가 같은데 ... 내가 지금까지 가지고있는 코드 ...
녹화 버튼 ...
function recordbutton_Callback(hObject, eventdata, handles)
% hObject handle to recordbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
rec = audiorecorder
disp('Recording for 5 Seconds...')
recordblocking (rec,5); %5 Seconds
disp('Finished Recording.')
global myrecording
myrecording = getaudiodata(rec);
axes(handles.axes3);
plot(myrecording)
저장 버튼입니다. 글로벌 변수를 사용하는 대신 guidata를 사용하는 것이 가장 좋습니다. mathworks Q&A here.
둘째로 당신의 audiowrite 코드는 audiowrite(filename,y,Fs)
는 파일 이름, 소리, 다음 입력으로 주파수 소요, 매스 웍스 help here에서 다른 방식으로 (적어도 내 시스템에)이라고합니다.
코드를 약간 변경했지만 두 개의 버튼이있는 wav 파일이 기록됩니다.
function recordbutton_Callback(hObject, eventdata, handles)
rec = audiorecorder
disp('Recording for 5 Seconds...')
recordblocking (rec,5); %5 Seconds
disp('Finished Recording.')
handles.myrecording = getaudiodata(rec);
guidata(hObject, handles); %writes the handles structure back to the guiframe.
귀하의 저장 기능
다시에서 guidata를 작성할 필요가 없습니다이
function Save_Callback(hObject, eventdata, handles)
% hObject handle to Save (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.myrecording % check to make sure handles.myrecording actually has data
audiowrite('RecordedSound.wav',handles.myrecording, 44100);
같이 작성해야 메모리를 확보하기 위해 녹화를 삭제하지 않으려면, 저장합니다.
무엇이 문제입니까? 코드가 작동하지 않습니까? 불완전한가요? – zhqiat
'저장'버튼을 누르면 녹음 된 오디오가 .wav 파일로 저장됩니다. 그러나 이것은 일어나지 않습니다. –
* *는 어떻게됩니까? 빈 .wav 파일을 가져 옵니까? 콜백이 전혀 호출되지 않았습니까? 'myrecording'에는 디버깅 중에 검사 할 때 그 시점에 생각하는 데이터가 포함되어 있습니까? 디버그 콘솔에서'audiowrite' 명령을 사용하여 의도 한대로 동작하는지 확인해 보셨습니까? –