Volume control

The waave library understand the volume as a multiplicative filter applied to the stream audio data. Each stream have a associated volume value that control the filter. So a 1.0 value doesn't affect audio samples, values greater than 1.0 encrease audio gain while smaller value decrease it.

Set stream volume

You can set stream volume by directly give the multiplicative factor value. Don't forget that a 1.0 value don't affect the audio data so this will reduce the engine loading.

  /* set the stream volume to 2.0 */
  WV_setVolume(myStream, 2.0);

Volume triggers

The main problem to directly set the volume factor is that it doesn't take on account the logarithmic human audio persection. So starting with a 1.0 volume and encreasing it to successively 2.0, 3.0, 4.0 ... will make that the users will gradually no longer perceive the volume changes. The correct way is to choose an exponentiation factor like 2.0. Each time we encrease the volume we multiply the volume by this factor. This give the sequence 1.0, 2.0, 4.0, 8.0 ...

The idea described above is the idea behind the decibel (db) unit. The only difference is that decibel have a fixed exponentiation factor. With the waave library you can set the exponentiation factor with :

  /* set exponentiation factor to 2.0 */
  WV_setVolumeDBPitche(myStream, 2.0);

Note that this is useless because default value is 2.0. We can now directly set the volume by giving the power (db) value :

  /* set myStream volume */
  WV_setDBVolume(myStream, 0);  //set volume to 1.0
  WV_setDBVolume(myStream, 1);  //set volume to 2.0
  WV_setDBVolume(myStream, 2);  //set volume to 4.0
  WV_setDBVolume(myStream, 3);  //set volume to 8.0
  WV_setDBVolume(myStream, -1);  //set volume to 0.5
  WV_setDBVolume(myStream, -2);  //set volume to 0.25

So when building audio triggers, the DB pitche control the trigger sensibility and the trigger's value give teh volume in db unit.