フィルターのクリア

How to audiowrite a soundfile from m4a to wav?

27 ビュー (過去 30 日間)
Laura Sels
Laura Sels 2016 年 7 月 5 日
コメント済み: Geoff Hayes 2016 年 7 月 7 日
Hello!
I want to write an audiofile from m4a to wav? I thought it was easy, but I miss something I guess..
This is what I'm doing:
load hoi.m4a
filename='hoi.wav'
audiowrite(filename, y, Fs)
This is what the help function says, but what am I supposed to fill in on y and Fs?
Thanks!

採用された回答

Geoff Hayes
Geoff Hayes 2016 年 7 月 5 日
Laura - I think that you want to use audioread first as
m4AFilename = 'hoi.m4a';
[y,Fs] = audioread(m4AFilename);
and then write it as a wav file using audiowrite as
wavFilename = 'hoi.wav';
audio write(wavFilename,y,Fs);
Try the above and see what happens!
  3 件のコメント
Laura Sels
Laura Sels 2016 年 7 月 7 日
編集済み: Geoff Hayes 2016 年 7 月 7 日
Now I want to audiowrite and save not from a m4a or wav file but from a recorded file in matlab. How can I do that, because this does not work..
% record some speech (chien):
r= audiorecorder;
disp('Start speaking.')
recordblocking(r, 5);
disp('End of Recording.');
% Play back the recording.
play(r);
% Store data in double-precision array.
myRecording = getaudiodata(r);
% write the recording in a wav file
filename='chien.wav';
audiowrite(filename, y, Fs);
[y, Fs] = audioread(filename);
Geoff Hayes
Geoff Hayes 2016 年 7 月 7 日
Laura - presumably it isn't working because you haven't defined the y and Fs and so the line
audiowrite(filename, y, Fs);
fails. Is that correct? If so, then you need to define them
y = getaudiodata(r);
Fs = get(r,'SampleRate');

サインインしてコメントする。

その他の回答 (1 件)

Thorsten
Thorsten 2016 年 7 月 5 日
Use audioread to read the m4a. audioread returns y and Fs, and you can pass these to audio write:
[y, Fs] = audioread('hoi.m4a');
audiowrite('hoi.wav', y, Fs)
  1 件のコメント
Laura Sels
Laura Sels 2016 年 7 月 6 日
Thank you! I forgot the audioread! And I had a not working soundfile but now it works!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by