Reading audio file using GUI pushbutton and saving them to a folder

3 ビュー (過去 30 日間)
abidalkareem
abidalkareem 2016 年 4 月 30 日
編集済み: CS Researcher 2016 年 4 月 30 日
Hi everyone,
I'm trying to read multiple audio files using a simple GUI pushbutton, and saving the selected files into a folder for later processing, I hope you can help me how to achieve that.
This is my current code, I know its messy
[filename, Ttrain]=uigetfile('*.wav', 'Select a wave file');
if isequal(filename,0) || isequal(filename,0)
return % or whatever other action if 'CANCEL'
else
nwavfile=fullfile(Ttrain, filename);
wavwrite(i,fs,nbits,nwavfile);
end
cd(Ttrain);
rawdata1=load([Ttrain filename]);
guidata(hObject, handles);

回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 4 月 30 日
You should not be using wavwrite(), that is for writing files. You need to read the data and save() it .
Or you should consider just copyfile() to the destination folder.

CS Researcher
CS Researcher 2016 年 4 月 30 日
編集済み: CS Researcher 2016 年 4 月 30 日
You can start with this and then continue:
[filename, pathname] = uigetfile('*.wav', 'Select a wave file','MultiSelect','on');
% Check if the user selected one file or multiple
if iscell(filename)
nfiles = length(filename);
nwavfile = cell(1,nfiles);
for i = 1:nfiles
nwavfile{1,i} = fullfile(pathname, filesep, filename{1,i});
%Enter the command to save nwavfile{1,i} here
end
else
nwavfile{1,1} = fullfile(pathname, filesep, filename);
%Enter the command to save nwavfile here
end
handles.nwavfile = nwavfile;
guidata(hObject, handles);

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by