Baldur
Baldur

Reputation: 237

An algorithm for inverting a soundwave

Hi I’m making a simple program in Objective-C and I need to get the inverse of a soundwave. I've tried searching for an algorithm for doing this but I haven't found anything. I guess it’s more complicated than just multiplying each value with -1 :P

Here’s my code so far, I’ve cast the data to int32_t to be able to manipulate it:

int32_t* samples = (int32_t*)(sourceBuffer.mData);

for ( int i = 0; i < sourceBuffer.mDataByteSize / sizeof(int32_t); i++ )
{
    // Add algorithm here
}

Thanks.

Upvotes: 0

Views: 548

Answers (1)

Simon Lee
Simon Lee

Reputation: 22334

Multiplying by -1 should work no? What output do you get? Bear in mind you won't hear ANY difference with the wave unless you layer the normal and inverted together in which case they will cancel each other out.

Upvotes: 2

Related Questions