0
0

Greetings all, thanks to the great documentation and forum posts I haven’t had to post yet, but this time I’m pretty stuck. I’m using c# to draw or visualize a waveform for an entire wav file, using readData and FMOD.MODE.OPENONLY, as was demonstrated in the offlinedecoding sample project. Currently, I am able to open and draw both mono and stereo 16-bit files, but have hit a snag with 8-bit files. Here’s the c# I use for 1 channel 16 bit…

[code:15067ui0]while (index < length – 2)
{
values.Add(Convert.ToInt32(BitConverter.ToInt16(buffer, index)));
index += 2;
}[/code:15067ui0]

where "values" is an Int32 List, "buffer" is a byte array copy in managed memory of the data returned by readData, "length" is the length of that byte array, and "index" is just an integer index of the current position in the byte array.

Here’s what I’m using for 1 channel 8 bit…

[code:15067ui0]while (index < length)
{
values.Add(Convert.ToInt32(buffer[index]) – 128);
index += 1;
}[/code:15067ui0]

I subtract 128 because it is my interpretation that for an 8-bit unsigned sound, 128 represents 0 amplitutde, whereas for a signed sound 0 represents 0 amplitude, so to convert from unsigned to signed I simply have to subtract 128. Correct?

Once the data is read, the same code uses the list to draw all waveforms, which would imply that the my problem is in acquiring the data.

Now, I do realize that you can’t make a straight conversion from unsigned 8-bit to signed 32-bit, the drawing code takes the values in the list and then uses the the format of the sound to draw. ( (value / 2^bit format) * GUIClientHeight = final value to draw)

So, what should I be doing differently for 8-bit files? Given that 16-bit files are working so well I know I’m doing something right, I just don’t see what I’m doing wrong. Any and all suggestions would be greatly appreciated here. Thank you so much!

Drew

  • You must to post comments
0
0

Somebody? Anybody? Brett? Am I asking a dumb question? Did I not provide enough info? Please help!

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.