https://ch.mathworks.com/help/audio/ref/audioplayerrecorder-system-object.html
audioPlayerRecorder - Simultaneously play and record using an audio device - MATLAB
The audioPlayerRecorder System object reads and writes audio samples using your computer's audio device.
play andaudio devicesimultaneouslyrecordusing