How do I control the audio volume when using AUDIOPLAYER in MATLAB?

조회 수: 95 (최근 30일)
I am using AUDIOPLAYER function to play an audio file and would like to control the audio volume.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2023년 5월 15일
편집: MathWorks Support Team 2023년 5월 15일
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개)

Jan
Jan 2016년 3월 11일
편집: MathWorks Support Team 2023년 5월 15일
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 1월 10일
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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by