How can I simultaneously play and record from the same audio device?

13 views (last 30 days)
Hi guys,
I am trying to do a super simple operation of playing the signal and recording it at the same time through my RME audio interface. I have the DSP toolbox so I wanted to use the audioPlayerRecorder object to do that however my output is just a bunch of zeros with couple of non-zero values at the very end of the vector. I have been trying to figure out what would seem to be super simple operation for couple of days now and I just cannot figure it out. Please, any advice would be a lifesaver! My code so far is below
clear all
close all
internaldata.driver = 'ASIO';
internaldata.audio_device = 'ASIO Fireface USB';
internaldata.framesize = 30*2^13;
internaldata.samplerate = 48000;
internaldata.tfe_FFTLength = 512;
internaldata.spectral_averages = 1;
internaldata.input_channel_map = 5;
internaldata.output_channel_map = 5;
internaldata.deviceReader = audioDeviceReader('Driver',internaldata.driver,'SampleRate',internaldata.samplerate,...
internaldata.deviceWriter = audioDeviceWriter('Driver',internaldata.driver,'SampleRate',internaldata.samplerate,...
input = step(dsp.ColoredNoise('Color','pink','SamplesPerFrame',internaldata.framesize,'NumChannels',1));
aPR = audioPlayerRecorder('SampleRate',internaldata.samplerate,'PlayerChannelMapping',internaldata.output_channel_map,...
subplot 211
subplot 212

Answers (1)

Sharan Paramasivam Murugesan
1. Is your audio device capable of simultaneous playback and recording (Full duplex sound card)?
2. Following is an example on how to perform simultaneous playback and recording:
Please take a look at the above example - especially the frame based loop. If you want to specify channel mapping manually, the section on "Specify non-default channel mapping" might help.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by