Platforms to show: All Mac Windows Linux Cross-Platform

Back to PortAudioMBS class.

PortAudioMBS.CountDevices as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 6.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Retrieve the number of available devices.
Example
dim pa as new PortAudioMBS

Dim c as Integer = pa.CountDevices
msgbox str(c)+" devices found"

for i as Integer = 0 to c-1
MsgBox pa.DeviceInfo(i).Name
next

The number of available devices may be zero.

Returns a non-negative value indicating the number of available devices or, a PaErrorCode (which are always negative) if PortAudio is not initialized or an error is encountered.

PortAudioMBS.DefaultHostApiIndexd as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 7.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Retrieve the index of the default host API.
Example
dim pa as new PortAudioMBS

dim DefaultHostApiIndexd as Integer = pa.DefaultHostApiIndexd

if DefaultHostApiIndexd>=0 then
dim d as PortAudioHostApiInfoMBS = pa.HostApiInfo(DefaultHostApiIndexd)
MsgBox "Default host API is: "+d.Name
else
MsgBox "No default host API."
end if

The default host API will be the lowest common denominator host API on the current platform and is unlikely to provide the best performance.

Returns a non-negative value ranging from 0 to (HostApiCount-1)indicating the default host API index or, a PaErrorCode (which are always negative) if PortAudio is not initialized or an error is encountered.

Some examples using this method:

PortAudioMBS.DefaultInputDeviceID as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 6.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Retrieve the index of the default input device.
Example
dim pa as new PortAudioMBS

dim DefaultInputDeviceID as Integer = pa.DefaultInputDeviceID

if DefaultInputDeviceID>=0 then
dim d as PortAudioDeviceInfoMBS = pa.DeviceInfo(DefaultInputDeviceID)
MsgBox "Default input device is: "+d.Name
else
MsgBox "No default input device."
end if

The result can be used in the inputDevice parameter to OpenStream().

Returns the default input device index for the default host API, or paNoDevice (-1) if no default input device is available or an error was encountered.

PortAudioMBS.DefaultOutputDeviceID as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 6.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Retrieve the index of the default output device.
Example
dim pa as new PortAudioMBS

dim DefaultOutputDeviceID as Integer = pa.DefaultOutputDeviceID

if DefaultOutputDeviceID>=0 then
dim d as PortAudioDeviceInfoMBS = pa.DeviceInfo(DefaultOutputDeviceID)
MsgBox "Default output device is: "+d.Name
else
MsgBox "No default output device."
end if

The result can be used in the outputDevice parameter to OpenStream().

Returns the default output device index for the defualt host API, or paNoDevice (-1) if no default output device is available or an error was encountered.

On the PC, the user can specify a default device by setting an environment variable. For example, to use device #1.
set PA_RECOMMENDED_OUTPUT_DEVICE=1
The user should first determine the available device ids by using the supplied application "pa_devs".

PortAudioMBS.DeviceInfo(DeviceIndex as Integer) as PortAudioDeviceInfoMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 6.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Retrieve an object containing information about the specified device.
Example
dim pa as new PortAudioMBS

Dim u as Integer = pa.CountDevices-1
for i as Integer = 0 to u
dim d as PortAudioDeviceInfoMBS = pa.DeviceInfo(i)
MsgBox d.Name+" with default "+str(D.DefaultSampleRate)+" Hz"
next

Returns an object of class PortAudioDeviceInfoMBS with the requested information. If the device parameter is out of range the function returns nil.

DeviceIndex: A valid device index in the range 0 to (PortAudioMBS.CountDevices-1)

PortAudioMBS.ErrorText(ErrorNumber as Integer) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 6.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Translate the error number into a human readable message.

PortAudioMBS.GetSampleSize(Format as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 7.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Returns the sample size in bytes of the given format.
Example
dim pa as new PortAudioMBS

const paFloat32 = 1

MsgBox str(pa.GetSampleSize(paFloat32))+" bytes per sample"

PortAudioMBS.HostApiCount as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 7.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Retrieve the number of available host APIs.
Example
dim pa as new PortAudioMBS

Dim c as Integer = pa.HostApiCount
msgbox str(c)+" host APIs found"

Even if a host API is available it may have no devices available.

Returns a non-negative value indicating the number of available host APIs or, a PaErrorCode (which are always negative) if PortAudio is not initialized or an error is encountered.

Some examples using this method:

PortAudioMBS.HostApiDeviceIndexToDeviceIndex(hostApiIndex as Integer, hostApiDeviceIndex as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 7.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Convert a host-API-specific device index to standard PortAudio device index.

This function may be used in conjunction with the deviceCount field of PaHostApiInfo to enumerate all devices for the specified host API.

hostApiIndex: A valid host API index ranging from 0 to (HostApiCount-1)
hostApiDeviceIndex: A valid per-host device index in the range 0 to (HostApiInfo(hostApi).deviceCount-1)

Returns a non-negative device index ranging from 0 to (DeviceCount-1) or, an error code (which are always negative) if PortAudio is not initialized or an error is encountered.

A paInvalidHostApi (-9978) error code indicates that the host API index specified by the hostApi parameter is out of range.

A paInvalidDevice (-9996) error code indicates that the hostApiDeviceIndex parameter is out of range.

Some examples using this method:

PortAudioMBS.HostApiInfo(hostApiIndex as Integer) as PortAudioHostApiInfoMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 7.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Retrieve an PortAudioHostApiInfoMBS object containing information about a specific host Api.
Example
dim pa as new PortAudioMBS
Dim u as Integer = pa.HostApiCount - 1

for i as Integer = 0 to u
dim d as PortAudioHostApiInfoMBS = pa.HostApiInfo(i)
MsgBox d.name
next

hostApiIndex: A valid host API index ranging from 0 to (HostApiCount-1)

Returns the information object. If the hostApi parameter is out of range or an error is encountered, the function returns nil.

Some examples using this method:

PortAudioMBS.HostApiTypeIdToHostApiIndex(type as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 7.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Convert a static host API unique identifier, into a runtime host API index.
Example
dim IndexDirectSound as Integer
dim p as new PortAudioMBS
const paDirectSound=1
IndexDirectSound=p.HostApiTypeIdToHostApiIndex(paDirectSound)

type: A unique host API identifier. See PortAudioHostApiInfoMBS.Type for the list of constants.

Returns a valid PaHostApiIndex ranging from 0 to (HostApiCount-1) or, a PaErrorCode (which are always negative) if PortAudio is not initialized or an error is encountered.

The paHostApiNotFound (-9979) error code indicates that the host API specified by the type parameter is not available.

PortAudioMBS.HostError as PortAudioHostErrorInfoMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 7.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Return information about the last host error encountered.

This function is provided as a last resort, primarily to enhance debugging by providing clients with access to all available error information.

Returns an object constaining information about the host error. The values in this structure will only be valid if a PortAudio function has previously returned the paUnanticipatedHostError.

PortAudioMBS.IsFormatSupported(input as PortAudioStreamParametersMBS, output as PortAudioStreamParametersMBS, sampleRate as Double) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 7.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Determine whether it would be possible to open a stream with the specified parameters.

input: An object that describes the input parameters used to open a stream. The suggestedLatency field is ignored. inputParameters must be nil for output-only streams.

output: An object that describes the output parameters used to open a stream. The suggestedLatency field is ignored. outputParameters must be nil for input-only streams.

sampleRate: The required sampleRate. For full-duplex streams it is the sample rate for both input and output

Returns 0 if the format is supported, and an error code indicating why the format is not supported otherwise. The constant paFormatIsSupported (0) is provided to compare with the return value for success.

PortAudioMBS.SampleSize(theFormat as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 6.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Return size in bytes of a single sample in a given sample format or paSampleFormatNotSupported (-9994).

Returns 0 on any error.

Constants for sample format:
const paFloat32= 1
const paInt32= 2
const paInt24= 4
const paInt16= 8
const paInt8= 16
const paUInt8= 32
const paCustomFormat= 65536
const paNonInterleaved= negative sign

The standard formats paFloat32, paInt16, paInt32, paInt24, paInt8 and aUInt8 are usually implemented by all implementations.

The floating point representation (paFloat32) uses +1.0 and -1.0 as the maximum and minimum respectively.

paUInt8 is an unsigned 8 bit format where 128 is considered "ground"

The paNonInterleaved flag indicates that a multichannel buffer is passed as a set of non-interleaved pointers.

PortAudioMBS.Sleep(msec as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Audio MBS Audio Plugin 7.0 ✅ Yes ✅ Yes ✅ Yes ❌ No All
Put the caller to sleep for at least 'msec' milliseconds.

This function is provided only as a convenience for authors of portable code (such as the tests and examples in the PortAudio distribution.)
The function may sleep longer than requested so don't rely on this for accurate musical timing.

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


The biggest plugin in space...