Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I'm trying to read a wave file by a push button ,play it with otherones, and save as it with another push button with a new name, how can I do that?

I do this code but have get Error!

C++
% --- Executes on button press in Openb.
function Openb_Callback(hObject, eventdata, handles)
% hObject    handle to Openb (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


global filename pathname y fs nbits;
[filename, pathname]=uigetfile('*.wav', 'Select a wave file');
[handles.y, fs, nbits] = wavread(fullfile(pathname, filename));


% --- Executes on button press in Saveb.
function Saveb_Callback(hObject, eventdata, handles)
% hObject    handle to Saveb (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global filename pathname y fs nbits;
[filename pathname]=uiputfile('*.wave', 'Choose a name to save file');
wavwrtie(y,fs,nbits,'*.wav');

% --- Executes on button press in Playb.
function Playb_Callback(hObject, eventdata, handles)
% hObject    handle to Playb (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global filename pathname y fs nbits;

p=audioplayer(y,fs);
play(p, [START STOP]);
Posted
Updated 3-Dec-14 3:05am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900