Recognizing 8 audio channels not stereo
5 ビュー (過去 30 日間)
古いコメントを表示
setpref('dsp', 'portaudioHostApi', 3)
[audioData, Fs] = audioread('speech.wav');
ad = audiodevinfo;
deviceID = audiodevinfo(0,ad.output(2).Name); % select audio device
channelmapping = zeros(size(audioData,1),8);
channelmapping(:,1) = audioData(:,1); % audio data with selected channels of devices
p = audioplayer(channelmapping,Fs,8, deviceID);
play(p)
Dear community,
I want to select 1 channel to play audio data among 8 channels of devices.
However, Matlab does recognize stereo instead of 8 channels.
Could you help me fixing my code?
Thank you.
0 件のコメント
回答 (1 件)
Paras Gupta
2023 年 10 月 18 日
Hi Jihyun,
I understand that you want to select and play one channel's audio data from an 8 channel audio file. MATLAB's 'audiplayer' function only supports mono (one-channel) and stereo (two-channel) audio data, and thus it cannot play 8 channela audio.
The error in the code provided is that the variable 'channelmapping' is created with 8 columns which is equivalent to 8 channles, even though only one column contains audio data and the remaining columns contain zeros.
You can refer the following code to achieve the desired results:
setpref('dsp', 'portaudioHostApi', 3);
[audioData, Fs] = audioread('8_Channel_ID.wav');
ad = audiodevinfo;
deviceID = ad.output(2).ID; % Select audio output device
channelmapping = zeros(size(audioData, 1), 1); % second dimension set to 1
selectedChannel = 1; % Select the desired channel (1 to 8)
channelmapping(:, selectedChannel) = audioData(:, selectedChannel); % Audio data with selected channel
p = audioplayer(channelmapping, Fs, 8, deviceID);
play(p);
Please find below the link to the documentaion of the 'audioplayer' function.
Hope this answer helps.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Audio and Video Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!