Recognizing 8 audio channels not stereo
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Paras Gupta
le 18 Oct 2023
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 commentaires
Voir également
Catégories
En savoir plus sur Audio and Video Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!