audioDeviceReader
Record from sound card
Description
The audioDeviceReader
System object™ reads audio samples using your computer’s audio input device.
See Audio I/O: Buffering, Latency, and Throughput for a detailed explanation of the audio device reader data flow.
The audio device reader specifies the driver, the device and its attributes, and the data type and size output from your System object.
To stream data from an audio device:
Create the
audioDeviceReader
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, deviceReader
= audioDeviceReaderdeviceReader
, that reads audio samples using an audio
input device in real time.
sets the SampleRate property to
deviceReader
= audioDeviceReader(sampleRateValue
)sampleRateValue
.
sets the SamplesPerFrame property to
deviceReader
= audioDeviceReader(sampleRateValue
,sampPerFrameValue
)sampPerFrameValue
.
sets each property deviceReader
= audioDeviceReader(___,Name,Value
)Name
to the specified Value
.
Unspecified properties have default values.
Example: deviceReader = audioDeviceReader(16000,'BitDepth','8-bit
integer')
creates a System object, deviceReader
, that operates at a 16 kHz sample rate and
an 8-bit integer bit depth.
Properties
Usage
Description
returns one frame of audio samples from the selected audio input device.audioFromDevice
= deviceReader
()
[
returns the number of samples by which the audio reader's queue was overrun since the last
call to audioFromDevice
,numOverrun
]
= deviceReader
()deviceReader
.
Note: When you call the audioDeviceReader
System object, the audio device specified by the Device
property is locked. An audio device can be locked by only one
audioDeviceReader
at a time. To release the audio device, call
release
on your audioDeviceReader
object.
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)
Examples
Extended Capabilities
Version History
Introduced in R2016a