http://anotherprophecy.com/system/scrip ... 110326.zip
Edit: Actually it seems not to work...

Code: Select all
Enumeration ; PaHostApiTypeId
#paInDevelopment=0 ; /* use While developing support For a new host API */
#paDirectSound=1
#paMME=2
#paASIO=3
#paSoundManager=4
#paCoreAudio=5
#paOSS=7
#paALSA=8
#paAL=9
#paBeOS=10
#paWDMKS=11
#paJACK=12
#paWASAPI=13
EndEnumeration
Code: Select all
XIncludeFile "PortAudio.pb"
Procedure ErrorCheck(err)
If err <> #paNoError
MessageRequester("", PeekS(Pa_GetErrorText(err), -1, #PB_Ascii))
End
EndIf
EndProcedure
ErrorCheck(Pa_Initialize())
numDevices = Pa_GetDeviceCount()
Dim deviceNames.s(numDevices - 1)
For device = 0 To numDevices - 1
*deviceInfo.PaDeviceInfo = Pa_GetDeviceInfo(device)
ioCapable.s = " ["
If *deviceInfo\maxInputChannels : ioCapable + "I" : EndIf
If *deviceInfo\maxOutputChannels : ioCapable + "O" : EndIf
ioCapable + "]"
deviceNames(device) = Str(device) + " " + PeekS(*deviceInfo\name, -1, #PB_Ascii) + ioCapable
Debug deviceNames(device)
Next
Debug ""
Debug "Default input : " + deviceNames(Pa_GetDefaultInputDevice())
Debug "Default output : " + deviceNames(Pa_GetDefaultOutputDevice())
Pa_Terminate()

but the way i implemented my application with directsound is illustrated below. the application has 10 channels, and in each channel i can load a wav file (and process it once loaded) or load a sound synthesized from scratch. each channel is an independent directsound buffer. Once sounds have been thus loaded into the channels, the sequencer part of the application can trigger play of each buffer independently (and if another trigger arrives to play while a sound is still playing, the buffer plays from the start again, which of course is what one wants from a sequencer), and directsound makes available methods on each buffer to allow the user to change the level, pan and frequency of the sound in the buffer 'on the fly' while the sequence is playing. a new sound can be loaded into any buffer or an existing sound in a buffer further processed while the sequence is playing, by the 'synth' part of the application. as you can see, there is no 'mix all the sounds prior and stream through one object' technique here. I was wondering how to do similar with purebasic->portaudioYou need to mix them in the callback. (Mixing two streams just means adding the sample values.)


Code: Select all
ProcedureC PaStreamCallback(*in, *output.Float, frameCount, *timeInfo.PaStreamCallbackTimeInfo, statusFlags, *userData)
PhaseAdd = Freq / #SampleRate
While frameCount
*output\f = Sin(#PI2 * WaveFormFn(Phase))
Phase + PhaseAdd
If Phase > 1 : Phase = Phase - 1 : EndIf
*output + 4
frameCount - 1
Wend
EndProcedure