Cleaning Game Audio Files

Include new and ported/converted games, and old games/tools. Subjects about CP/M software goes in the CP/M Forum.
Bill B
Posts: 593
Joined: 26 Jan 2014 16:31

Cleaning Game Audio Files

Post by Bill B »

As those who were at Memofest 2016 know, I have created a version of Andy's MEMU that can load games from audio WAV files.

Claus PM'd me about using this to clean up audio recordings. This is possible, but MEMU will probably auto-run the game and so the problem will be breaking into it to save the file (The same problem as real hardware).

A beeter solution is some dedicated software to apply the cleaning directly, read in the original file and produce a cleaned copy. The copy can then be tested in MEMU to validate it.

I can think of a number of levels of cleaning:

* A simple "squaring" function, with hysteresis to prevent jitter at the edges.
* As above but with a timing filter to adjust the time between edges to be the "ideal" value for a zero or one.
* A two stage conversion WAV->MTX and then MTX->WAV. This process could probably include some higher level checking of the data format. Correct number of bits, correct chunk length etc.

I think I am talking myself into some work here :roll:

A couple of ways this could be implemented:

* In C or C++ with a command line UI. I would develop on Linux but there should not be any problem for people to compile on Windows.
* In Python. Execution would be slower, but a simple cross platform GUI would be possible.

Comments?
User avatar
Dave
Posts: 1280
Joined: 11 Aug 2012 18:16
Contact:

Re: Cleaning Game Audio Files

Post by Dave »

Hi Bill,

For programs that already exist as MTX files, I think that there is software already available to do the job.

The AppMake tool that is part of Z88DK should be able to generate a "clean" .WAV file from the digital .MTX file.

Paul will know more about this, but this might save you doing work that might not be required?

regards
Dave
http://primrosebank.net/computers/mtx/t ... _z88dk.htm
User avatar
Crazyboss
Site Admin
Posts: 274
Joined: 09 Aug 2012 21:45
Location: Sweden
Contact:

Re: Cleaning Game Audio Files

Post by Crazyboss »

Hi Bill and others :).

I would love to see Wave support for MEMU. I sample wavefiles at 22khz 8bit (i think, or maybe 16 bit). Its good enough to load it back into

I could even think about an option for loading the wave into memu at higher speed. As Bill demoed at Memofest 2016, it load in realtime :)

There are two things, one is to clean up the waves, to be sure the waves around (primary my homepage, are as clean as possible)

Another thing is when I convert games, it could be nice to if I could use Memu to create the wavefile to. So Saving to a wave would be nice - but I think I will be the only one to use that function :o by using memu.

Bill, it could be interesting to know if the TAPE version of Zombie Near, works with your MEMU. The game can be downloaded from www.mtxworld.dk too :)
//CLAUS - Webmaster at www.mtxworld.dk
User avatar
thewiz
Posts: 137
Joined: 12 Aug 2012 16:08

Re: Cleaning Game Audio Files

Post by thewiz »

Hi All,

I am sure it would be easy to resave wav files.

Apparently Andy used to know a small M/c program that would save out what it loaded in on a MTX.

I would guess that copying the rom routine to load a tape could be used as a basis. As it loads a block in, e.g. filename, sys vars etc, it could then call a routine to save the block. Obviously this would take a bit of investigation.

Did Genpat or MOC ever publish anything?

Cheers
THIS is what Memotech is doing now.
Bill B
Posts: 593
Joined: 26 Jan 2014 16:31

Re: Cleaning Game Audio Files

Post by Bill B »

Claus,

I confirm that my version of MEMU will load "Zombie Near" from the WAV file.

Bill

=== memu started at Sat Nov 5 11:48:39 2016 ===
Cassette remote control start
Tape start.
Cassette remote control stop
Tape stop: CTC Pulses = 3282.
Cassette remote control start
Tape start.
Cassette remote control stop
Tape stop: CTC Pulses = 29034.
Cassette remote control start
Tape start.
Cassette remote control stop
Tape stop: CTC Pulses = 16810.
Cassette remote control start
Tape start.
Cassette remote control stop
Tape stop: CTC Pulses = 3018.
Cassette remote control start
Tape start.
Cassette remote control stop
Tape stop: CTC Pulses = 3290.
Cassette remote control start
Tape start.
Cassette remote control stop
Tape stop: CTC Pulses = 29034.
Cassette remote control start
Tape start.
Cassette remote control stop
Tape stop: CTC Pulses = 227914.
Cassette remote control start
Tape start.
Cassette remote control stop
Tape stop: CTC Pulses = 3018.
Cassette remote control start
Tape start.
Cassette remote control stop
Tape stop: CTC Pulses = 3290.
Cassette remote control start
Tape start.
Cassette remote control stop
Tape stop: CTC Pulses = 29034.
Cassette remote control start
Tape start.
Cassette remote control stop
Tape stop: CTC Pulses = 265146.
Cassette remote control start
Tape start.
Cassette remote control stop
Tape stop: CTC Pulses = 15514.
Cassette remote control start
Tape start.
Cassette remote control stop
Tape stop: CTC Pulses = 3018.
Screenshot from 2016-11-05 11-50-33.png
Screenshot from 2016-11-05 11-50-33.png (9.37 KiB) Viewed 10981 times
Screenshot from 2016-11-05 11-43-08.png
Screenshot from 2016-11-05 11-43-08.png (10.26 KiB) Viewed 10981 times
Bill B
Posts: 593
Joined: 26 Jan 2014 16:31

Re: Cleaning Game Audio Files

Post by Bill B »

OK, I have had a go at producing a simple tape cleaning program. It does no more than turn the input file into clean square waves.

The program is a single C source file, and compiles with gcc on Linux. On Windows it should compile with MinGW or Visual C.

The user interface is command line:

./tape_clean_1 <input_File> - Produces statistics of the input wave file
./tape_clean_1 <Input_file> <Output_file> - Produces a cleaned version of the input file as the output file
./tape_clean_1 --hys 0.5 <Input_file> <Output_file> - Produces an output using 50% hysteresis.
Attachments
tape_clean_1.zip
(3.05 KiB) Downloaded 528 times
Bill B
Posts: 593
Joined: 26 Jan 2014 16:31

Re: Cleaning Game Audio Files

Post by Bill B »

This one is my level 2 tape audio file cleaning program. As well as squaring the input signal it normalises the pulse lengths. In order to do so, it needs to know the Baud rate of the recording. 2400 is assumed if nothing else is specified. The program can produce an output file with a different Baud rate, which gives the possibility of faster loading.

The program can also change the sample rate. The minimum WAV file size is produced by having a sample rate of twice the Baud rate (Nyquist theorem). This works for my MEMU, it needs testing for a real MTX. A cleaned, minimum sample rate version of "Zombie Near" is attached for the purpose.

A brief explanation of the hysteresis parameter. The program makes two passes through the input file. In the first pass it determines the mean and standard deviation of the input signal. Then in the second pass, a high output is generated when the input upcrosses:

Mean + Hysteresis * Standard deviation

And a low output when the input downcrosses:

Mean - Hysteresis * Standard Deviation

The difference in these two levels prevents jitter in the output caused by noise in the input signal.
Attachments
Zombie_Near_Clean.zip
(73.64 KiB) Downloaded 542 times
tape_clean_2.zip
(3.36 KiB) Downloaded 535 times
Bill B
Posts: 593
Joined: 26 Jan 2014 16:31

Re: Cleaning Game Audio Files

Post by Bill B »

Windows executable versions, compiled using MinGW,

Bill.
Attachments
tape_clean.zip
(18.45 KiB) Downloaded 514 times
User avatar
Crazyboss
Site Admin
Posts: 274
Joined: 09 Aug 2012 21:45
Location: Sweden
Contact:

Re: Cleaning Game Audio Files

Post by Crazyboss »

Great work Bill :)

Will the tool also detect if there are any CRC/Loading errors in the input wave ?
//CLAUS - Webmaster at www.mtxworld.dk
User avatar
Crazyboss
Site Admin
Posts: 274
Joined: 09 Aug 2012 21:45
Location: Sweden
Contact:

Re: Cleaning Game Audio Files

Post by Crazyboss »

by the way tested the tape2 in windows. I had to stop it, it was creating a big wave file.
I used kilopede - from mtxworld http://www.mtxworld.dk/kilopede.rar

using tape1 no problems.

I did not use any of the options in tape2 only input and output.

By the way would it be easy to convert the wave to a MTX file and convert MTX to wave ?
//CLAUS - Webmaster at www.mtxworld.dk
Post Reply