MATLAB: Play a sound at certain frequency and recording it simultaneously

audiorecorderfrequency

Hello,
I am a novice and I need your help
The code below helps me to generate a sound at certain frequency for a certain duration, how to I record simultaneously and write it
to a file?
Fs = 44100; % Samples per second. 48000 is also a good choice
toneFreq = 22000; % Tone frequency, in Hertz. must be less than .5 * Fs.
nSeconds = 10; % Duration of the sound
a = sin(linspace(0, nSeconds*toneFreq*2*pi, round(nSeconds*Fs)));
sound(a,Fs); % Play sound at sampling rate Fs

Best Answer

To simultaneously play and record:
  1. Create the audioPlayerRecorder object and set its properties.
  2. Call the object with arguments, as if it were a function.
For more information, see:
Related Question