Patterns
Keywords: mma

Subsections

- Defining a Pattern
  - Bass
  - Chord
  - Arpeggio
  - Walk
  - Scale
  - Aria
  - Plectrum
  - Drum
  - Drum Tone
- Including Existing Patterns in New Definitions
- Multiplying and Shifting Patterns

#
Patterns

MMA builds its output based on PATTERNs and SEQUENCEs supplied by you. These can be defined in the same file as the rest of the song data, or can be included (see here) from a library file.

A pattern is a definition for a voice or track which describes what rhythm to play during the current bar. The actual notes selected for the rhythm are determined by the song bar data (see here).

# Defining a Pattern

The formats for the different tracks vary, but are similar enough to confuse the unwary.

Each pattern definition consists of three parts:

- A unique label to identify the pattern. This is case-insensitive. Note that the same label names can be used in different tracks—for example, you could use the name “MyPattern” in both a Drum and Chord pattern ... but this is probably not a good idea. Names can use punctuation characters, but must not begin with an underscore (“_”). The pattern names “z” or “Z” and “-” are also reserved.

- A series of note definitions. Each set in the series is delimited with a “;”.

- The end of the pattern definition is indicated by the end-of-line.

In the following sections definitions are shown in continuation lines; however, it is quite legal to mash all the information onto a single line.

The following concepts are used when defining a pattern:

Start
  When to start the note. This is expressed as a beat offset. For example, to start a note at the start of a bar you use “1”, the second beat would be “2”, the fourth “4”, etc. You can easily use off-beats as well: The “and” of 2 is “2.5”, the “and ahh” of the first beat is “1.75”, etc. Using a beat offset greater than the number of beats in a bar or less than “0” is not permitted. Please note that offsets in the range “0” to “.999” will actually be played in the previous bar using the chord specified at beat 1 of the current bar (this can be useful in Jazz charts, and it will generate a warning!).4.1 See TIME (here).

  The offset can be further modified by appending a note length (see the duration chart, below). If you want to specify an offset in the middle of the first beat you can use “1.5” or “1+8”. The latter means the first beat plus the value of an eight note. This notation is quite useful when generating “swing” sequences. For example, two “swing eights” chords on beat one would be notated as: “1 81 90; 1+81 82 90”.

  You can subtract note lengths as well, but this is rarely done. And, to make your style files completely unreadable, you can even use note length combinations. So, yes, the following pattern is fine:4.2

  Chord Define C1 2-81+4 82 90

Duration
  The length of a note is somewhat standard musical notation. Since it is impractical to draw in graphical notes or to use fractions (like 1/4) MMA , uses a shorthand notation detailed in the following table:

  > Notation | Description
  > 1 | Whole note
  > 2 | Half
  > 4 | Quarter
  > 8 | Eighth
  > 81 | The first of a pair of swing eights
  > 82 | The second of a pair of swing eights
  > 16 | Sixteenth
  > 32 | Thirty-second
  > 64 | Sixty-fourth
  > 3 | Eight note triplet
  > 43 | Quarter note triplet
  > 23 | Half note triplet
  > 6 | Sixteenth note triplet
  > 5 | Eight note quintuplet
  > 0 | A single MIDI tick
  > ddT | dd MIDI ticks.

  The “81” and “82” notations represent the values of a pair of eighth notes in a swing pair. These values vary depending on the setting of SWINGMODE SKEW, see here.

  The note length “0” is a special value often used in drum tracks where the actual “ringing”length appears to be controlled by the MIDI synth, not the driving program. Internally, a “0” note length is converted to a single MIDI tick.

  Lengths can have a single or double dot appended. For example, “2.” is a dotted half note and “4..” adds an eight and sixteenth value to a quarter note.

  Note lengths can be combined using “+”. For example, to make a dotted eight note use the notation “8+16”, a dotted half “2+4”, and a quarter triplet “3+3”.

  Note lengths can also be combined using a “-”. For example, to make a dotted half you could use “1-4”. Subtraction might appear silly at first, but is useful in generating a note just a bit shorter than its full beat. For example, “1-0” will generate a note 1 MIDI tick shorter than a whole note. This can be used in generating breaks in sustained tones.4.3

  It is permissible to combine notes with “dots”, “+”s and “-”s. The notation “2.+4” would be the same as a whole note.

  A number of special tuplet values (ie, 3, 6, 5) have been hard-coded into the above table. However, it is easy to use others. Just specify the note in the ratio format “Count:Base” where “Count” is the number of divisions and “Base” is a note duration from the above table (ie, 2, 4, 8, etc.). So, an eight note triplet could be set as “3:4” (there are 3 eight note triplets in a quarter) or a whole note divided into 5 would be “5:1”. The “Base” value cannot be a MIDI tick value or be dotted. It is possible to create tuplet values which are not playable and/or permitted in standard musical notation. Ratio tuplets can be added, subtracted and dotted.

  The actual duration given to a note will be adjusted by the ARTICULATE value here).

  In special cases you might want to forget all standard duration conventions and specify the length of a note or chord in MIDI ticks. Just append a single “t” or “T” to end of the value. For example, a quarter note duration can be set with a “4” or “192t”. Using MIDI values can simplify the creation of odd-length beats.

  When using MIDI tick values you cannot use “+”, “-” or “.” to combine or modify the value.

Volume
  The MIDI velocity4.4 to use for the specified note.

  For a detailed explanation of how MMA calculates the volume of a note, see here. Without going into a lot of detail, we recommend a moderate velocity so that MMA has some room to make the note louder or softer. If you create a pattern with all your velocities set to 127 it will be impossible for MMA to increase them when it encounters a DYNAMIC command. Most of the files in the standard library use velocities in the range 50 to 100.

  MIDI velocities are limited to the range 0 to 127. However, MMA does not check the volumes specified in a pattern for validity.4.5

Patterns can be defined for BASS, WALK, CHORD, ARPEGGIO and DRUM tracks. All patterns are shared by the tracks of the same type—Chord-Sus and Chord-Piano share the patterns for Chord. As a convenience, MMA will permit you to define a pattern for a sub-track, but remember that it will be shared by all similar tracks. For example:

Drum Define S1 1 0 50

and

Drum-woof Define S1 1 0 50

Will generate identical outcomes.4.6

##
Bass

A BASS pattern is defined with:

Position Duration Offset Volume ; ...

Each group consists of an beat offset for the start point, the note duration, the note offset and volume.

The note offset is one of the digits “1” through “7”, each representing a note of the chord scale. So, if you want to play the root and fifth in a traditional bass pattern you'd use “1” and “5” in your pattern definition.

The note offset can be modified by appending a single or multiple set of “+” or “-” signs. Each “+” will force the note up an octave; each “-” forces it down. This modifier is handy in creating bass patterns when you wish to alternate between the root note and the root up an octave ... but users will find other interesting patterns. There is no limit to the number of “+”s or “-”s. You can even use both together if you're in a mood to obfuscate.

The note offset can be further modified with a single accidental “#”, “&”, “B” or “b”. This modifier will raise or lower the note by a semitone.4.7 In the boogie-woogie library file a “6#” is used to generate a dominant 7th.

Bass Definition
Bass Define Broken8 1 8 1 90 ; \ 2 8 5 80 ; \ 3 8 3 90 ; \ 4 8 1+ 80
Sheet Music Equivalent

This example defines 4 bass notes (probably staccato eight notes) at beats 1, 2, 3 and 4 in a 4/4 time bar. The first note is the root of the chord, the second is the fifth; the third note is the third; the last note is the root up an octave. The volumes of the notes are set to a MIDI velocity of 90 for beats 1 and 3 and 80 for beats 2 and 4.

MMA refers to note tables to determine the “scale” to use in a bass pattern. Each recognized chord type has an associated scale. For example, the chord “Cm” consists of the notes “c”, “e and “g”; the scale for this chord is “c, d, e, f, g, a, b”.

Due to the ease in which specific notes of a scale can be specified, BASS tracks and patterns are useful for much more than “bass” lines! These tracks are useful for sustained string voices, interesting arpeggio and scale lines, and counter melodies.

##
Chord

A CHORD pattern is defined with:

Position Duration Volume1 Volume2 ...; ...

Each group consists of an beat offset for the start point, the note duration, and the volumes for each note in the chord. If you have fewer volumes than notes in a chord, the last volume will apply to the remaining notes.

Chord Definition
Chord Define Straight4+3 1 4 100 ; \ 2 4 90 ; \ 3 4 100 ; \ 4 3 90 ; \ 4.3 3 80 ; \ 4.6 3 80
Sheet Music Equivalent

This example defines a 4/4 pattern in a quarter, quarter, quarter, triplet rhythm. The quarter notes sound on beats 1, 2 and 3; the triplet is played on beat 4. The example assumes that you have C major for beats 1 and 2, and G major for 3 and 4.

Using a volume of “0” will disable a note. So, you want only the root and fifth of a chord to sound, you could use something like:

Chord Define Dups 1 8 90 0 90 0; 3 8 90 0 90 0

## Arpeggio

An ARPEGGIO pattern is defined with:

Position Duration Volume ; ...

The arpeggio tracks play notes from a chord one at a time. This is quite different from chords where the notes are played all at once—refer to the STRUM directive (here).

Each group consists of an beat offset, the note duration, and the note volume. You have no choice as to which notes of a chord are played (however, they are played in alternating ascending/descending order.4.8)

The volume is applied to the specified note in the pattern.

Arpeggio Definition
Arpeggio Define 4s 1 4 100; \ 2 4 90; \ 3 4 100; \ 4 4 100
Sheet Music Equivalent

This example plays quarter notes on beats 1, 2, 3 and 4 of a bar in 4/4 time.

## Walk

A WALKing Bass pattern is defined with:

Position Duration Volume ; ...

Walking bass tracks play up and down the first part of a scale, paying attention to the “color”4.9 of the chord. Walking bass lines are very common in jazz and swing music. They appear quite often as an “emphasis” bar in marches.

Each group consists of an beat offset, the note duration, and the note volume. MMA selects the actual note pitches to play based on the current chord (you cannot change this).

Walking Bass Definition
Walk Define Walk4 1 4 100 ; \ 2 4 90; \ 3 4 90

This example plays a bass note on beats 1, 2 and 3 of a bar in 3/4 time.

## Scale

A SCALE pattern is defined with:

Position Duration Volume ; ...

Each group consists of an beat offset for the start point, the note duration, and volume.

Scale Definition
Scale Define S1 1 1 90 Scale Define S4 S1 * 4 Scale Define S8 S1 * 8

This example defines three scale patterns: “S1” is just a single whole note, not that useful on its own, but it is used as a base for “S4” and “S8”.

“S4” is 4 quarter notes and “S8” is 8 eight notes. All the volumes are set to a MIDI velocity of 90.

Scale patterns are quite useful in endings. More options for scales detailed in the SCALEDIRECTION (here) and SCALETYPE (here) sections.

## Aria

An ARIA pattern is defined with:

Position Duration Volume ; ...

much like a scale pattern. Please refer to the the ARIA section (here) for more details.

## Plectrum

An PLECTRUM pattern is defined with:

Position Strum Volume1 Volume2 ...; ...

Note the absence of a duration setting. For details, please refer to the the PLECTRUM section (here) for more details.

##
Drum

Drum tracks are a bit different from the other tracks discussed so far. Instead of having each track saved as a separate MIDI track, all the drum tracks are combined onto MIDI track 10.

A Drum pattern is defined with:

Position Duration Volume; ...

Drum Definition
Drum Define S2 1 0 100; \ 2 0 80 ; \ 3 0 100 ; \ 4 0 80

This example plays a drum sound on beats 1, 2, 3 and 4 of a bar in 4/4 time. The MIDI velocity (volume) of the drum is 100 on beats 1 and 3; 80 on beats 2 and 4.

This example uses the special duration of “0”, which indicates 1 MIDI tick.

##
Drum Tone

Essential to drum definitions is the TONE directive.

When a drum pattern is defined it uses the default “note” or “tone” which is a snare drum sound. But, this can (and should) be changed using the TONE directive. This is normally issued at the same time as a sequence is set up (see sequences).

TONE is a list of drum sounds which match the sequence length. Here's a short, concocted example (see the library files for many more):

Drum Define S1 1 0 90 Drum Define S2 S1 * 2 Drum Define S4 S1 * 4 SeqClear SeqSize 4 Drum Sequence S4 S2 S2 S4 Drum Tone SnareDrum1 SideKick LowTom1 Slap

Here the drum patterns “S2” and “S4” are defined to sound a drum on beats 1 and 3, and 1, 2, 3 and 4 respectively (see DefMult for details on the “*” option). Next, a sequence size of 4 bars and a drum sequence are set to use this pattern. Finally, MMA is instructed to use a SnareDrum1 sound in bar 1, a SideKick sound in bar 2, a LowTom1 in bar 3 and a Slap in bar 4. If the song has more than four bars, this sequence will be repeated.

In most cases you will probably use a single drum tone name for the entire sequence, but it can be useful to alternate the tone between bars.

To repeat the same “tone” in a sequence list, use a single “/”.

The “tone” can be specified with a MIDI note value or with a symbolic name. For example, a snare drum could be specified as “38” or “SnareDrum1”. The Drumnames appendix lists all the defined symbolic names.

It is possible to substitute tone values. See TONETR.

# Including Existing Patterns in New Definitions

When defining a pattern, you can use an existing pattern name in place of a definition grouping. For example, if you have already defined a chord pattern (which is played on beats 1 and 3) as:

Chord Define M13 1 4 80; 3 4 80

you can create a new pattern which plays on same beats and adds a single push note just before the third beat:

Chord Define M1+3 M13; 2.5 16 80 0

A few points to note:

- the existing pattern must exist and belong to the same track,

- the existing pattern is expanded in place,

- it is perfectly acceptable to have several existing definitions, just be sure to delimit each with a “;”,

- the order of items in a definition does not matter, each will be placed at the correct position in the bar.

This is a powerful shortcut in creating patterns. See the included library files for examples.

#
Multiplying and Shifting Patterns

Since most pattern definitions are, internally, repetitious, you can create complex rhythms by multiplying a copy of an existing pattern. For example, if you have defined a pattern to play a chord on beats 1 though 4 (a quarter note strum), you can easily create a similar pattern to play eighth note chords on beats 1, 1.5, etc. though 4.5 with a command like:

Track Define NewPattern OldPattern * N

where “Track” is a valid track name (“Chord”, “Walk”, “Bass”, “Arpeggio” or “Drum”, as well as “Chord2” or “DRUM3”, etc.).

The “*” is absolutely required.

“N” can be any integer value between 2 and 100.

Multiply Define
Drum Define S1 1 1 100 Drum Define S13 S1 * 2 Drum Define S1234 S1 * 4 Drum Define S8 S1234 * 2 Drum Define S16 S8 * 2 Drum Define S32 S16 * 2 Drum Define S64 S1 * 64

In this example a Drum pattern is defined which plays a drum tone on beat 1 (assuming 4/4 time). Then a new pattern, “S13”, is created. This is the old “S1” multiplied by 2. This new pattern will play a tone on beats 1 and 3.

Next, “S1234” is created. This plays 4 notes, one the each beat.

Note the definition for “S64”: “S32” could have been multiplied by 2, but, for illustrative purposes, “S1” has been multiplied by 64—same result either way.

When MMA multiplies an existing pattern it will (usually) do what you expect. The start positions for all notes are adjusted to the new positions; the length of all the notes are adjusted (quarter notes become eighth notes, etc.). No changes are made to note offsets or volumes.

This example shows how to get a swing pattern which might be useful on a snare drum.

Swing Beat Drum Definition
Begin Drum Define SB8 1 2+16 90 ; 3.66 4+32 80 SB8 SB8 * 4 End
Sheet Music Equivalent, Normal Notation Sheet Music Equivalent, Actual Rhythm

To see the effects of multiplying patterns, create a simple test file and process it though MMA with the “-p” option.

Even cooler4.10 is combining a multiplier, and existing pattern and a new pattern all in one statement. The following is quite legal (and useful):

Drum Define D1234 1 0 90 * 4

which creates drum hits on beats 1, 2, 3 and 4.

More contrived (but examples are needed) is:

Drum Define Dfunny D1234 * 2; 1.5 0 70 * 2

If you're really interested in the result, run MMA with the “-p” option with the above definition.

An existing pattern can be modified by shifting it a beat, or portion of a beat. This is done in a MMA definition with the SHIFT directive. This example shows a triplet pattern created to play on beat 1, and then a second pattern played on beat 3.

Shift Pattern Definition
Chord Define C1-3 1 3 90; \ 1.33 3 90; 1.66 3 90
Chord Define C3-3 C1-3 Shift 2

Note that the shift factor can be a negative or positive value. It can be fractional. Just be sure that the factor doesn't force the note placement to be less than 1 or greater than the TIME setting.

And, just like the multiplier discussed earlier you can shift patterns as they are defined. And shifts and multipliers can be combined. So, to define a series of quarter notes on the offbeat you could use:

Drum Define D1234' 1 0 90 * 4 Shift .5

which would create the same pattern as the longer:

Drum Define D1234' 1.5 1 90; 2.5 1 90; 3.5 1 90; 4.5 1 90

#### Footnotes

... warning!).4.1
  The exception is that RTIME may move the chord back into the bar.
... fine:4.2
  The start offset is the value of the first of a pair of swing eights plus a quarter before the second beat.
... tones.4.3
  See the supplied GROOVE “Bluegrass” for an example.
... velocity4.4
  MIDI “note on” events are declared with a “velocity” value. Think of this as the “striking pressure” on a piano.
... validity.4.5
  This is a feature that you probably don't want to use, but if you want to ensure that a note is always sounded use a very large value (e.g., 1000) for the volume. That way, future adjustments will maintain a large value and this large value will be clipped to the maximum permitted MIDI velocity.
... outcomes.4.6
  What really happens is that this definition is stored in a slot named “DRUM”.
... semitone.4.7
  Be careful using this feature ... certain scales/chords may return non-musical results.
... order.4.8
  See the DIRECTION command (here).
... “color”4.9
  The color of a chord are items like “minor”, “major”, etc. The current walking bass algorithm generates acceptable (uninspired) lines. If you want something better there is nothing stopping you from using a RIFF to over-ride the computer generated pattern for important bars.
... cooler4.10
  In this case the word “cool” substitutes for the more correct “useful”.