필터 지우기
필터 지우기

Can audioPlayerRecorder system object input stereo audio?

조회 수: 2 (최근 30일)
Gene Goff
Gene Goff 2018년 9월 4일
답변: JIAHUI LIAO 2021년 9월 15일
Can the audioPlayerRecorder system object input stereo audio? I know it can output stereo audio, but looking at the diagrams and code examples for the audioPlayerRecorder system object it appears it can only input one channel at a time. Testing my code, when I output stereo audio, audioPlayerRecorder still only inputs a one-channel vector.

답변 (3개)

Astha Singh
Astha Singh 2018년 9월 11일
Essentially, once you have created an audioPlayerRecorder System Object (here ‘playRec’)
playRec = audioPlayerRecorder
the audio signal read from the device (‘audioFromDevice’) depends on size and data type of the data being written (‘audioToDevice’) to the audio device selected
audioFromDevice = playRec(audioToDevice)
Thus if you are sending a two channel stereo audio data to be played, a two-channel audio data only will be read through the sound card.

Gene Goff
Gene Goff 2018년 9월 13일
Thank you, but this is incorrect. The Matlab test file attached demonstrates that the audioFromDevice is always mono (one channel) regardless if the audioToDevice is mono or stereo (two channel). Please provide a remedy for this problem because I need to output and input stereo audio simultaneously. The audioDeviceReader and audioDeviceWriter objects cannot be used simultaneously and therefore is not a solution. Thank you for your help.
clc fprintf('Working....\n')
frameLength = 2048; Fs = 44100; osc = audioOscillator('SignalType','sine','Frequency',400,'SamplesPerFrame',frameLength,'SampleRate',Fs);
% instantiate the audioPlayerRecorder object with your particular sound card here playRecObj = audioPlayerRecorder('SampleRate',Fs,'Device','US-2x2 & US-4x4','BitDepth','32-bit float');
frameCtr = 1; tic; while toc < 2 % play for 2 seconds monoSinewave = 0.1 * osc(); stereoSinewave = [monoSinewave monoSinewave]; audioToDevice = stereoSinewave;
audioFromDevice = playRecObj(audioToDevice);
% display in the command window the number of output and input channels
if frameCtr==1
audioToDeviceSize = size(audioToDevice)
audioFromDeviceSize = size(audioFromDevice)
end
frameCtr = frameCtr + 1;
end
release(audioFileReaderObj); release(audioFileWriterObj); release(playRecObj); fprintf('Done!.\n')

JIAHUI LIAO
JIAHUI LIAO 2021년 9월 15일
You can try like this
aPR = audioPlayerRecorder('SampleRate',fs);
aPR.RecorderChannelMapping = 1:2;

카테고리

Help CenterFile Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by