Mod Tracking on 9front

Let's write a little chiptune using the tools at
http://runjimmyrunrunyoufuckerrun.com/src/mod.tgz

SAMPLE
First we need some samples.  The easiest way is to open an existing
song in mod/track, find a sample you like, and press r to rip it to
disk, or R to rip all samples to a dir.  This is generally tolerated
by artists so long as it's not a melody or vocal or something and you
are doing your own thing with it and not ripping a whole track or
song.  Another way is to take a sample you already have as a .wav or
something and convert it to the required format with mod/sample.
For a chiptune, it's easy enough to make our own samples.

EDSAMP
Run mod/edsamp, which gives us a 128KB blank slate in which to craft a
sample.  First press ↓ once to zoom out, so that the line at the
bottom reads vis [00000,00040), ie we can see the first 64 bytes of
the available space.  Now click in the middle of the screen with mouse
button 3 and drag all the way to the right, so that the whole window
is purple and the line at the bottom reads sel [00000,00040), ie the
first 64 bytes are selected.

Press 6 and hit enter at the prompts to add a triangle wave to the
selection.  The mnemonic for wave forms is: ~ sine, ^ triangle, / ramp
(saw), because those characters look kind of like the waveforms, but
the same keys work whether or not shift is held down.  If you want to
make a square wave, enter exponent 0 for any form.  You can experiment
with different shapes and parameters, pressing Backspace in between to
clear the selection, but I'll stick with the triangle.

The waveform that appears is shaded grey because it is not part of the
sample.  Press (lowercase) s and the waveform will go black and the
top row should read sample [00000,00040).  If we play this back we'll
just hear a quick blip; we need to loop our sample.  Press (uppercase)
S and the waveform will go dark purple and the top row should read
replen 40.  Samples are played straight through once, then if replen
is greater than 2 it is looped between rep and rep + replen.

Press Space and you will hear the triangle wave.  Press Esc or Enter
to stop playback.  The top row tells us playback is at note C-2 +0,
which means C natural in the second octave with finetune 0.  You can
cycle the octave by pressing Tab, change the finetune by pressing t
and entering a number between -8 and +7, and change the note with the
following pseudo-keyboard layout:

key:          y       u           o       p       [
key:      g       h       j   k       l       ;       '
note:     C   C♮  D   D♮  E   F   F♮  G   G♮  A   A♮  B

Write the sample to disk by pressing w and giving it a name.  The
repeat information is not saved, so it is pre-filled into the filename
prompt, but 0 and 40 are easy to remember, so let's just call it tri.

Now let's try a chord (okay, a ditone).  Press Backspace to clear the
selection and create two waveforms on top of each other, one with 2
cycles and one with 3, both with amplitude 0.5: I chose a sine and a
saw.  Now you have a root note and a perfect fifth: read up on
Pythagorean tuning to extend the concept.  Save this sample as chord.

Finally, let's make some percussive sounds.  We don't want to loop
these, so drag with mouse button 3 all the way to the left to set the
selection to 0, then press S and the top row should read replen 0.
Press ↓ a few times to zoom out to, say, vis [00000,01000) and extend
the selection to the whole screen again, pressing Backspace to clear
any data you had hanging around, and s to set the new sample length.

Press r to read data from disk.  You might do this to read in other
samples, perhaps created by mod/sample or ripped from other mods, or
even any old file you have on hand.  A good noise source is
/dev/random, so type that and hit enter for the rest of the prompts.
Play back the noise at some different frequencies to see what it
sounds like.

To make it a little more interesting, press a to change the amplitude
envelope.  Leave start amplitude at 1.0 and set end amplitude to 0.
Use an exponent like 0.3 to give the envelope some curve.  That sounds
better!  we can use this at a high frequency for hihats and low
frequency for a snare: let's save this sample as drum.

For fun, press x to invert the selection and get a woosh instead of a
crash.  You can experiment a lot to try to get the perfect drum sound
by mixing tones and noise.  Ideally the period of the drum tone should
rapidly decrease along with the volume: I may add a "stretch" function
to edsamp to make this easier...  but you can also bend the pitch and
volume of samples in the tracker, which is how we will make our kick
drum, so let's see what we can achieve with just these three samples.

TRACK
Run mod/track and press s to load a sample into the first slot.  Type
tri at the first prompt, then hit enter for the rest of the prompts,
except repeat length, where we will enter 40.  Press g and a C-2 note
will be entered in the first track and sequenced.  Press ↑ to return
to the first row and hit Space: the pattern will be played back.
Press Space again to interrupt playback.

In the first row again type 2a0, which is an effect bending the pitch
down very rapidly.  You can't bend below C-1.  Listen to the pattern
again: not a bad kick drum!  and it can double as a bass pedal.  Press
Backspace (cut) and then Esc (paste) to snarf this cell, then press ↓
to move down and paste in rows 07 and 0A.  Press ^A to jump to the top
and Space to listen back.

Press + to make sample slot 02 active and then s to load our drum
sample, leaving repeat length 0 this time.  Move to row 04 and press
g, then again on row 0C.  Now we have a kick-snare pattern like this:

00 01 C-2 2A0
01 -- --- ---
02 -- --- ---
03 -- --- ---
04 02 C-2 ---
05 -- --- ---
06 -- --- ---
07 01 C-2 2A0
08 -- --- ---
09 -- --- ---
0A 01 C-2 2A0
0B -- --- ---
0C 02 C-2 ---
0D -- --- ---
0E -- --- ---
0F -- --- ---

On row 00 select "block" from the mouse button 3 menu and enter 10 for
"rows" and 1 for "cols" to snarf our work so far.  Move to row 10 and
select "paste block" from the mouse button 2 menu, then repeat on rows
20 and 30.  Return to row 00 and listen.

Press → to move to track 2.  We are going to stay with sample 2 but
play it at a higher frequency.  Press tab and the display should read
"oct 3" in the bottom right.  Press ' (apostrophe) and at B-3 our
sample sounds like a passable high hat, but it is too loud: press ↑
then c1c to set the volume a bit lower.  Now press Backspace to cut
this note, then select "fill down" from the button 2 menu to fill the
track with it.  So much for drums!

Move to track 4, row 00, press + to move to the next sample slot, and
load our chord sample with volume 10 and repeat length 40.  The
F5..F12 buttons set the scroll distance to 1..8 to make it easier to
move around, so press F12 because we're only going to enter four notes
for this track.  Press Tab until you are in octave 2 again, then press
g ↓ k ↓ l ↓ g and return to row 00.  Press F5 to set the scroll
distance to 1 again.  Now add some tremolo: type 742, press ↓, type
700, select "effect" from the button 3 menu, then "fill down" from the
button 2 menu.  Listen back.

Let's add another pattern: press Insert to increase the song length to
02.  Since we are at the end of the song, this also increases the
sequence position to 01.  Move to track 1, row 00, and select "block"
from the button 3 menu.  Snarf 40 rows and 4 cols, ie the whole
pattern.  Press PgUp to change the pattern associated with this
sequence position to 01, then "paste block".

We'll turn our triangle into a saw lead for the second pattern.
Select samp 04 and load tri again but this time set the sample name to
lead, volume to 10, rep to 10, and replen to 20.  Move to track 3, row
00, set the scroll distance to 2 (F6), and enter a melody.  Notice
that because we set the scroll distance, every second row is skipped:
let's finish by filling that space with an echo.  Jump to row 00 and
snarf track 3 (40 rows, 1 col), then hit F5, move to row 03, and hit
F6 again.  Fill, block paste, and transpose only affect the row they
are invoked on and every scroll distance row after that, so by pasting
the block on an odd row with scroll distance set to 2 we won't clobber
our nice melody but replicate it a few rows later.

To make the echo sound better we want it to be at a lower volume, so
get back to row 03 and type c0c, then select "effect" from the button
3 menu.  Make sure that the scroll distance is set to 2 (F6) and "fill
down".  As a final touch, give the even rows some attack: get to row
00 and type A30, hit F6 and "fill down".

Press End and ^A to jump back to the first row of the first sequence
and listen to the whole song.  Well, it's a start!  Give the song a
title by pressing t, then press w to write the mod to disk.  You
should have ended up with something like the tut.mod included in the
tarball.  You can delete the samples now: they are saved in the mod.

DECODE
To play the mod back without firing up the tracker, you can:

mod/decode <tut.mod >/dev/audio

There is a patch included to make this work with play(1).  Of course,
if you want to share the magic with the unenlightened, you can:

mod/decode <mysong.mod | dd -conv swab | audio/mp3enc -r >mysong.mp3

From here, read the manpage, decipher some good mods for inspiration,
and practice.  Have fun!

umbraticus
