I'm using GUI matlab, I'm recording wav sound and save it in specific folder. When I press the play button an error occurs, the error is: The filename specified was not found in the MATLAB path. That's a small part of the recording button:
name=strcat(year,'-',month,'-',day,'-',hour,'-',min,'-',sec);
fullpath=fullfile('c:\monitoringsystem',name);
wavwrite(y,44100,fullpath);
y=[];
The play code:
allstrings = cellstr( get(handles.listbox1, 'String') );
curvalue = get(handles.listbox1, 'Value');
thisstring = allstrings{curvalue};
[q, Fs] = audioread(thisstring);
soundsc(q,44100);
How to solve this problem, with keeping to save the sound in a specific folder.
To read an audio file which is not in the MatLab path with "audioread" you have to specify the full file path.
In the code you posted it is not clear how you build the sound list and how it is assigned to the listbox.
Nevrtheless, a possible solution could be the following: you might create a (N x 2) cellarray in whch you store, for each song, the filename and its path.
You can assign to the listbox only the filename, then you can use the index of the item selected in the list box to also access to the cell containing the path. Then, you have just to build the full file name (including the path) to be used in the call to
audioread
.The imlementation of this solution depends on how you manages the list of sound.
To test this solution I've build a small GUI: I've manually created a list of song and their path in the "
listbox1_CreateFcn
" and build up the full file name in thepushbutton1_Callback
as follows (I've usedguidata
to manage the soud list within the GUI):Hope this helps.