getaudiodata
Store recorded audio signal in numeric array.
📝Syntax
y = getaudiodata(recorder)
y = getaudiodata(recorder, dataType)
📥Input Arguments
Parameter Description
recorder audiorecorder object: audio recorder object created by audiorecorder.
dataType string or character vector: data type of output audio signal. Valid values: 'double' (default), 'single', 'int16', 'int8', 'uint8'.
📤Output Arguments
Parameter Description
y numeric array: audio signal data. Number of columns depends on channel count.
📄Description

getaudiodata returns recorded audio data from an audiorecorder object as a numeric array.

y = getaudiodata(recorder) returns the audio data as a double array.

y = getaudiodata(recorder, dataType) returns the audio data converted to the specified data type.

The number of columns in y matches the number of channels in the recording (1 for mono, 2 for stereo).

The value range of y depends on dataType:

Data Type Sample Value Range
int8 -128 to 127
uint8 0 to 255
int16 -32,768 to 32,767
single or double -1 to 1
💡Examples
Get Data from Audio Recorder Object
recObj = audiorecorder;
disp('Start speaking.')
recordblocking(recObj, 5);
disp('End of Recording.');
doubleArray = getaudiodata(recObj);
plot(doubleArray);
title('Audio Signal (double)');
      
Get audio as int8 array
recObj = audiorecorder;
recordblocking(recObj, 2);
int8Array = getaudiodata(recObj, 'int8');
plot(int8Array);
title('Audio Signal (int8)');
      
🔗See Also
audiorecorder
🕔Version History
Version Description
1.16.0 initial version
Edit this page on GitHub