1

I have the following code.

FloatControl volumeControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);

// Set the value to modify by in decibels
volumeControl.setValue(float volume);

Get minimum modification value in decibels (e.g. -80)

volumeControl.getMinimum();

Get maximum modification value in decibels (e.g. 6)

volumeControl.getMaximum();

I have a float called volume, which ranges from -1f (sound completely off) to +1f (200% volume).

How do I convert volume to the number of decibels to modify the volumeControl by?

Lucien
  • 776
  • 3
  • 12
  • 40
  • It's not totally clear if `volume` is intended to be relative to the total volume range, or is intended to be the volume delta relative to current volume. If it's intended to be relative to the total volume range, then you need to map the range of `volume` to the range of `volumeControl`, e.g. `volumeDecibels = 43 * (volume + 1.0f) - 80` – Ben Simmons Jan 14 '16 at 22:23
  • @BenSimmons, ah apologies. It is supposed to be relative to whatever volume the song is playing at currently (since decibels are logarithmic). – Lucien Jan 15 '16 at 06:23

0 Answers0