How to write from audioplayer?

9 Ansichten (letzte 30 Tage)
Joseph Patrick
Joseph Patrick am 26 Okt. 2023
Kommentiert: Joseph Patrick am 27 Okt. 2023
Hi, I'm using AppDesigner to process Audio. It reads the audio file and goes through a filtering process, however I'm having some issues trying to save the filtered audio.
I have a push button to save the filtered audio, but all I've managed to do is save it as an audioplayer type.
I then try to save it in matlab by doing this:
% Saved file name
output_name = 'filtered.wav';
fs = 16000;
audiowrite(output_name, FilteredAudio, fs);
However audiowrite won't work because FilteredAudio is an audioplayer insteead of an integer.
Is there a way to write from an audioplayer? Or extract an int?

Antworten (1)

Pratyush
Pratyush am 26 Okt. 2023
Hi Joseph,
I understand that you want to save a filtered audio file to a WAv file.
To extract the audio data from the audioplayer object, you can use the "getaudiodata" function. This function returns the audio data as a double-precision array. You can refer to the following documentation for more details on "getaudiodata": https://in.mathworks.com/help/matlab/ref/audiorecorder.getaudiodata.html
Here's an example code snippet that saves the filtered audio from an audioplayer object to a WAV file:
% Saved file name
output_name = 'filtered.wav';
fs = 16000;
% Assuming 'FilteredAudio' is the audioplayer object
audio_data = getaudiodata(FilteredAudio); % Extract audio data
audiowrite(output_name, audio_data, fs); % Save audio data to file
  1 Kommentar
Joseph Patrick
Joseph Patrick am 27 Okt. 2023
Doesn't getaudiodata only work for type audiorecorder? My value is of type audioplayer, not audiorecorder.
Also getaudiodata shows up as an unrecognized function for my matlab

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by