audioPlayerRecorder
Simultaneously play and record using an audio device
Description
The audioPlayerRecorder
System object™ reads and writes audio samples using your computer’s audio device. To use
audioPlayerRecorder
, you must have an audio device and driver capable of
simultaneous playback and record.
See Audio I/O: Buffering, Latency, and Throughput for a detailed explanation of the data flow.
To simultaneously play and record:
Create the
audioPlayerRecorder
object and set its properties.Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?
Creation
Syntax
Description
returns a
System object, playRec
= audioPlayerRecorderplayRec
, that plays audio samples to an audio device
and records samples from the same audio device, in real time.
sets the SampleRate
property to playRec
= audioPlayerRecorder(sampleRateValue
)sampleRateValue
.
sets each property playRec
= audioPlayerRecorder(___,Name,Value
)Name
to the specified Value
.
Unspecified properties have default values.
Example: playRec = audioPlayerRecorder(48000,'BitDepth','8-bit
integer')
creates a System object, playRec
, that operates at a 48 kHz sample rate and an
8-bit integer bit depth.
Properties
Usage
Syntax
Description
writes one frame of audio samples, audioFromDevice
= playRec(audioToDevice
)audioToDevice
, to the selected
audio device, and returns one frame of audio, audioFromDevice
.
[
returns the number of samples overrun since the last call to
audioFromDevice
,numUnderrun
]
= playRec(audioToDevice
)playRec
.
[
returns the number of samples underrun since the last call to audioFromDevice
,numUnderrun
,numOverrun
]
= playRec(audioToDevice
)playRec
.
Note: When you call the audioPlayerRecorder
System object, the audio device specified by the Device
property is
locked. An audio device can be locked by only one audioPlayerRecorder
at
a time. To release the audio device, call release
on the
audioPlayerRecorder
System object.
Input Arguments
Output Arguments
Object Functions
To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named obj
, use
this syntax:
release(obj)