Need help with MSX tape wav to cas conversion

By dhau

Paragon (1556)

dhau's picture

29-11-2017, 00:24

I am trying to find some tool to convert wav tape images to cas files. There are many great tools that will convert rom, bin or bas file to wav, like caslink and microwaver. But I only know of one that converts wav to cas: joyrex2001 castools. It works on some wav files from msxdev releases, but it fails to work on wav output from openMSX 0.14. I filled a bug report: https://github.com/joyrex2001/castools/issues/4. Does anyone know who joyrex2001 is and if he's still active? I certainly hope so. If you're him and reading this, thanks for writing and maintaining castools!

openMSX is the only emulator that will load and save wav files. It does some DSP stuff on PCM data, see CasImage.cc, so it's not pure 1200/2400 buzzing. May be that is what confuses castools.

Also, castools is using 396 bytes of wav data per byte of cas data. This is because each byte is encoded in 11 bits and each bit is either one long 1200hz beep or two short 2400hz beeps. castools is using a non-standard 43200hz discretization and probably relies on digital player hardware and drivers to interpolate this into 44.1 or 48khz. The reason for that number is because 43200 = 1200 * 36 = 2400 * 18, so we use 36 bytes in wav channel for each encoded bit, so one byte of cas input generates 11*36 = 396 bytes of wav channel data. If joyrex2001 would just do that as-is but set discretization at 44.1khz, it would result in sligtly off-tone beeps: instead of 1200hz we'd get 44100/36 = 1225hz and instead of 2400hz we'd get 2450hz. Interestingly enough, most audio chips those days work comfortably with 48khz data without resampling, and 48khz allows to have 1200/2400hz tones using exactly 40 bytes per input bit, no rounding errors, no pitch shift.

I'd like to find out if there are more tools for converting wav file to cas and how well they work.

Please help, thank you in advance.

Login or register to post comments

By Manuel

Ascended (15360)

Manuel's picture

29-11-2017, 10:28

What "DSP stuff" do you mean? CasImage only converts the cas to wav internally, so it cannot be related to the output wav when saving to cassette.
openMSX doesn't do anything special. It just records to WAV what the MSX puts on the cassetteoutput bit. Nothing more nothing less.

The best way to create a CAS file is to use an MSX tool: http://cintasmsx.webcindario.com/ (TAPE2CAS). It worked fine for me :)

There's also SofaCAS by Louthrax, a PC tool.

By NYYRIKKI

Enlighted (5270)

NYYRIKKI's picture

29-11-2017, 14:09

Manuel wrote:

openMSX doesn't do anything special. It just records to WAV what the MSX puts on the cassetteoutput bit. Nothing more nothing less.

Actually it is not purely digital... there is a bit of "extra logic" in it as it emulates the signal attenuation caused by signals tendency to drop towards "zero level" over time. How ever it does not emulate the filtering that is caused by the cassette it self -> You can record & load stuff that would newer be possible with real cassette. (BTW for some reason it does not emulate this attenuation unless cassette motor is spinning IIRC.)

One big question is should this filtering be emulated as well? Emulating it on output could help developing & testing functional cassette turbos, but since this is analog stuff that depends a lot about used hardware there is no such a thing as "right" amount of filtering, so emulating it would require the filter to be user adjustable anyway.

By TomH

Champion (324)

TomH's picture

29-11-2017, 14:51

Based on the bug you filed, the problem seems to be that castools makes an assumption about phase that isn't borne out by the wav you have. Different tape recorders have a habit of introducing different phase shifts at different frequencies, so a really solid tool should try to be immune to that. Similarly, tapes flutter and wow, often relative to a slightly different motor speed than originally recorded at, so being allowing input a little way off 1200 or 2400 is also fairly essential.

I saw that your wav is attached to the filed issue, so might stick my own nose in if no other answers are forthcoming.

By eimaster

Master (220)

eimaster's picture

01-12-2017, 04:32

To NYYRIKKI

What I understood from Manuel is that openMSX is a near perfect MSX computer emulator. It emulate the machine not its peripherals like the cassette.

As you know, computers is digital while the data cassette recorder is an analog device. openMSX is digital as well. So after openMSX record the WAV file on the PC hard disk, you can attach an analog cassette recorder to the PC and record the WAV file sounds to a tape. The cassette recorder will then apply the filtering you mentioned the same way happen when using a real MSX computer and a cassette recorder.

Or have I missed something?!

By NYYRIKKI

Enlighted (5270)

NYYRIKKI's picture

01-12-2017, 09:04

eimaster wrote:

To NYYRIKKI

What I understood from Manuel is that openMSX is a near perfect MSX computer emulator. It emulate the machine not its peripherals like the cassette.

As you know, computers is digital while the data cassette recorder is an analog device. openMSX is digital as well. So after openMSX record the WAV file on the PC hard disk, you can attach an analog cassette recorder to the PC and record the WAV file sounds to a tape. The cassette recorder will then apply the filtering you mentioned the same way happen when using a real MSX computer and a cassette recorder.

Or have I missed something?!

No, you got it right and I take your answer as "No, this should not be done". How ever the line between what should be and what should not be emulated is not quite black and white... openMSX ie. emulates things like blur and noise in monitor emulation, so for that reason I see no reason why cassette analog features could not be emulated just as well... as I said it might even become handy option in some special cases.

By eimaster

Master (220)

eimaster's picture

02-12-2017, 05:18

NYYRIKKI wrote:

No, you got it right and I take your answer as "No, this should not be done". How ever the line between what should be and what should not be emulated is not quite black and white... openMSX ie. emulates things like blur and noise in monitor emulation, so for that reason I see no reason why cassette analog features could not be emulated just as well... as I said it might even become handy option in some special cases.

You have a point and I'm convinced.
Manuel... you shouldn't have emulated the video display device (TV and Monitor). Now you must try convincing openMSX developing team to emulate all MSX peripherals stsrting with the data cassette recorder. At leadt it would be appreciated by all MSX lovers and would gain respect from other emulators' developers not just for MSX but for other computers. I hope you consider this suggestion seriously.

By Manuel

Ascended (15360)

Manuel's picture

02-12-2017, 14:28

I don't have such plans, as I fail to see the added value. We have limited spare time to work on openMSX, so we work on what we like to work on. Feel free to convince/seduce other developers to work on this of course. Anyone can help! Not only the team itself.