------------------------------------------------
BTc Sound Encoder for PIC sound.
Roman Black 2001

See the latest version + tools online at:
http://centauri.ezy.net.au/~fastvid/picsound.htm
------------------------------------------------

This is a encoder for 1bit sound which can be added
to a PIC (or other embedded) micro.

encoder.exe is a freeware tool that can display your
sound wave (which must be 8bit mono signed) and then
encode it into 2 formats. The encoded waveform is
done by closed loop math modeling and the encoded
waveform is shown with the original wave to compare.
The closed loop encoding gives good 1bit sound,
or more specifically the BEST possible bitstream
to reproduce the waveform.

Different encoding factors can be adjusted to give
the best result. The final sound bitstream data
is 8 times smaller than the original and can be
played back on any chip with a digital output
and a simple RC filter. The encoder even shows the
RC filter and gives you the R and C values so
your playback hardware will match the performance
of the encoder math model.

The encoder theory and algorithm is shown on my
web page:
http://centauri.ezy.net.au/~fastvid/picsound.htm

My BTc encoding algorithm is VERY fast and suitable
for real-time record/encode (as well as playback
obviously) on a PIC or any other small micro,
and will allow recording and playing back on a
20MHz PIC at any rate up to 156 kbit/sec!

I have supplied some .wav sound files, different
speed versions of the same file which has speech and
some background music. Windows should play these
files ok. The files are all 8bit mono signed:

dick06.wav	6kHz 
dick09.wav	9.766kHz   (10MHz PIC)
dick15.wav	15.625kHz  (16MHz PIC)
cannon16.wav	16kHz
dick19.wav	19.531kHz  (20MHz PIC)
dick22.wav	22.05kHz
dick44.wav	44.1kHz

sound.wav is the file the encoder works with,
so copy any sound file to that name and it will
appear in the encoder. Size limit is 60000 bytes
max at the moment.

The encoder will export data as raw bitstream data
file called sound.bit which is 8bits per byte,
the bits played from left to right, ie ms_bit is
first.

It will also export the sound bitstream data as
a PIC .asm file as a "retlw" table, allowing it
to be cut and pasted into any PIC .asm code.

You can get great speech playback with this system
provided you try to maximise the volume on
recording, and use bitrates of above 10kHz.
Even low bitrates will give acceptable results
if you do some extra filtering of the output
wave via a second RC filter.

NEW!! Christian Dorner has sent me code for a PIC
chip and I2C serial eeprom. This allows playback of a
LOT of sound, with a 24LC256 eeprom of 32k bytes you
can get 17 seconds of sound at 15625Hz. He gave me 3
new files which I have added to the .ZIP file you have
here. They are: 
  * PS_I2C.ASM    PIC assembler code
  * PS_I2C.INC    (serial eeprom routines, needed by above code)
  * PS_I2C.GIF    .GIF of the circuit using PIC 16F84 and 24C65 eeprom
I have not had time yet to test his code, and any
feedback is appreciated.

The web page and software are a bit rushed, I
threw them together in a few days just before
christmas. Hopefully I'll get time soon to add
inprovements like the abilty to attach an RC filter
to your PC parallel port and playback the encoded
bitstream in real time when encoding so you will
be able to hear the result with the same actual
hardware and bitrate you are going to use in your
product.
-Roman


