getaudiodata

Store recorded audio signal in numeric array

Syntax

y = getaudiodata(recorder)
y = getaudiodata(recorder, dataType)

Description

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

y = getaudiodata(recorder, dataType) converts the signal data to the specified data type: 'double', 'single', 'int16', 'int8', or 'uint8'.

Output Arguments

y

Audio signal data y contains the same number of columns as the number of channels in the recording: one for mono, two for stereo. The range of values depends on the data type, as shown in the following table.

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

Examples

Collect a sample of your speech with a microphone, and plot the signal data:

% Record your voice for 5 seconds.
recObj = audiorecorder;
disp('Start speaking.')
recordblocking(recObj, 5);
disp('End of Recording.');

% Play back the recording.
play(recObj);

% Store data in double-precision array.
myRecording = getaudiodata(recObj);

% Plot the waveform.
plot(myRecording);
Was this topic helpful?