How do I control the audio volume when using AUDIOPLAYER in MATLAB?
95 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 21 de Jul. de 2009
Editada: MathWorks Support Team
el 15 de Mayo de 2023
I am using AUDIOPLAYER function to play an audio file and would like to control the audio volume.
Respuesta aceptada
MathWorks Support Team
el 15 de Mayo de 2023
Editada: MathWorks Support Team
el 15 de Mayo de 2023
A function to control audio volume directly is not available as of MATLAB R2015a.
As a workaround, you can modify the value of the signal data to control volume. Please see the code below for an example:
load handel; % 'handel' is a MAT-file which is shipped with MATLAB as an examplex = y/5; % Decrease volumeplayer = audioplayer(x, Fs);
play(player,[1 (get(player, 'SampleRate')*3)]);
x = y*5; % Increase volumeplayer = audioplayer(x, Fs);
play(player,[1 (get(player, 'SampleRate')*3)]);
As an additional workaround, you might try using the File Exchange submission called "SoundVolume", which sets or gets the computer system's speaker sound volume using Java. This submission can be found at the following link:
1 comentario
Walter Roberson
el 6 de Abr. de 2016
Más respuestas (1)
Jan
el 11 de Mzo. de 2016
Editada: MathWorks Support Team
el 15 de Mayo de 2023
1 comentario
Walter Roberson
el 10 de En. de 2017
Farhan Hussain, are you saying that if you use Yair's routine while audioplayer's play() method is in the middle of playing a file, that audioplayer goes back to the beginning of the file?
Ver también
Categorías
Más información sobre Audio and Video Data en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!