Hi guys, For my project I need to play a wav file from my speaker and while it's playing I want to record it with a microphone simultaneously. I'm using the audioPlayerRecorder which I believe is what I need to use. This is what I've done so far, however I'm not quite sure if its correct.
clear allclcfilereader=dsp.AudioFileReader('chirp_2.wav'); % this is the wav file saved in my Computer
fs=filereader.SampleRate;filewriter= audioDeviceWriter(fs);apr=audioPlayerRecorder('SampleRate',fs);while ~isDone(filereader) audioToPlay = filereader(); audioRecorded = apr(audioToPlay); filewriter(audioToPlay); end release(apr);release(filewriter);release(filereader); mic1=getaudiodata(apr);mic2=getaudiodata(filewriter);
When I run this, it runs fine so I'm assuming that both speaker and microphone are working synchronously?
My issue is, I want to plot both the audio from speaker and the recorded audio. I'm trying to convert the object to a numerical array through the getaudiodata function however having I get an error saying "Unrecognized function or variable getaudiodata()".
Does anyone know how to plot both the speaker and microphone audio?
Best Answer