Audio In

class audioIn.AudioIn[source]

Bases: Schedule

Class which implements the Microphone features.

Any device which has Audio IN should instantiate this class. It contains all the necessary methods to use the audio inputs of a VPIxx device.

getBaseAddress()[source]

Gets the Ram buffer start address.

This method allows the user to get the RAM buffer start address used in schedules. It should only be used if the user wants the schedules to wrap when it has reached its maximum size. When schedules are expected to wrap, the user should also use setBufferSize()

Returns:

Any value in a range of 0 up to the RAM size.

Return type:

int

getBufferSize()[source]

Gets the Ram buffer size.

This method allows the user to get the RAM buffer size used in schedules.

Returns:

Any value in a range of 0 up to the RAM size.

Return type:

int

getGroupDelay(sample_rate)[source]

Gets the CODEC Audio OUT group delay in seconds.

Returns:

delay in seconds.

Return type:

float

getMicSource(dBUnits=0)[source]

Gets the source and the gain of the microphone input.

Parameters:

dBUnits (int, optional) – Set non-zero to return the gain in dB. Defaults to 0.

Returns:

A list containing the [gain value, microphone source]

Low-level C definition:

int DPxGetMicSource(int DBUnits)

getScheduleBufferMode()[source]

Gets the microphone Left/Right configuration mode.

This method allows the user to set the microphone to one of the mono, left, right or stereo mode.

Returns:

Any of the following predefined constants.

  • mono : Mono data is written to the schedule buffer. The average of Left/Right CODEC data.

  • left : Left data is written to the schedule buffer.

  • right : Right data is written to the schedule buffer.

  • stereo : Left and Right data are both written to the schedule buffer.

Return type:

String

getScheduleCount()[source]

Gets the schedule count value.

This method allows the user to get the current count for a schedule.

Returns:

Any positive value equal to or greater than 0.

Return type:

int

getScheduleOnset()[source]

Gets the schedule onset value.

This method allows the user to get the schedule onset value used in schedules. The onset represents a nanosecond delay between schedule start and first sample.

Returns:

Any positive value equal to or greater than 0.

Return type:

int

getScheduleRate()[source]

Gets the schedule rate value.

This method allows the user to get the schedule rate value used in schedules. The rate represents the speed at which the schedule updates.

Returns:

Any positive value equal to or greater than 0.

Return type:

int

getScheduleUnit()[source]

Gets the schedule unit value.

This method allows the user to get the schedule unit value used in schedules.

Returns:

Any positive value equal to or greater than 0.

Return type:

int

getValueLeft()[source]

Gets the current value of the left channel.

This method allows the user to get the 16-bit 2’s complement signed value for left MIC channel.

Returns:

16-bit 2’s complement signed value.

Return type:

int

getValueRight()[source]

Gets the current value of the right channel.

This method allows the user to get the 16-bit 2’s complement signed value for right MIC channel.

Returns:

16-bit 2’s complement signed value.

Return type:

int

getWriteAddress()[source]

Gets the Ram buffer write address.

This method allows the user to get the RAM buffer write address used in schedules.

Returns:

Any value in a range of 0 up to the RAM size.

Return type:

int

isCountDownEnabled()[source]

Verifies the schedule count down mode.

Returns:

True if the schedule is decrementing at every sample, False otherwise.

Return type:

Bool

isLoopbackEnabled()[source]

Verifies the digital inputs and outputs loopback mode.

Returns:

True if transitions are being stabilized, False otherwise.

Return type:

enable (Bool)

See also

setLoopback

isScheduleRunning()[source]

Verifies if a schedule is currently running on the subsystem.

Returns:

True if a schedule is currently running, False otherwise.

Return type:

Bool

See also

startSchedule, stopSchedule, getScheduleRunningState

setBaseAddress(address)[source]

Sets the Ram buffer start address.

This method allows the user to set the RAM buffer start address used in schedules. The given address must be an even value.

Parameters:

address (int) – Any value in a range of 0 up to the RAM size.

setBufferSize(buffer_size)[source]

Sets the Ram buffer size.

This method allows the user to set the RAM buffer size used in schedules. It should only be used if the user wants the schedules to wrap when it has reached its maximum size. When schedules are expected to wrap, the user should also use setBaseAddress() The given size is in byte and must be an even value.

Parameters:

buffer_size (int) – Any value in a range of 0 up to the RAM size.

setLoopback(enable)[source]

Sets the digital inputs and outputs loopback mode.

This method allows the user to enable or disable the loopback between digital output ports and digital inputs. When enabled, the digital outputs send their data to the digital inputs. When disabled, the digital inputs will not get the digital outputs data.

Parameters:

enable (Bool) – True if loopback is enabled, False otherwise.

setMicSource(source, gain, dBUnits=0)[source]

Sets the source for the MIC

Select the source of the microphone input. Typical gain values would be around 100 for a microphone input, and probably 1 for line-level input.

Parameters:
  • source (int) –

    One of the following:

    • MIC: Microphone level input.

    • LINE: Line level audio input.

  • gain (int) –

    The gain can take the following values depending on the scale:

    • linear scale : [1, 1000]

    • dB scale : [0, 60] dB

  • dBUnits (int, optional) – Set non-zero to return the gain in dB. Defaults to 0.

setScheduleBufferMode(mode)[source]

Sets the schedule buffer storing mode.

This method allows the user to configure how microphone left and right channels are stored to the schedule buffer.

Parameters:

mode (str) –

Any of the following predefined constants.

  • mono : Mono data is written to the schedule buffer. The average of Left/Right CODEC data.

  • left : Left data is written to the schedule buffer.

  • right : Right data is written to the schedule buffer.

  • stereo : Left and Right data are both written to the schedule buffer.

setScheduleCount(count)[source]

Sets the schedule count.

This method allows the user to set the schedule count for a schedule with a fixed number of samples. In this case, the schedule will decrement at a given rate and stop when the count reaches 0.

Parameters:

count (int) – Any positive value greater than 0.

setScheduleCountDown(enable)[source]

Sets the schedule count down mode.

This method allows the user to enable or disable the countdown on a schedule. When enabled, the schedule decrements at the given rate and stops automatically when the count hits 0. When disabled, the schedule increments at the given rate and is stopped by calling stopSchedule().

Parameters:

enable (Bool) – True if countdown is enabled, False otherwise.

setScheduleOnset(onset)[source]

Sets the schedule onset value.

This method allows the user to set the nanosecond delay between schedule start and first sample. If no delay is required, this method doesn’t need to be used. Default value is 0.

Parameters:

onset (int) – Any positive value equal to or greater than 0.

setScheduleRate(rate, unit='hz')[source]

Sets the schedule rate.

This method allows the user to set the schedule rate. Since the rate can be given with different units, the method also needs to have a unit associated with the rate.

nanosecond delay between schedule start and first sample. If no delay is required, this method does not need to be used. Default value is 0.

Parameters:
  • rate (int) – Any positive value equal to or greater than 0.

  • unit (str) –

    Any of the following predefined constants.

    • hz : samples per second, maximum 102.4 kHz.

    • video : samples per video frame, maximum 102.4 kHz.

    • nano : sample period in nanoseconds, minimum 9750 ns.

setWriteAddress(address)[source]

Sets the Ram buffer write address.

This method allows the user to set the RAM buffer write address used in schedules. This address is used by the schedule to know where the data should be first written to. The schedule will then write the following data to the address following the RAM buffer write address.

The given address must be an even value.

Parameters:

address (int) – Any value in a range of 0 up to the RAM size.

startSchedule()[source]

Starts a schedule.

Schedules may be configured in different ways, affecting their behavior. Before a schedule is started, the user should make sure that it is properly set in the right mode.

stopSchedule()[source]

Stops the active schedule for a given subsystem.

Depending on how the Schedules are configured, it may not be necessary to call this method. When a schedule is using a countdown, it is not required to stop the schedule.