1
votes

Can any one tell me what does portaudio callback function variable framesperbuffer is? If i want to play audio stream through PA_WriteStream() by 64 bytes data every iteration then what value i should put in the framesperbuffer?

Also in lsbsndfilelibrary the function for reading wave file expects variable with name frame to be provided. i.e.

samples=sf_readf_float(file,fptr,frames);

if i put frames=256 then always 64 samples are returned in fptr and rest are garbage whereas returned values from read function is 256. I have checked through following code

memcpy(array,fptr,samples); //samples returned are 256 always but first 64 contain data

now array[0] to array[63] contain values and array[64] to array[255] contain null value in every iteration of file read. Now i have to write data read to portaudio audio playing function then what framesperbuffer should be filled in with.

Also in some cases i need to process data and samples reduce to 32 (when i consume two samples to form one output sample)then what value should i put in the framesperbuffer variable?

1

1 Answers

1
votes

framesPerBuffer The number of frames passed to the stream callback function, or the preferred block granularity for a blocking read/write stream. The special value paFramesPerBufferUnspecified (0) may be used to request that the stream callback will receive an optimal (and possibly varying) number of frames based on host requirements and the requested latency settings. Note: With some host APIs, the use of non-zero framesPerBuffer for a callback stream may introduce an additional layer of buffering which could introduce additional latency. PortAudio guarantees that the additional latency will be kept to the theoretical minimum however, it is strongly recommended that a non-zero framesPerBuffer value only be used when your algorithm requires a fixed number of frames per stream callback.