how can i play sound to the right stereo channel only?

10 vues (au cours des 30 derniers jours)
Noam
Noam le 14 Fév 2016
Commenté : An le 6 Fév 2024
The sound command sends sound to both earphones. how do I send a sound to just one?

Réponse acceptée

Star Strider
Star Strider le 14 Fév 2016
The sound files are (usually) a (2xN) or (Nx2) matrix, one row or column for each channel. To have it play in only the right channel, set the other to a vector of zeros:
Fs = 44100;
t = linspace(0, Fs*2, Fs*2);
s = sin(2*pi*t*1000);
Out = [zeros(size(t)); s]';
sound(Out, Fs)
There is a problem with the sound on my laptop, so it’s not rendering this correctly. It should work on your computer.
  3 commentaires
Alireza Naghsh
Alireza Naghsh le 7 Mai 2021
With sound it is ok but if we audiowrite it is not work
An
An le 6 Fév 2024
Alireza Naghsh is right: Play works stereo, but when writing to file it doesn't seem to work.

Connectez-vous pour commenter.

Plus de réponses (1)

Noam
Noam le 16 Fév 2016
Thanks a lot Noam
  1 commentaire
Jan
Jan le 16 Fév 2016
Please accept the answer if it solves your problem. Use the section for answers for answers only. Thanks.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Audio I/O and Waveform Generation 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!

Translated by