Code: Select all
Dim buffers.i(2)
buffers(0) = 123;
!((integer*)a_buffers.a)[1]=234;
Debug buffers(0)
Debug buffers(1)
I'm not sure why your using the blocking I/O methods, using a callback would simplify the problem
as it passes you the pointers for the input and output buffers.
here's an example it will open a the default recording device and the call back copies it to the default output
Code: Select all
!//#include D:\pb\portaudio\portaudio.h; path to portaudio.h
ProcedureC IOCallback(*in.float,*out.float,framesPerBuffer,*timeInfo,statusFlags,*userData)
CopyMemory(*in,*out,framesPerBuffer*SizeOf(float)*2) ;copy in to out number of samples * size of float * 2 channels
EndProcedure
OpenConsole()
!#define SAMPLE_RATE (44100)
!#define PA_SAMPLE_TYPE paFloat32
!PaStreamParameters inputParameters;
!PaStreamParameters outputParameters;
!PaStream *stream;
Global err,pcb,samplesize ;
samplesize = 1024
pcb= @IOCallback()
!v_err = Pa_Initialize();
If err <> 0
Goto error;
EndIf
!inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
!if (inputParameters.device == paNoDevice) {
Debug "Error: No default input device."
Goto error;
!}
!inputParameters.channelCount = 2; /* stereo input */
!inputParameters.sampleFormat = PA_SAMPLE_TYPE;
!inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device )->defaultLowInputLatency;
!inputParameters.hostApiSpecificStreamInfo = 0;
!outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
!if (outputParameters.device == paNoDevice) {
Debug "Error: No Default output device."
Goto error;
!}
!outputParameters.channelCount = 2; /* stereo output */
!outputParameters.sampleFormat = PA_SAMPLE_TYPE;
!outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
!outputParameters.hostApiSpecificStreamInfo = 0;
!v_err = Pa_OpenStream(&stream,&inputParameters,&outputParameters,SAMPLE_RATE,v_samplesize,0,v_pcb,0);
If err <> 0
Goto error;
EndIf
!v_err = Pa_StartStream( stream );
If err <> 0
Goto error;
EndIf
PrintN("Hit ENTER to stop program.");
Input()
!v_err = Pa_CloseStream( stream );
If err <> 0
Goto error;
EndIf
!Pa_Terminate();
End
error:
!Pa_Terminate();