Main Content

info

Characteristic information about audio device writer

Description

S = info(adw) returns a structure, S, containing characteristic information of the audio device writer object, adw.

example

Examples

collapse all

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

collapse all

Audio device writer object, specified as audioDeviceWriter System object™.

Output Arguments

collapse all

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

See Also

Functions

Objects