I perform such operations with my audio signal:
- Read raw data from buffer
- Downsample from 24 bit to 16 bit
- Convert to double <-1, 1>
- Calculate dB
I would like to add volume control to my program but I don't know at which step should I edit my signal data.
Also I would like to ask about scaling method. After doing some research so far I have 2 ideas:
First idea:
for (int i=0; i<buffSamples; i++)
{
buffer[i] *= volumeModifier;
}
So I could just multiply samples by some value, but I don't know if it should be in dB or double, or maybe I can manipulate raw data to get the effect? Also I read that human hearing doesn't change in linear way so that method isn't to good and better way would be just changing audio volume by -6dB because that makes noticeable difference but I don't know how to achieve it.
Second idea I've found somewhere:
for (int i=0; i<buffSamples; i++)
{
buffer[i] *= volumeModifier * pow(10, (-6.0 / 20.0));
}
And from what I understand from it. Every time volumeModifier change value by 1 it should change amplitude by half?
Aucun commentaire:
Enregistrer un commentaire