Creating an array that contains recordblockings
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello, first of all I'm new to matlab. What's the syntaxis to create an array that can store audio recordblockings and then create a file at each iteration with a different name. This is my code:
audios = ; % What do I put here so that it stores recordingblocks
Recording = audiorecorder;
for i = 1:3
disp('Recording ...')
recordblocking(Recording , 1);
disp('End of recording')
audio = getaudiodata(Recording );
sound(audio);
audios(i) = audio;
audiowrite('output0001.wav' , audios(i), 8000);
end
end
댓글 수: 0
답변 (1개)
Geoff Hayes
2015년 2월 22일
Andrés - even though each iteration records only one second of audio data, it may be that each recording is of a different length (i.e. the audio array). In that case, your audios variable could be a cell array which will allow you to contain arrays of different lengths. Initialize it as
audios = cell(3,1);
and then initialize the kth element as
audios{k} = audio;
(I use k as the iterator since MATLAB treats i and j as representations for the imaginary number.)
To write each audio block to a different file, just do the following
filename = sprintf('output%04d.wav',k);
which will create file names such as
output0001.wav
output0002.wav
output0003.wav
etc.
Then write to file as
audiowrite(filename,audios{k},8000);
Try integrating the above into your code and see what happens.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio and Video Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!