SofaCas bug report thread

Page 1/4
| 2 | 3 | 4

By Louthrax

Prophet (2280)

Louthrax's picture

06-05-2016, 02:05

SofaCas is a Windows command line tool designed to record/play .CAS files to/from an audio device or .WAV file. Please report any bug or suggestion on this thread.

It's using Goertzel signal processing, which makes the tool less sensitive to volume level, phase inversion or signal shift.

It gives pretty good results from my first tests, but please do not use it as a "preservation tool" right now, it still needs to be tested.

Another interesting feature is the ability to control the playback start/stop by connecting the MSX "REM" plug to a PC COM port (and I need to add schematics for this in the documentation...).

Windows executable and sources are available here. Code is quite generic except for the sound-acquisition/playback part and should be easy to port to other platforms.

Here's the command line usage:


SofaCas version 1.0, coded by Louthrax in April 2016
====================================================

sofacas play <cas_file> [options]

Plays an MSX .CAS or .ROM file to an audio output device or .WAV file

[options] can be one or more of:
    -a<i>    Specify audio output device (0). Use -l to list
    -b<f>    Audio output device buffer length in seconds (0.20)
    -c<port> Use COM port <port> to read REM signal (e.g. COM1)
    -f<i>    Frequency in hertzes (44100Hz)
    -g<f>    Start position in .CAS file in bytes (0)
    -h<f>    Short header duration in seconds (6.67s)
    -H<f>    Long header duration in seconds (1.67s)
    -k       Wait for [Return] key instead of long silence
    -l       List available audio output devices and exit
    -o<file> Output to .WAV file <file> instead of audio output device
    -p       Add prefix loader to always load with RUN"CAS:
    -r<i>    Target baud rate in bauds (2450Bd)
    -s<f>    Short silence duration in seconds (2.00s)
    -S<f>    Long silence duration in seconds (1.00s)
    -v<f>    Volume amplification (1.00)
    -w<i>    Waveform (Square)
		0: Square
		1: Sine
		2: Sawtooth
    -y       Do not ask before overwriting file

<i> is an integer number
<f> is a floating point number
<cas_file> is a source MSX .CAS or .ROM file

Command line options can also be specifed in a "sofacas_play.ini" file


sofacas rec <cas_file> [options]

Records an MSX .CAS file from an audio output device or .WAV file

[options] can be one or more of:
    -a<i>    Specify audio input device (0). Use -l to list
    -b<f>    Audio input device buffer length in seconds (0.20s)
    -f<i>    Frequency in hertzes (44100Hz)
    -h<f>    Header detection block length in seconds (0.10s)
    -H<f>    Header detection length in seconds (0.75s)
    -i<file> Use .WAV file <file> as input instead of audio input device
    -l       List available audio input devices and exit
    -m<f>    Minimal baud rate in bauds (500.00Bd)
    -M<f>    Maximal baud rate in bauds (4000.00Bd)
    -p<f>    Phase-adjust coefficient (0.25)
    -q<f>    Header quality (50.00)
    -r<f>    Header scan resolution (11.00)
    -s<f>    Silence ratio (0.10)
    -v<f>    Volume amplification (1.00)
    -w<f>    Header scan ratio (0.75)
    -y       Do not ask before overwriting file

<i> is an integer number
<f> is a floating point number
<cas_file> is a target MSX .CAS file

Command line options can also be specifed in a "sofacas_rec.ini" file

And a little snapshot of the thing in action:

Login or register to post comments

By Louthrax

Prophet (2280)

Louthrax's picture

06-05-2016, 02:32

A funny thing to note in the above screenshot is that the baud rate of H.E.R.O. is not the same on the first half and second half of the tape (the game is using 2 sides of the tape, side A at 1200 bauds and side B at 2400, each side contains 2 copy of the whole game). Wondering if that's caused by my cassette player mechanisms or done on purpose in factory...

By sd_snatcher

Prophet (3348)

sd_snatcher's picture

06-05-2016, 03:13

Great work again, Louthrax!

Do you think it would be too hard to add support for the 4-samples-per-bit proposed by hit9918 in this thread?

This method results in much smaller wave files than usual.

By Louthrax

Prophet (2280)

Louthrax's picture

06-05-2016, 14:11

It should be working out of the box with these parameters:

9600Hz is the minimal working frequency for 2400 bauds recording (2400Bauds -> 4800Hz header/short pulses -> 9600 samples). You can also use 4800Hz for 1200 bauds, but the file will be 2x longer, so same size as 9600Hz / 2400 bauds :)

I realize an 8bit output option would be interesting, as it does not really make sense to have 16bits sampling when using a Square waveform (not sure of the results with Sine & Sawtooth).

By Louthrax

Prophet (2280)

Louthrax's picture

06-05-2016, 15:12

"-8" option added to the "sofacas play" command to generate 8bits samples (both audio device and .WAV files), version updated to 1.1.

9600Hz 4 samples per bit .WAV file of H.E.R.O. weights 1,037,732 bytes now, and only 26KB once zipped (original .CAS file takes 19KB).

By Louthrax

Prophet (2280)

Louthrax's picture

10-05-2016, 01:04

Updated to version 1.2. Tweaked default values, improved header frequency detection and display some more information during recording (header type and binary start,end,exec addresses).

By Louthrax

Prophet (2280)

Louthrax's picture

12-05-2016, 14:57

Updated to version 1.3 (added -e option to filter wrong "header ends" detection).
Also put some tutorials on YouTube here and here.

By AxelF

Champion (359)

AxelF's picture

12-05-2016, 16:00

Wow, very nice project..
How did you connect the REM On / REM Off signal to the PC ?

By Louthrax

Prophet (2280)

Louthrax's picture

12-05-2016, 16:57

Ah, forgot to add that in the "usage" section :

To use -c option, connect the MSX REM cable to COM port pins DCD and RTS (pins #1 and #7 on DE-9 plugs), order has no importance.

Note that I have not tested that with a USB to serial adapter (I'm using a serial-port card).

By waal70

Supporter (4)

waal70's picture

19-05-2016, 14:37

Un travail impressionnant!

I have just re-woken my MSX and have a lot of old tapes containing programs of my own hand. I will definitely give this a try tonight! Your tutorial videos were VERY helpful and to the point.

BTW: I tried compiling the source as well, but I do not know your implementation of M_Assert; do you do anything special in there? Also, I use VS 2015 CE, so that may also be my bad...

By Louthrax

Prophet (2280)

Louthrax's picture

19-05-2016, 16:58

Merci Smile
Just remove the M_Assert lines for now if you want to play with the sources (they are defined in an external debug.h file that I forgot to include). I'm also using VS 2015 CE.
Let me know if you manage to get your old tapes back !

Page 1/4
| 2 | 3 | 4