Reversing buffer array - losing bytes
Hey, I'm assisting in a project I can't disclose until it's release, and we've run into a bit of a problem.
Say you have a 32 or 16 bit audio buffer, it gets the bytes from an imported file.
Now, make a copy of that same array, but reverse it. Now if you were to start playing the audio buffer, and halfway through, decide to reverse it,
you hit a reverse button and it finds whatever byte you're at in Buffer 1, but it finds it in Buffer 2 and moves forward in that buffer.
Recap:
Buffer 1 is forwards
Buffer 2 is reversed
hitting the reverse button will find the byte you're at in Buffer 1, but in Buffer 2 so that when it moves forward in buffer 2, it'd be the same as moving backwards in buffer 1.
Now, there's also an automatic replay option. when it reaches the end of the buffer you're playing, it will go to the opposite end and continue to play from there.
This works fine in buffer 1,
But in Buffer 2, you start to lose bytes and the sound appears sped up and whatever speech you have loaded seems nearly inaudible. It only does so when the automatic replay function is on.
Does anyone have any ideas as to why this might be?
Thanks, I really appreciate any help!
Re: Reversing buffer array - losing bytes
How do you play the sound? Does the buffers contain anything besides raw sound?
Re: Reversing buffer array - losing bytes
I'm assuming it's just raw sound, but the audio guy was unclear on that part. He's using this plugin to handle the audio. http://naudio.codeplex.com/
Thanks for the reply!
Edit: I remember, he said there's headers in the first stream as well, but when it switches to buffer 2, it keeps the headers of buffer 1, and buffer 2 is just the audio.
Re: Reversing buffer array - losing bytes
And playing audio from buffer2 works allright, except when auto-replay is on?
Truly and odd problem. I had a quick glance through the documentation you provided. If I were to guess, I would assume that this had something to do with:
1) Encoding
2) Data-packing
3) Stream-format
but neither of them seem likely, if you can play in reverse ok without auto-replay.
I'm going to have to draw a blank on this - sry :(
#EDIT: I would be interested in hearing what caused the problem, assuming ofc you solve it eventually.
Re: Reversing buffer array - losing bytes
I talked to the audio guy again, he said he solved it but has no clue why it wasn't working in the first place.
He had the functions set up in a way where there was a function handling all things reversed, then another handling the auto-replay. he had if(_reversed) under the auto replay function, and by changing it to if(_areplay) under the reversed function, it just started working out of nowhere.
Hopefully anyone finding this thread by google has the same structure lol, otherwise this will probably be of no help.