Platforms to show: All Mac Windows Linux Cross-Platform

Back to PortAudioStreamMBS class.

PortAudioStreamMBS.Callback(InputBuffer as memoryblock, outputBuffer as memoryblock, FrameCount as Integer, inputBufferAdcTime as Double, currentTime as Double, outputBufferDacTime as Double, statusFlags as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Audio MBS Audio Plugin 7.0 ✅ Yes ✅ Yes ✅ Yes ❌ No
The event called when new data is needed or received.

This event is implemented by PortAudio clients. They consume, process or generate audio in response to requests from an active PortAudio stream.

InputBuffer and outputBuffer are arrays of interleaved samples, the format, packing and number of channels used by the buffers are determined by parameters to OpenStream().

frameCount: The number of sample frames to be processed by the stream callback.

inputBufferAdcTime, currentTimeTiming and outputBufferDacTime: The time in seconds when the first sample of the input buffer was received at the audio input, the time in seconds when the first sample of the output buffer will begin being played at the audio output, and the time in seconds when the stream callback was called.

statusFlags: Flags indicating whether input and/or output buffers have been inserted or will be dropped to overcome underflow or overflow conditions.

Returns the stream callback should return one of the values in the PaStreamCallbackResult enumeration. To ensure that the callback continues to be called, it should return paContinue (0). Either paComplete or paAbort can be returned to finish stream processing, after either of these values is returned the callback will not be called again. If paAbort is returned the stream will finish as soon as possible. If paComplete is returned, the stream will continue until all buffers generated by the callback have been played.
This may be useful in applications such as soundfile players where a specific duration of output is required. However, it is not necessary to utilise this mechanism as Stop(), Abort() or Close() can also be used to stop the stream. The callback must always fill the entire output buffer irrespective of its return value.

With the exception of CpuLoad() it is not permissable to call PortAudio API functions from within the stream callback.

Flag bit constants for the statusFlags to Callback:

paInputUnderflow = 1
In a stream opened with paFramesPerBufferUnspecified, indicates that input data is all silence (zeros) because no real data is available. In a stream opened without paFramesPerBufferUnspecified, it indicates that one or more zero samples have been inserted into the input buffer to compensate for an input underflow.

paInputOverflow = 2
In a stream opened with paFramesPerBufferUnspecified, indicates that data prior to the first sample of the input buffer was discarded due to an overflow, possibly because the stream callback is using too much CPU time. Otherwise indicates that data prior to one or more samples in the input buffer was discarded.

paOutputUnderflow = 4
Indicates that output data (or a gap) was inserted, possibly because the stream callback is using too much CPU time.

paOutputOverflow = 8
Indicates that output data will be discarded because no room is available.

paPrimingOutput = 16
Some of all of the output data will be used to prime the stream, input data may be zero.

Allowable return values for the callback: (PaStreamCallbackResult)
const paContinue= 0
const paComplete= 1
const paAbort= 2

PortAudioStreamMBS.Finished

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Audio MBS Audio Plugin 7.0 ✅ Yes ✅ Yes ✅ Yes ❌ No
This event is implemented by PortAudio clients.

Once registered they are called when the stream becomes inactive (ie once a call to Stop() will not block).
A stream will become inactive after the stream callback returns non-zero, or when Stop or Abort is called. For a stream providing audio output, if the stream callback returns paComplete, or Stop is called, the stream finished callback will not be called until all generated sample data has been played.

The items on this page are in the following plugins: MBS Audio Plugin.


The biggest plugin in space...