info
Characteristic information about audio device writer
Syntax
Description
Examples
Read from File and Write to Audio Device
Read an MP3 audio file and play it through your default audio output device.
Create a dsp.AudioFileReader
object with default settings. Use the audioinfo
function to return a structure containing information about the audio file.
fileReader = dsp.AudioFileReader('speech_dft.mp3'); fileInfo = audioinfo('speech_dft.mp3')
fileInfo = struct with fields:
Filename: '/mathworks/devel/bat/filer/batfs2566-0/Bdoc24b.2725827/build/runnable/matlab/toolbox/dsp/dsp/samples/speech_dft.mp3'
CompressionMethod: 'MP3'
NumChannels: 1
SampleRate: 22050
TotalSamples: 112320
Duration: 5.0939
Title: []
Comment: []
Artist: []
BitRate: 64
Create an audioDeviceWriter
object and specify the sample rate.
deviceWriter = audioDeviceWriter('SampleRate',fileInfo.SampleRate);
Call setup
to reduce the computational load of initialization in an audio stream loop.
setup(deviceWriter,zeros(fileReader.SamplesPerFrame,...
fileInfo.NumChannels))
Use the info
function to obtain the characteristic information about the device writer.
info(deviceWriter)
ans = struct with fields:
Driver: 'ALSA'
DeviceName: 'ALSAdefault'
MaximumOutputChannels: 32
In an audio stream loop, read an audio signal frame from the file, and write the frame to your device.
while ~isDone(fileReader) audioData = fileReader(); deviceWriter(audioData); end
Close the input file and release the device.
release(fileReader) release(deviceWriter)
Input Arguments
adw
— Audio device writer object
audioDeviceWriter
audioDeviceWriter
Audio device writer object, specified as audioDeviceWriter
System object™.
Output Arguments
S
— Characteristic information
struct
Characteristic information of the audio device writer object, returned as a structure. The fields of the structure vary depending on the System object.
Version History
Introduced in R2016a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)