我想做一個播放器,做好之後又想加一些新的功能,於是有了這個錄音器。本來想把他們兩個放在一個界面同時運行,這樣就可以在播放的同時進行錄音,但是可能code上有一些地方沒有銜接上,所以放在一起后動畫導不進去/(ㄒ^ㄒ)/~~所以那我們就分開使用好了qwq。。。
I want to do a player,then I make it but want to add some new features so I have this recorder. Originally wanted to put both of them on an interface at the same time, so that you can record while playing, but there may be some places on the code that are not connected, so after the animation is put together, the animation guide will not put in/(ㄒ^ㄒ)/~~, so we will use it separately. All right . . .qwq
Initial value
function SoundRecorderDemo_OpeningFcn(hObject, eventdata, handles, varargin)SoundRecorderDemohandles.output = hObject;handles.recObj = audiorecorder(48000, 16, 2,-1);handles.recObj.TimerFcn={@RecDisplay,handles};handles.recObj.TimerPeriod=0.25;handles.playSpeed=1;% Update handles structureguidata(hObject, handles);Button
function pushbutton1_Callback(hObject, eventdata, handles)function pushbutton1_Callback(hObject, eventdata, handles)record(handles.recObj);function pushbutton2_Callback(hObject, eventdata, handles)stop(handles.recObj)function pushbutton3_Callback(hObject, eventdata, handles)handles.myRecording = getaudiodata(handles.recObj);handles.playObj = audioplayer(handles.myRecording,handles.playSpeed*handles.recObj.SampleRate);play(handles.playObj);guidata(hObject, handles);function pushbutton4_Callback(hObject, eventdata, handles)[file,path] = uiputfile(['soundDemo_Speed' num2str(handles.playSpeed) '.wav'],'Save recorded sound');if file audiowrite([path '\' file],handles.myRecording,handles.playSpeed*handles.recObj.SampleRate)endPlay recorder
function RecDisplay(hObject, eventdata,handles)handles.myRecording = getaudiodata(handles.recObj);plot(handles.axes1,(1:length(handles.myRecording))/handles.recObj.SampleRate,handles.myRecording)drawnow;Callback
function edit1_Callback(hObject, eventdata, handles)handles.playSpeed=str2double(get(hObject,'String'));guidata(hObject,handles)function edit1_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');endInitial value
function playMTV_OpeningFcn(hObject, eventdata, handles, varargin)pos = [0 0 0 0];MovieControl = actxcontrol('WMPlayer.OCX.7',pos);handles.MovieControl = MovieControl;mp = handles.MovieControl.controls;handles.output = mp;guidata(hObject,handles);Resize
function figure1_ResizeFcn(hObject, eventdata, handles) units = get(handles.figure1,'units'); set(handles.figure1,'units','pixels');pos = get(handles.figure1,'position');set(handles.figure1,'units',units);pos = [0 0 pos(3:4)];move(handles.MovieControl,pos);Read file
function Untitled_2_Callback(hObject, eventdata, handles)[filename pathname] = uigetfile('*.*','请选择一个视频文件');if ~filename returnend;handles.MovieControl.URL=[pathname filename];handles.MovieControl.controls.play;