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 / siz开发者_运维问答eof(int32_t); i++ )
{
// Add algorithm here
}
Thanks.
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.
精彩评论