Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

8 bit audio samples to 16 bit

This is my "weekend" hobby problem.

I have some well-loved single-cycle waveforms from the ROMs of a classic synthesizer.

These are 8-bit samples (256 possible values).

Because they are only 8 bits, the noise floor is pretty high. This is due to quantization error. Quantization error is pretty weird. It messes up all frequencies a bit.

I'd like to take these cycles and make "clean" 16-bit versions of them. (Yes, I know people love the dirty versions, so I'll let the user interpolate between dirty and clean to whatever degree they like.)

It sounds impossible, right, because I've lost the low 8 bits forever, right? But this has been in the back of my head for a while, and I'm pretty sure I can do it.

Remember that these are single-cycle waveforms that just get repeated over and over for playback, so this is a special case. (Of course, the synth does all kinds of things to make the sound interesting, including envelopes, modulations, filters cross-fading, etc.)

For each individual byte sample, what I really know is that it's one of 256 values in the 16-bit version. (Imagine the reverse process, where the 16-bit value is truncated or rounded to 8 bits.)

My evaluation function is trying to get the minimum noise floor. I should be able to judge that with one or more FFTs.

Exhaustive testing would probably take forever, so I could take a lower-resolution first pass. Or do I just randomly push randomly chosen values around (within the known values that would keep the same 8-bit version) and do the evaluation and keep the cleaner version? Or is there something faster I can do? Am I in danger of falling into local minimums when there might be some better minimums elsewhere in the search space? I've had that happen in other similar situations.

Are there any initial guesses I can make, maybe by looking at neighboring values?


Edit: Several people have pointed out that the problem is easier if I remove the requirement that the new waveform would sample to the original. That's true. In fact, if I'm just looking for cleaner sounds, the solution is trivial.

like image 853
Nosredna Avatar asked Jul 29 '09 22:07

Nosredna


People also ask

Can you convert 8bit to 16bit?

In general there is no way back from 8bit to 16bit. With 8bit images you can have 256 shades of gray, with 16bit you may have 65536 shades of gray. So if you have a 16bit image that shows more than 256 shades of gray and you convert it to 8bit, you definitely loose gray-levels.

Is 8 bit color better than 16bit?

In terms of color, an 8-bit image can hold 16,000,000 colors, whereas a 16-bit image can hold 28,000,000,000. Note that you can't just open an 8-bit image in Photoshop and convert it to 16-bit. When you create a 16-bit document, you are giving the document the 'space' to hold 16 bits of information.

Is 16-bit 44.1 khz audio good enough?

A bit depth of 16-bit for a sample rate of 44.1kHz is enough to reproduce the audible frequency and dynamic range for the average person, which is why it became the standard CD format.

What is the difference between 8-bit and 16-bit audio?

8 bit music only allows for 256 different levels of amplitude, which is going to have some digitization errors. 16 bit music will allow for 65,536 different levels of amplitude, so you get that much more nuance (or accuracy) in the waveform.


2 Answers

You could put your existing 8-bit sample into the high-order byte of your new 16-bit sample, and then use the low order byte to linear interpolate some new 16 bit datapoints between each original 8-bit sample.

This would essentially connect a 16 bit straight line between each of your original 8-bit samples, using several new samples. It would sound much quieter than what you have now, which is a sudden, 8-bit jump between the two original samples.

You could also try apply some low-pass filtering.

like image 197
Robert Harvey Avatar answered Sep 18 '22 17:09

Robert Harvey


Going with the approach in your question, I would suggest looking into hill-climbing algorithms and the like.

http://en.wikipedia.org/wiki/Hill_climbing has more information on it and the sidebox has links to other algorithms which may be more suitable.

AI is like alchemy - we never reached the final goal, but lots of good stuff came out along the way.

like image 40
MaHuJa Avatar answered Sep 18 '22 17:09

MaHuJa