User Tools

Site Tools


x68000:mxdrv_mml_mdx_tutorial

This is an old revision of the document!


MXDRV MML/MDX Tutorial

So, you've been enlighted with the knowledge of a little machine called the Sharp x68000. It was powerful, beautiful, and maybe even a tad expensive ( that didn't keep people from flocking to purchase one :-) ).

You probably know that one of its major strong points were two sound chips called the YM2151 and the OKI MSM6258.

And as with any computer worth buying, if you're into composing music, then this computer will work for you. Especially since it's got FM audio + ADPCM. Sega Genesis? Who needs it?! It's got a system that will stomp it any day (and yes, I mean the SNES)!

But the blessed Japanese folks were the only ones who got ahold of this machine.

So, what if you wanted to, I dunno, compose music using the x68k's beautiful FM synthesis + ADPCM audio. MXDRV MML is the name of the game (not an actual game though).

The problem is that there's not a lot of documentation on it in English. So make sure you thank me well, and maybe give me a nice pat on the back (and send me lotsa money so I can buy some C64 peripherals, an Amiga 500, a Sharp x68k of my own, and every other vintage computer I'd like to get my bony hands on! Ooops! Forgot to mention the Compaq Presario 425!). Kidding about the money part, although that doesn't mean I won't accept money :-).

LOL

x68k Sound Information

The Sharp x68000 has two chips for audio within the main unit. These two chips are the Yamaha YM2151 (a.k.a. OPM), and the OKI MSM6258, which are used for FM Synthesis and ADPCM sampled audio respectively.

The early models of the x68k have 8 channels of FM and 1 channel of ADPCM. Later Sharp decided to expand the ADPCM audio, and added 7 extra channels of ADPCM, dubbing the new ADPCM system the PCM8 expansion or PCM8. There is also a software called PCM8 which uses software mixing to add more ADPCM channels, but from what I've tested of it, it's a CPU cycle thief. There are other software mixing ADPCM TSR drivers, but I haven't tried them.

MXDRV allows you to use PCM8 in addition to the normal FM Synthesis and ADPCM.

Required/Optional Tools and Information Links

Here are some useful links to tools and information that you might want to see.

The following tools are required to write MXDRV MML code:

Run68k - Sharp x68k command line emulator, necessary to run x68k programs from 
term/cmd:
https://osdn.jp/projects/sfnet_run68/
Alternatively, you can use a full x68k emulator, but I have no idea how you 
would handle file transfer that way. The command line emulator has access to 
files on your hard drive, so you can run x68k command line programs from your 
system'snative command line.
MDX_TOOL - x68k MXDRV tools, necessary to compile your MML->MDX:
http://nfggames.com/x68000/Mirrors/x68pub/x68tools/SOUND/MXDRV/MDX_TOOL.LZH
This archive contains mxc.x, the x68k MDX compiler. You will need to run it 
with run68k and your MML file to compile to MDX.
There are other MDX compilers, but this is the one I use.
MKPDX
http://x.haun.org/software/mkpdx/mkpdx.txt
This tool is required to create PDX files. See the section on making a PDX for this.
It's a Win32 executable, so no emulator required (unless you're using Linux or Mac).
WAV2ADP 
http://nfggames.com/x68000/Mirrors/x68pub/x68tools/SOUND/ADPCM/W2ADP101.LZH
This tool is required to convert any .wav audio files you have lying around, that
you want to convert to ADPCM for use in a PDX. See the section on making a PDX for this.

GR_ALL.lzh - Battle Garegga MDX tunes:
http://kmkz.jp/mtm/mag/mus/mdxdat/GR_ALL.lzh
This archive contains all the MDX tunes from Battle Garegga, but I mainly linked to it 
because it has a PDX file if you don't want to create your own. The PDX contains some nice
samples from synths and drum machines (the TR-909 and others) that Manabu Namiki didn't want, or 
need to program as FM instruments.
VOPM - OPM Emulation VST, necessary for making your own FM patches:
http://www.geocities.jp/sam_kb/VOPM/
You can experiment with VOPM and make your own FM sounds, or rip them from other
FM tunes using mdxtools or .opm files from the internet. This is important 
because if you don't have any FM patches, you won't be able to make music on an FM
chip lol.

Savihost - Standalone Virtual Instrument Host, necessary if you want to run VOPM without
a DAW:
http://www.hermannseib.com/english/savihost.htm

mdxtools - "A bunch of tools for handling the MDX music format (music for the 
Sharp X68000 using the MXDRV sound driver).":
https://github.com/vampirefrog/mdxtools
You need these tools if you want to do things like rip FM patches from other MDX 
tunes or decompile MDX. I've only gotten this toolkit to compile on Linux, which 
shouldn't be too much of a problem for you if you don't use Linux (VM or dual boot).

opm2mml - A program to convert MiOPMdrv .opm banks to MXDRV mml:
https://drive.google.com/open?id=0B-5MDOTTWQK9a0hhbFNFUlBXdDQ
This is a tool I coded in Java to do exactly what the description says. With it, you'll be able to 
convert .opm banks to MML. You can find lots of .opm banks online, and you can rip them from software/games on
systems using the YM2151 or YM2612 chips. Even better, you can export VOPM preset banks to .opm, so you can use
your own patches. If, for whatever reason, you need a version in C++ or C because you don't use or like Java, then I may
port it to one of those languages. 

To play your compiled mdx tunes:

mxv - MXDRV World Vision, an MDX player:
http://gorry.haun.org/cgitest/download.pl?subject=CGI-DOWNLOAD%20mxv200b.lzh&info=readcount&file=mx.html&downfile=mxv200b.lzh
The player requires the libraries X68Sound.dll and MXDRV.dll
X68Sound.dll - X68k YM2151 and OKI Emulation library, necessary for mxv:
http://gorry.haun.org/cgitest/download.pl?subject=CGI-DOWNLOAD%20X68Sound_020609_g20020611.lzh&info=readcount&file=mx.html&downfile=X68Sound_020609_g20020611.lzh
mxdrv.dll - Mdx driver for Windows, necessary for mxv:
http://gorry.haun.org/cgitest/download.pl?subject=CGI-DOWNLOAD%20mxdrv200b.lzh&info=readcount&file=mx.html&downfile=mxdrv200b.lzh

Alternatively, you can use the Winamp in_mdx.dll plugin in Winamp or XMPlay, or use the native MDX player for the X68k
Note that the Winamp plugin requires you to have mxdrv.dll and X68Sound.dll in the same directory as the player (Winamp or XMPlay)
Putting those libraries in the same directory as the plugin will not work if you put your plugins in subdirectories

The following tools and infos are optional:

PPMCK MML Beginner's guide:
http://www.nullsleep.com/treasure/mck_guide/

Notepad++ - Windows text editor made especially for coders: 
https://notepad-plus-plus.org/
Notepad++ will make it a lot easier to write in MML in because you can define your own
language syntaxes. I might make an MXDRV MML user defined language someday, but not atm.

Woolyss chipmusic > MML - MML tools and editors 
http://woolyss.com/chipmusic-mml.php
This page has a great deal of MML editors and compilers (though none for the x68k).
It MML bundles for various text editors at the bottom of the page (including 
Notepad++), but it was made for PPMCK mml. However, you can still use it.

General MML Information

If you don't already know what MML is or how it works, then hold your $400 studio headphones, because I'm about to explain. Well, only the basics, because a lot of general MML information is already documented in English.

MML, or Music Macro Language, is a programming language used for nothing other than composing music. Sounds a bit masochistic, but it's not as bad as you think, so keep reading.

The core of MML is rooted in traditional musical notation. So it's not like you'll be programming your music routines in assembly…bless Rob Hubbard's heart. But it also means that you'll be doing everything in textual format, unlike many other electronic composition methods.

As with any worthwhile electronic composition method, MML uses commands which allow things like portamento, ties, vibrato, and other important musical techniques.

General MML Macros and Syntax

Get ready, because I'm about to get straight to the point with this one. If some of these terms are confusing you, then you might need to learn basic music theory.

Macro arguments in brackets are optional, and the brackets are NOT part of the command, with the only exception to this being the loop macro.

!

Ignore all following commands on the current channel
Sort of like commenting out code, although you can use ; or /* */ for that
@#

Select voice, where # = the desired voice(0 - 255)

The precondition here is that the voice must already be defined, else your 
compiler will flip you the bird.
Assuming that you're writing this on an FM channel, using this command will 
switch to the desired instrument denoted by num. There is a very 
important variation of this syntax which I will discuss later.
#TITLE title

Sets the title of a tune

Ex. #title mytune
& 

Tie macro
When this macro is used between notes, it will tie to the next note. For porta-
mento, you want to use the glide macro instead. This just 
( )

Decrement/Increment Volume, respectively.
( ~ lowers the volume of the current channel by one
) ~ raises the volume of the current channel by one 
_

Portamento to note
When specified directly after a note, this command will glide to the next note. 
Note: the note to be glided to must not have a duration macro after it
Ex. c4_e
glides from c to e in a quarter note
< >

Decrement/Increment octave, respectively.
Where > increments the octave and < decrements it
Use these instead of o when you want to change the octave up or down by a value
of one.
.

Dotted note macro
Add half (of a note's duration) to a note's duration
Ex. c4. 
A dotted quarter c note

[]#
Loop macro, loops the macros inside the brackets
The macros to be looped go inside the brackets and # is the number of times to 
loop them.

Ex. [c4]3    ~ Plays c quarter note 3 times and exits the loop

/
Break a loop on the last iteration
This macro goes inside the brackets with the rest of the macros

Ex. [c4 / d4]4		~ Plays c quarter note four times, but d quarter only 3 
times
;
Line comment
Use this to comment on a single line
/* */
  
Block comment
Use this to make a comment that extends multiple lines or to make single line
comments look nicer
chan

Specify the channel
Where chan is the corresponding letter for the channel. This macro must always 
be at the beginning of a line in which you intend to coerce any digital farts 
out of your poor x68k (or emulator).

Ex. A  		~ This sets the current channel to channel A
D#

Detune current voice
Where # is the value to detune by in 1/64 semitones
k# 

Delay macro
Where # is the number of ticks to delay by
L
Set loop start
Use this command in a channel when you wish to loop everything after this 
command
l[length]

Set the default note length.
Where length is the numerical value of the length in powers of two (ex. l4 
sets default note length to quarter notes).

When a note is specified without a length after, the note will default 
to this length. If this command is not set, the default length is set to 4,
a.k.a. a quarter note
MPwaveform,speed,depth
Set pitch LFO 
Where waveform is the LFO waveform (0 = sawtooth, 1 = square, 2 = triangle), 
speed is 1/4 of the LFO cycle in ticks, and depth is the 
max amplitude of the LFO. 
Useful for vibrato.

MPON 
Turn pitch LFO on for current channel, only needed if you have turned the 
pitch LFO off (setting the LFO automatically turns it on).

MPOF
Turn pitch LFO off for current channel. Only needed when it is already on.
n#,length

Play a note by its numerical value, with the length separated by a comma.
"length" is the length of the note in eights. See the next entry for proper
lengths.
Ex. n21,8 
Play note 21 as an eigth note
note[accidental][length]

Play a note with the desired length.
Where "note" is the letter of the musical note you want to play (a-g), 
"accidental" is the desired accidental (+ for sharp and - for flat), 
and "length" is the length of the note in eights.
For the note lengths, you can use any standard note length:
1 - whole note
2 - half note
4 - quarter note
8 - eighth note
16 - sixteenth note
32 - thirty-second note

Any length not a power of 2 or > 32 is not supported and will cause your compiler to 
question your sanity. When a length is not specified, the compiler will default
to the default length, which is by default a quarter note unless you specified 
otherwise. Unless you specified the default length as something like 33, which 
will mean that your compiler will complain that DE fault was yours...by default. :-P

Ex. c4 - play the note c as a quarter note
Ex. e-8 - play the note e flat as an eighth note
Ex. c - play the note c with whatever the default note length is
o#

Set the octave.
Where # is the desired octave (0 - 9)
q# 

Note cutoff (stacatto) 
Sets note duration (in eights) of cutoff. Range is 1 - 8 inclusive.
t#

Set the tempo 
Where # = the number of quarter notes per second

Ex. t180
v#

Set the coarse volume, where # is a number between 0 and 15
x68000/mxdrv_mml_mdx_tutorial.1453602858.txt.gz · Last modified: 2019/08/27 20:44 (external edit)