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

11 visualizaciones (últimos 30 días)
Noam
Noam el 14 de Feb. de 2016
Comentada: An el 6 de Feb. de 2024
The sound command sends sound to both earphones. how do I send a sound to just one?

Respuesta aceptada

Star Strider
Star Strider el 14 de Feb. de 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 comentarios
Alireza Naghsh
Alireza Naghsh el 7 de Mayo de 2021
With sound it is ok but if we audiowrite it is not work
An
An el 6 de Feb. de 2024
Alireza Naghsh is right: Play works stereo, but when writing to file it doesn't seem to work.

Iniciar sesión para comentar.

Más respuestas (1)

Noam
Noam el 16 de Feb. de 2016
Thanks a lot Noam
  1 comentario
Jan
Jan el 16 de Feb. de 2016
Please accept the answer if it solves your problem. Use the section for answers for answers only. Thanks.

Iniciar sesión para comentar.

Categorías

Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by