Error Using audioread : Expected input number 2, range, to be positive.
Show older comments
I'm trying to read a portion of an audio file, and matlab's returning the error consistently on the same line.
It used to work, but I'm not entirely sure what I changed to make this occur.
The code for reproduction is below. I'm doing this in a app where the user inputs a start and end time (i.e. 0:00 and 1:00) the program then converts that into seconds for the samples and calls audioread. app.path1 is the path to the audio file.
sng1 = app.StartofComparisonEditField.Value;
startSongOne = times(str2num(sng1(1)), 60);
startSongOne = startSongOne + times(str2num(sng1(3)), 10);
startSongOne = startSongOne + str2num(sng1(4));
sng1 = app.EndofComparisonEditField.Value;
endSongOne = times(str2num(sng1(1)), 60);
endSongOne = endSongOne + times(str2num(sng1(3)), 10);
endSongOne = endSongOne + str2num(sng1(4));
Fs = 44100;
samplesSongOne = [startSongOne,endSongOne * Fs];
clear Fs;
[y, Fs] = audioread(app.path1, samplesSongOne);
Many Thanks.
Accepted Answer
More Answers (0)
Categories
Find more on Audio I/O and Waveform Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!