sotomie
Newbie level 6
- Joined
- Apr 5, 2013
- Messages
- 13
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,376
i'm getting this error
??? Error using ==> wavread
Cannot open file.
Error in ==> wav_to_audio at 108
[f_audio,fs,nbits] = wavread(strcat(dirAbs,dirRel,wavfilename));
Error in ==> Untitled at 5
[f_audio,sideinfo] = wav_to_audio('C:\Users\S.M.Jamil Akhter\Desktop\MATLAB-Chroma-Toolbox_2.0\data_WAV', 'data_WAV/', filename);
can someone plz tell me how to correct it?
??? Error using ==> wavread
Cannot open file.
Error in ==> wav_to_audio at 108
[f_audio,fs,nbits] = wavread(strcat(dirAbs,dirRel,wavfilename));
Error in ==> Untitled at 5
[f_audio,sideinfo] = wav_to_audio('C:\Users\S.M.Jamil Akhter\Desktop\MATLAB-Chroma-Toolbox_2.0\data_WAV', 'data_WAV/', filename);
can someone plz tell me how to correct it?
Code:
clear
close all
filename = 'abc.wav';
[f_audio,sideinfo] = wav_to_audio('C:\Users\sotomie\Desktop\MATLAB-Chroma-Toolbox_2.0\data_WAV\abc.wav', 'data_WAV/abc.wav', filename);
shiftFB = estimateTuning(f_audio);
paramPitch.winLenSTMSP = 4410;
paramPitch.shiftFB = shiftFB;
paramPitch.visualize = 1;
[f_pitch,sideinfo] = ...
audio_to_pitch_via_FB(f_audio,paramPitch,sideinfo);
paramCP.applyLogCompr = 0;...
Code:
function [f_audio,sideinfo] = wav_to_audio(dirAbs,dirRel,wavfilename,parameter)
if nargin<4
parameter=[];
end
if nargin<3
error('Please specify at least the path and filename of the wav file')
end
if isfield(parameter,'useResampling')==0
parameter.useResampling = 1;
end
if isfield(parameter,'destSamplerate')==0
parameter.destSamplerate = 22050;
end
if isfield(parameter,'convertToMono')==0
parameter.convertToMono = 1;
end
if isfield(parameter,'monoConvertMode')==0
parameter.monoConvertMode = 'downmix';
end
if isfield(parameter,'message')==0
parameter.message = 0;
end
if isfield(parameter,'vis')==0
parameter.vis = 0;
end
if isfield(parameter,'save')==0
parameter.save = 0;
end
if isfield(parameter,'saveDir')==0
parameter.saveDir = [dirAbs,dirRel];
end
if isfield(parameter,'saveFilename')==0
parameter.saveFilename = wavfilename;
end
if parameter.message == 1
fprintf('wav_to_audio: processing %s, ',wavfilename);
end
[pathstr,name,ext] = fileparts(wavfilename);
if strcmp(ext,'.wav')
[f_audio,fs,nbits] = wavread(strcat(dirAbs,dirRel,wavfilename));
else
error(['Unknown file format ' ext]);
end
bConverted_to_mono = 0;
if parameter.convertToMono
if size(f_audio,2)>1
bConverted_to_mono = 1;
if parameter.message == 1
fprintf('converting to mono, ');
end
switch parameter.monoConvertMode
case 'leftmost_channel'
f_audio= f_audio(:,1);
case 'rightmost_channel'
f_audio= f_audio(:,size(f_audio,2));
case 'downmix'
% pay attention to energy loss due to differences in phase
% when using this method. This is often the case for bad
% stereo mixes
nChannels = size(f_audio,2);
f_audio = sum(f_audio,2);
f_audio = f_audio / nChannels;
otherwise
disp('wav_to_audio: monoConvertMode : Unknown method')
end
end
end
bResampled = 0;
if parameter.useResampling
if (fs ~= parameter.destSamplerate)
bResampled = 1;
if parameter.message == 1
fprintf('Resampling to %d, ', parameter.destSamplerate);
end
f_audio = resample (f_audio,parameter.destSamplerate,fs,100);
fs = parameter.destSamplerate;
end
end
sideinfo.wav.version = 1;
sideinfo.wav.filename = wavfilename;
sideinfo.wav.dirRel = dirRel;
sideinfo.wav.size = size(f_audio,1);
sideinfo.wav.duration = (sideinfo.wav.size-1)/fs;
sideinfo.wav.energy = sum(f_audio.^2);
sideinfo.wav.fs = fs;
sideinfo.wav.nbits = nbits;
sideinfo.wav.channels = size(f_audio,2);
sideinfo.wav.resampled = bResampled;
sideinfo.wav.monoConverted = bConverted_to_mono;
if bConverted_to_mono
sideinfo.wav.monoConvertMode = parameter.monoConvertMode;
else
sideinfo.wav.monoConvertMode = 'none';
end
if parameter.save == 1
if parameter.message == 1
fprintf('Saving to file, ');
end
filename = strcat(parameter.saveFilename,'_audio');
save(strcat(parameter.saveDir,filename),'f_audio','sideinfo');
end
if parameter.message == 1
fprintf('Done\n');
end
if parameter.vis
figure;
for k=1:sideinfo.wav.channels
if sideinfo.wav.channels > 1
subplot(sideinfo.wav.channels,1,k);
end
plot( [0:sideinfo.wav.size-1] / sideinfo.wav.fs , f_audio(:,k));
axis tight;
end
end
end