How to use/work with a Signal recorded with function "audiorecorder" instead of inserting a .wav file?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Satyam
am 25 Apr. 2025
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 Kommentare
Siehe auch
Kategorien
Mehr zu Audio Plugin Creation and Hosting finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!