Sign in to follow this  
tonymontana

Changing Volume programatically - Amplification effect

Recommended Posts

İ loaded a Wav file.Iparsed it myself.So i have the buffer.What i want to do is lower /higher the sound programatically.My idea was getting left channel bits shift them 1 ( thats doubles their value.So makes them louder).and doing the same thing for the right channel.This doesn't work.What's the trick here?

Share this post


Link to post
Share on other sites
The values are typically 16 bit signed values, ie. centred around zero, so you can't just shift them as it would make the values fly all over the place. You need to multiply them by between 0.0 and 1.0, to do it properly. I don't know much about low-level speed these days, so I'm unsure whether it's faster to convert to a float, perform the multiplication, then convert back, or to do it all in integers (eg. multiply by 100, then divide by a number between 1 and 100). I'm sure there are other tricks with bit manipulation or special CPU instructions but I'd recommend you keep it simple to begin with.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this