Problems using the function audiowrite

17 ビュー (過去 30 日間)
ignacio
ignacio 2015 年 11 月 13 日
コメント済み: ignacio 2015 年 11 月 20 日
Hello, I'm working with Matlab R2014b and trying to create a wav file. I tried two posibilities:
- wavwrite(int32(signal),Fs,24,['test2.wav'])
- audiowrite(['test.wav'],int32(signal),Fs,'BitsPerSample',24)
But when I try to heard both files, I can only heard the first one created with the old function wavwrite.
In both case is the same signal.
any help?

採用された回答

Nick Haddad
Nick Haddad 2015 年 11 月 13 日
There is one subtle difference between writing 24-bit audio with audiowrite vs. wavwrite.
When writing int32 as 24-bit audio in wavwrite, the data range in y is interpreted as:
2^23 y ≤ 2^23–1
When writing an int32 as 24-bit audio in audiowrite, the data range in y is interpreted as:
-2^32 y ≤ 2^32–1
So your data is still being written but slightly quieter. If your 'signal' variable is in the 24-bit range you will need to rescale it to the 32-bit range to get the same results as using wavwrite. If 'signal' is just a normalized double (-1 ≤ y ≤ 1), the you can simply supply the double value and audiowrite will scale it for you properly:
audiowrite(['test.wav'],signal,Fs,'BitsPerSample',24)
  1 件のコメント
ignacio
ignacio 2015 年 11 月 20 日
Thanks Nick, the code works perfectly ;)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio I/O and Waveform Generation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by