Error using wavread on only a file?

1 visualizzazione (ultimi 30 giorni)
I Made
I Made il 28 Giu 2013
So here is my code & problem:
ButtonA
function pushbutton5_Callback(hObject, eventdata, handles)
[fileName,filePath]=uigetfile({'.wav'},'File Selector');
name = fullfile(filePath,fileName);
handles.fileName=name;
guidata(hObject,handles);
Button B
function pushbutton8_Callback(hObject, eventdata, handles)
File=handles.fileName;
[data, Fs, nbits] = wavread(File);
The error : only errror if i input a processed file. other files are fine
??? Error using ==> wavread at 166 Invalid field name: ''.
Error in ==> attack>pushbutton8_Callback at 338 [data, Fs, nbits] = wavread(File);
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> attack at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)attack('pushbutton8_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
What is strange here is this code is work for all my file except 1, which is a file that i've been doing some process in it actually it is watermarking. So what i wanted to know is why is this happening ? what specification for a file can be read using wavread?
And 1 thing come on my mind that the only different that the error file than the other have was before the data header.. take a look at this pict, could it be the problem?
before i process .wav file (can be read)
after i process.wav file (can't be read)
%

Risposte (1)

Jan
Jan il 28 Giu 2013
Modificato: Jan il 28 Giu 2013
You do not define the variable File at all in:
function pushbutton8_Callback(hObject, eventdata, handles)
[data, Fs, nbits] = wavread(File);
Therefore I'm surprised about the error message. Actually File should be undefined and not the empty string.
This callback has to obtain the file name from where it is stored:
function pushbutton8_Callback(hObject, eventdata, handles)
handles = guidata(hObject); % Is this required to get the newest version?
[data, Fs, nbits] = wavread(handles.fileName);
  1 Commento
I Made
I Made il 28 Giu 2013
i'm very sorry i write the code wrong.. i'm already edit it..
First time i use to write my code like you.. But same result it's not working for this 1 file.. Another file works just fine

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by