audioread() returns wrong data for integer range

17 visualizzazioni (ultimi 30 giorni)
John Wygonski
John Wygonski il 19 Feb 2015
Commentato: David Heise il 17 Dic 2020
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 Commenti
Walter Roberson
Walter Roberson il 17 Dic 2020
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 il 17 Dic 2020
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.

Accedi per commentare.

Risposte (1)

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

Categorie

Scopri di più su Audio I/O and Waveform Generation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by