So this question is more related to Matlab itself.

Some background info: I'm trying out the Exponential Sine Sweep method to obtain the Room Impulse Response with my laptop speakers and microphone for testing.

I can generate the Sine sweep perfectly but I have trouble playing and recording it without a lot of lag. I'm now trying to use "audioPlayerRecorder" from the Audio System Toolbox but when I do:

f1 = 80;       % Start frequency (Hz)
f2 = 22000;    % Stop frequency (Hz)
T = 3;         % Sweep duration in seconds
fs = 44100;    % Sampling frequency

[sweep, inverse] = ESS_generator(f1, f2, T, fs);

playRec = audioPlayerRecorder(fs);
recording = playRec(sweep);

I get an error on the last line saying: Error using coder.internal.assert (line 33) No full-duplex audio device detected

But I know that my laptop is able to use the microphone and speakers simultaneously so I'm thinking maybe the error gets thrown because of a missing configuration?

I'm running the code on Linux with the ALSA audio drivers. I'm using external speakers through the AUX audio port, and the default laptop microphone.

  • 1
    $\begingroup$ I don't know if Matlab is capable of doing that. What I have done in the past is to use Matlab to play the sound, while another process (sox in my case) does the recording. $\endgroup$
    – MBaz
    Feb 14, 2019 at 17:20
  • $\begingroup$ May be simulink could do that (simultaneous playback and recording)? have you checked its documentation as well ? $\endgroup$
    – Fat32
    Feb 15, 2019 at 23:17
  • $\begingroup$ @MBaz , How 'real-time' is this method? Since I assume you have a delay between the playing the audio using matlab and starting the recording. $\endgroup$ Feb 17, 2019 at 13:18
  • $\begingroup$ @Fat32, I'll check this out. Thanks! $\endgroup$ Feb 17, 2019 at 13:18
  • $\begingroup$ @Mistergrave It is real time in the sense that both streams are playing at the specified sampling rate. There is of course a delay, but that is unrelated to the system being 'real time". See this paper for more details: ieeexplore.ieee.org/document/5739249 $\endgroup$
    – MBaz
    Feb 17, 2019 at 17:13

2 Answers 2


I suspect that your problem is to do with having your speakers and microphone on different ALSA audio devices or subdevices.

You need to find the available sound cards for recording and playback on your system. The following commands will tell you this information :

aplay -l
arecord -l

You will need to define a default full duplex sound card using your choice of devices you see in the output to the above commands.

The way to define this full duplex card (made of two different soundcard devices) is to define it in your ~/.asoundrc file. This example shows you how to do that, however I will repeat it here.

The requirement is that you use plughw as your device name because the clocks on the two sound cards will drift and you will need resampling of some form. But you can play with this option.

So for example if you want to take input from a device on the first card (hw:0) and output to the second device on the second card (hw:1,1) then you would write the following in your ~/.asoundrc file :

pcm.!default {
    type asym
    playback.pcm "plughw:1,1"
    capture.pcm  "plughw:0"
ctl.!default {
        type hw
        card 1

Hopefully now Matlab sees a full duplex card as the default device and allows full duplex operation.


read doc of audioPlayerRecorder "Supported drivers for audioPlayerRecorder are platform-specific: Windows® –– ASIO™ Mac –– CoreAudio Linux® –– ALSA"

which means u need to install ASIO driver. In my case, a usb microphone is also needed, because RealTek Soundcard seems cannot enable full Duplex Mode.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.