How to use/work with a Signal recorded with function "audiorecorder" instead of inserting a .wav file?
2 次查看(过去 30 天)
显示 更早的评论
How I have been taught to insert signals, -and find the corresponding time-
% Input Signal
[b,Fs] = audioread('Recording1.wav');
[M,N]=size(b); %size signal
time=(0:M-1)/Fs; %insert time
This I can work with
In my new project, however, I have to record while the program runs. Instead of inserting a prerecorded .wav file
Like this:
Fs=8000;
a=audiorecorder(Fs,16,2);
%record with sample rate 8000Hz, bits/symbol 16, and in 2 channels
disp('Please speak');
%display message on command window
recordblocking(a,4);
%record as a implores for 4 secs
disp('end of Recording');
%display message on command window
I noted that b is -in this case- displayed on my workspace as "209919x1 double" while my recorded signal is displayed as "1x1 audiorecord".
Additionally using function "play (a);" sucesfully reproduces my recorded signal, while "play (b);" pops the error:
"Check for missing argument or incorrect argument data type in call to function 'play'."
I understand those occur beacuse the two methods save the signal in different ways.
How do I get my recorded signal a to be saved/converted as b is, and vice versa?
0 个评论
回答(1 个)
Satyam
2025-4-25
Hi Panagiotis,
You can utilize 'getaudiodata' method of the 'audiorecorder' object in order to access the recorded signal data. You can refer to the following documentation to learn more about the syntax of 'getaudiodata' function: https://www.mathworks.com/help/matlab/ref/audiorecorder.getaudiodata.html
However, the 'audiorecorder' object in MATLAB is designed for recording audio from an input device (like a microphone). It does not have a way to load existing audio data into it.
Here is a modified code snippet depicting the usage of 'getaudiodata':
Fs=8000;
a=audiorecorder(Fs,16,2);
%record with sample rate 8000Hz, bits/symbol 16, and in 2 channels
disp('Please speak');
%display message on command window
recordblocking(a,4);
%record as a implores for 4 secs
disp('end of Recording');
%display message on command window
audiodata=getaudiodata(a);
The recorded audio signal gets saved in the variable 'audiodata'.
I hope this addresses your issue.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio Plugin Creation and Hosting 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!