audioread() returns wrong data for integer range

17 ビュー (過去 30 日間)
John Wygonski
John Wygonski 2015 年 2 月 19 日
コメント済み: David Heise 2020 年 12 月 17 日
In the following code, audioread() returns wrong data but wavread() returns correct data from a wav file if the range parameters [start, finish] are int32 type. If the range parameters are type double, both audioread() and wavread() return correct data.
Is this expected behavior or a bug or my misunderstanding?
%audioread() reads from start=1 for range that is integer; wavread() correctly returns data starting at 'start'
start = int32(42016);
finish = int32(44440);
%start = 42016;
%finish = 44440;
wavpath = '.\test.wav';
clear arResult Fsar wrResult Fswr;
[arResult, Fsar] = audioread(wavpath, [start, finish ], 'native');
[wrResult, Fswr] = wavread(wavpath, [start, finish ], 'native');
  5 件のコメント
Walter Roberson
Walter Roberson 2020 年 12 月 17 日
i did some digging into the code, but unfortunately going further would require testing with a large .wav and I do not happen to have one large enough sitting around.
David Heise
David Heise 2020 年 12 月 17 日
In implementing my "workaround", I noticed a similar error (at the change to scientific notation) when using the calculated sample numbers as indices to access a portion of the entire signal. I was eventually able to get around that issue by explicitly converting the calculated indices to an int (I used uint64) and then *back to a double* since some of the Audio Toolbox functions - in this case, pitch() - expect doubles as input parameters.
It is odd to me that the Audio Toolbox functions - or, for that matter, audioread() - would expect doubles as the type to specify what must be an integer index, but maybe it's done that way since most of the time we rely on the default data type...
In any case, a bit later I'll see if a similar strategy can be used to avoid the aforementioned error with audioread(), and I'll post a code example for the benefit of others running into this particular issue.

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

回答 (1 件)

Antara Ganesh Kolar
Antara Ganesh Kolar 2016 年 11 月 23 日
Hey, Did you resolve this error? Even I am getting the same error. I am using R2016a on Windows.

カテゴリ

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