I'm trying to invert a sound wave (phase shift 180 degrees), but I'm not exactly sure how I would go about doing this. Can any audio programmers point me in the right direction?
Inverting a sound wave should be generally easy if you have access to the byte array that makes up the sound. You simply need to take the negative of each value in the stream.
Audio streams come in many different flavors so it's impossible to be specific. However, if it was a 16bit PCM stream, which is full of 2-byte values, you'd loop over the data and for each two bytes in the stream: cast it to a short, take the negative of it, and put it back into the byte stream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With