Hi vsmGuy, and thanks for the compliments with my BTc Encoder.
Decoding BTc 1bit sound back to 8bit wave is not easy at all. I've thought about it for a lot of years but there is really no easy way, that's why i have never included BTc->Wave decoding in any version of the Encoder. I am very interested in what you are doing and if it can lead to a successful decoding system.
The problem is that the BTc encoding of the wave->1bit data encoding is very lossy. For every sound sample the encoder is generating both a 0 and a 1 bit, (based on the RC curve) then choosing the "predicted" bit that is closest to the original wave. The encoding algoithms are shown on my
Roman Black's BTc 1bit Sound Encoding Algorithms
(BTc Algorithms page)
So each BTc bit will have an error, that may be + or - to the original sample, by quite a large amount. Then the next bit will have another error that will tend to correct the previous error(s), because every new bit chooses the best option (+ or -) to get back to (closest to) the original waveform.
This randomness of the error is extremely hard to reverse engineer being that the + or - for that bit is unknown, as were the bits before it that were also unknown. Also the predictive nature of the algorithm means there is a time issue as the BTc bit is predicted in advance of the new wave bit.
Sorry I don't know PERL so I cant help you much there, but one thing seems an issue is that my algorithm uses the middle part of the 5v (ie the orig wave is reduced to half amplitude and then biased at 2.5v centre, so it goes from 1.25v to 3.75v only). Your first diagram seems to have a 0v-5v swing which would not be possible given that RC time constant and that bitrate. If you change that it should get you back close to the BTc waveshape. Again, check my encoding algorithms on the link above, reproducing the BTc waveform from the BTc data should not be that hard.
I really don't think you can reverse encode the BTc data back to a wave based on a per-sample system for the reasons I stated above. The only way I think it CAN work is to do it the same way your ear does, by a low pass averaging of the total waveform. By averaging each sample with the samples before AND after (remember it's predictive) you should be able to remove most of the PCM noise and get a re-coded (not decoded) wave that is hopefully something like the original wave.
Hope that helps.





