soren wrote:@breeze4me - amazing, thanks!! I had no idea it was necessary first to call csoundSetRTAudioModule - how did you figure that out..?
Googling !
https://csound-devel.narkive.com/DhUQx8 ... s-from-api
BTW, the following code may be a proper way.
Code: Select all
CompilerIf #PB_Compiler_IsMainFile
EnableExplicit
CompilerEndIf
#CSOUND_SUCCESS = 0
#CSOUND_ERROR = -1
#CSOUND_INITIALIZATION = -2
#CSOUND_PERFORMANCE = -3
#CSOUND_MEMORY = -4
#CSOUND_SIGNAL = -5
#CSOUNDINIT_NO_SIGNAL_HANDLER = 1
#CSOUNDINIT_NO_ATEXIT = 2
Structure CS_AUDIODEVICE Align #PB_Structure_AlignC
device_name.a[64]
device_id.a[64]
rt_module.a[64]
max_nchnls.l
isOutput.l
EndStructure
PrototypeC.i Prototype_csoundCreate(*hostData)
PrototypeC.i Prototype_csoundDestroy(*hostData)
PrototypeC.i Prototype_csoundGetAudioDevList(*csound, *list.CS_AUDIODEVICE, isOutput.l)
PrototypeC.i Prototype_csoundGetVersion()
PrototypeC.i Prototype_csoundSetRTAudioModule(*csound, sModule.p-utf8)
PrototypeC.l Prototype_csoundGetModule(*csound, number.i, *name, *type)
Global csoundCreate.Prototype_csoundCreate
Global csoundDestroy.Prototype_csoundDestroy
Global csoundGetAudioDevList.Prototype_csoundGetAudioDevList
Global csoundGetVersion.Prototype_csoundGetVersion
Global csoundSetRTAudioModule.Prototype_csoundSetRTAudioModule
Global csoundGetModule.Prototype_csoundGetModule
Global CSoundLib.i
Define *CSound, n.i, i.i
CSoundLib = OpenLibrary(#PB_Any, "csound64.dll")
If CSoundLib
csoundCreate = GetFunction(CSoundLib, "csoundCreate")
csoundDestroy = GetFunction(CSoundLib, "csoundDestroy")
csoundGetAudioDevList = GetFunction(CSoundLib, "csoundGetAudioDevList")
csoundGetVersion = GetFunction(CSoundLib, "csoundGetVersion")
csoundSetRTAudioModule = GetFunction(CSoundLib, "csoundSetRTAudioModule")
csoundGetModule = GetFunction(CSoundLib, "csoundGetModule")
CompilerIf #PB_Compiler_IsMainFile
Debug "CSound Version " + Str(csoundGetVersion())
*csound = csoundCreate(#Null)
If *csound
Define *name
Define *type
Define ModuleName.s
While csoundGetModule(*csound, i, @*name, @*type) = #CSOUND_SUCCESS
Debug PeekS(*name, -1, #PB_UTF8)
Debug PeekS(*type, -1, #PB_UTF8)
If PeekS(*type, -1, #PB_UTF8) = "audio"
ModuleName = PeekS(*name, -1, #PB_UTF8)
; Break
EndIf
i + 1
Wend
Debug ""
If ModuleName
csoundSetRTAudioModule(*csound, ModuleName) ; it seems to work with "portaudio", "pa_bl", "pa_cb"
n = csoundGetAudioDevList(*csound, 0, 1)
Debug "Output AudioDevices: " + Str(n)
If n
Dim devlist.CS_AUDIODEVICE(n)
csoundGetAudioDevList(*csound, @devlist(), 1)
For i = 0 To n - 1
Debug PeekS(@devlist(i)\device_name[0], -1, #PB_UTF8)
Next i
EndIf
EndIf
csoundDestroy(*csound)
EndIf
CloseLibrary(CSoundLib)
CompilerEndIf
EndIf