Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

PortAudioStreamRecorderMBS.Constructor(BufferSize as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Audio MBS Audio Plugin 9.1 Yes Yes Yes Yes No
Function: Creates a new object using a buffer of the given size.
Notes:
The buffer must be a power of 2. For example one Megabyte (2^20). This defines the ring buffer used to buffer samples between data coming from sound device and you call ReadFrames method.

Automatically we take paFloat32 as format for sample buffer.

At 44100 Hz, and 4 bytes per value and 2 channels, you will need 352800 bytes per second on storage.

Feedback, Comments & Corrections

PortAudioStreamRecorderMBS.Flush
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Audio MBS Audio Plugin 10.1 Yes Yes Yes Yes No
Function: Clears the buffer and discards all current samples.

Feedback, Comments & Corrections

PortAudioStreamRecorderMBS.OpenDefaultStream(numInputChannels as Integer, sampleRate as Double) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Audio MBS Audio Plugin 9.1 Yes Yes Yes Yes No
Function: A simplified version of OpenStream() that opens the default input devices.
Notes:
Sampleformat is always 32bit float in this class. (use memoryblock.singlevalue)

numInputChannels: The number of channels of sound to be delivered. It can range from 1 to the value of maxInputChannels in the PortAudioDeviceInfoMBS object for the default output device. If 0 the stream is opened as an output-only stream.

sampleRate: Same as OpenStream parameter of the same name.

Returns an error code.
Error -2 is from the plugin and reports that the buffer was not created before.

Feedback, Comments & Corrections

PortAudioStreamRecorderMBS.OpenStream(inputParameters as PortAudioStreamParametersMBS, sampleRate as Double, framesPerBuffer as Integer, streamFlags as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Audio MBS Audio Plugin 9.1 Yes Yes Yes Yes No
Function: Opens a stream for input.
Notes:
Sampleformat is always 32bit float in this class. (use memoryblock.singlevalue)

outputParameters: A object that describes the input parameters used by the opened stream. See PortAudioStreamParametersMBS for a description of these parameters.

sampleRate: The desired sampleRate.

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 recieve 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.

const paFramesPerBufferUnspecified=0

streamFlags: Flags which modify the behaviour of the streaming process. This parameter may contain a combination of flags ORed together. Some flags may only be relevant to certain buffer formats.

const paNoFlag= 0no flags
const paClipOff= 1Disable default clipping of out of range samples.
const paDitherOff= 2Flag requests that where possible a full duplex stream will not discard overflowed input samples without calling the stream callback. This flag is only valid for full duplex callback streams and only when used in combination with the paFramesPerBufferUnspecified (0) framesPerBuffer parameter. Using this flag incorrectly results in a paInvalidFlag error being returned from OpenStream and OpenDefaultStream.
const paNeverDropInput= 4Call the stream callback to fill initial output buffers, rather than the default behavior of priming the buffers with zeros (silence). This flag has no effect for input-only and blocking read/write streams.
const paPrimeOutputBuffersUsingStreamCallback= 8Call the stream callback to fill initial output buffers, rather than the default behavior of priming the buffers with zeros (silence). This flag has no effect for input-only and blocking read/write streams.

Upon success OpenStream() returns paNoError and places a pointer to a valid PaStream in the stream argument. The stream is inactive (stopped).
If a call to OpenStream() fails, a non-zero error code is returned (see PaError for possible error codes) and the value of stream is invalid.

Error -2 is from the plugin and reports that the buffer was not created before.

Feedback, Comments & Corrections

PortAudioStreamRecorderMBS.ReadFrames(mem as memoryblock, SizeInBytes as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Audio MBS Audio Plugin 9.1 Yes Yes Yes Yes No
Function: Reads frames into the memoryblock.
Example:
dim s as PortAudioStreamRecorderMBS
dim m as memoryblock

m=newmemoryblock(1024*1024)
// initialize

dim frames as Integer

frames=s.ReadFrames(m,m.size)

msgbox "we got "+str(frames)+" frames."
Notes:
You pass a memoryblock and the size of this memoryblock in bytes.
Values are stored in floats (memoryblock.singlevalue) so you get at maximum SizeInBytes/4 values. And if you use more than one channel, you will receive them interlaced.

ReadFrames uses a mutex to access share data, so this call is expensive. Use a big buffer.

Feedback, Comments & Corrections

PortAudioStreamRecorderMBS.ResizeBuffer(BufferSize as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Audio MBS Audio Plugin 9.1 Yes Yes Yes Yes No
Function: Resizes the buffer.
Notes:
Do not resize while you are recording (this can crash).

The buffer must be a power of 2. For example one Megabyte (2^20).

At 44100 Hz, and 4 bytes per value and 2 channels, you will need 352800 bytes per second on storage.

Feedback, Comments & Corrections

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




Links
MBS FileMaker tutorial videos