How to control the volume of speaker using MATLAB?

24 views (last 30 days)
I am working on a project related to audio signal processing and want to map the rms value of a signal to control the volume of a speaker. The louder the signal, the more the rms value and hence the output of the speaker should be loud and vice versa. So, I would like to know if there is a way to do this?

Accepted Answer

Walter Roberson
Walter Roberson on 19 Apr 2018

Typical method:

  1. set speakers to maximum volume
  2. multiply signal in range -1 to +1 by fraction of maximum volume that is desired.

More Answers (1)

Jan
Jan on 18 Apr 2018

If you want to control the volume of the speakers use FEX: Control speaker volume.

 The louder the signal, the more the rms value and hence the output of the speaker
 should be loud

If the signal is loud, the output is loud already without the need to control anything. Maybe you meant the opposite: For a loud signal reduce the volume level?

Another idea is to scale the signal to get the wanted RMS value.

  1 Comment
goutham gumm
goutham gumm on 19 Apr 2018
Okay,let me make it clear. What I want to do is just to be able to play a WAV file at a volume which is under my control. I'm actually simulating a musical instrument where I use a piezoelectric sensor to generate electrical signals and based on the force applied, it generates stronger signals.I want to take the rms value of this signal and play a WAV file stored in my computer at a volume corresponding to the rms value.

Sign in to comment.

Categories

Find more on Simulation, Tuning, and Visualization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!