WAV file to sample PRG player converter

4 bit version

This is a converter script, which creates a C64 PRG file from a WAV file, which plays it. It is tested with Python 2.7 and 3.3.2. First download the script and then call it like this:

python.exe sampler.py

In Windows the Python interpreter might be not in the path:

c:\Python27\python.exe sampler.py

It expects the file "music8khz.wav" in the same directory, a 16 bit signed integer PCM encoded mono file, with 8 kHz sample rate. The max wave file length is 12 seconds. It uses some inline assembler for the sampler program, which is appended to a C64 BASIC header, and the music is appended at the end. This is the sampler source code: sampler.asm

Test output with some seconds from this music: music.prg. The compressed and amplified wave file: music8khz.wav.

For quick testing the audio quality, and adjusting the assembler source code (the delays are not perfect), you can use this command line in Windows:

dasm sampler.asm -osampler.prg && \Python27\python.exe sampler.py && "c:\Program Files\WinVICE-2.4-x64\x64.exe" music.prg<

Uncomment the commented part in sampler.py for loading sampler.prg instead of using the inline code.

8 bit version

This is a first version for 8 bit sampling, cycle accurate for 11kHz playback, with some colors to simulate a peak meter:

sampler8.py

sampler8.asm

sampler8.prg

Save "sampler8.prg" and "sampler8.py" in the same directory. The Python script converts expects a mono wave file "music11khz.wav" with 11kHz sample rate and a max file length of 4.5 seconds and creates "music8.prg". Sample files:

music8.prg

music11khz.wav


4. October 2013, Frank Buß