getaudiodata

Store recorded audio signal in numeric array

Description

example

y = getaudiodata(recorder) returns recorded audio data associated with audiorecorder object recorder in a double array y.

example

y = getaudiodata(recorder,dataType) converts the signal data to the specified data type.

Examples

collapse all

Create a recording using the audiorecorder object and then get the audio signal as a numeric array of different data types.

Create an audiorecorder object and record a five second audio clip from your microphone.

recObj = audiorecorder;
disp('Start speaking.')
Start speaking.
recordblocking(recObj,5);
disp('End of Recording.');
End of Recording.

Get the audio signal as a double array and plot the data.

doubleArray = getaudiodata(recObj);
plot(doubleArray);
title('Audio Signal (double)');

Get the audio signal as an int8 array and plot the data. Based on the data type specified, the same audio signal is returned with a different range of values . In this case, the values in the int8 array can span between -128 and 127.

int8Array = getaudiodata(recObj,'int8');
plot(int8Array);
title('Audio Signal (int8)');

Input Arguments

collapse all

Audio recorder object, specified as an audiorecorder object. Use the audiorecorder function to create the object.

Data type of the output audio signal, specified as one of these values: 'double', 'single', 'int16', 'int8', or 'uint8'.

Data Types: char | string

Output Arguments

collapse all

Audio signal data, returned as a numeric array.

The number of columns in y depends on the number of channels in the recording: one for mono and two for stereo.

The value range of y depends on the specified dataType.

Data Type

Sample Value Range

int8

-128 to 127

uint8

0 to 255

int16

-32768 to 32767

single

-1 to 1

double

-1 to 1

Introduced in R2006a