I am trying to record voice and then play it from the time index provided by the user. The problem is this code is not playing the recorded voice and gives "Invalid Playback Selection" error. What am I doing wrong? Here is the code:
function musiceditor(UserPassedTimeIndex)
Fs=44110;
y = wavrecord(5*Fs,Fs,'int16');
wavwrite(y,'Alfred.wav');
[Magnitude,SampleRate,x]=wavread('Alfred.wav');
AudioPlayer=audioplayer(Magnitude,SampleRate,x);
TotalPlayTime= length(Magnitude)/SampleRate;
Index= round((UserPassedTimeIndex/TotalPlayTime)*length(Magnitude));
play(AudioPlayer,Index);
Regards