Sphere-Corporation / GAME-TT

Tic-Tac-Toe for the SPHERE-1 Computer
MIT License
1 stars 0 forks source link

Improve cassette wav file generation #3

Closed alshapton closed 1 year ago

alshapton commented 1 year ago

Your WAV file didn't quite work-- I think the data in the WAV is missing the tape file framing (the leading 0x16 sync bytes, header, trailer, etc) even though the data is there? Not sure why. The complete binary (in your javascript array) worked fine when I turned that into a WAV file myself.

I looked at your python code and although there are certainly different ways of thinking about how to separate logical from physical cassette files, I believe that you probably don't want to "only" add the header/trailer as part of writing out audio data. A cassette image is a logical byte stream and since the cassette firmware (not the audio electronics) expects to read and write the framing, they would seem to be part of the "data" as well. (That's why the emulated PDS expects those parts even when loading from a digital source.)

Anyway, attached here for your use if handy is a sphere_encode.py file that I use-- I think derived from the same source yours is, with some tweaks for inter-block carrier management and also emits sine wave audio instead of square waves. It assumes the header and trailer already exist in the input and it just blindly encodes whatever is there.