Skip to content

Mod

The Mod class contains many functions for modifying, or varying, Phrases, Parts and Scores. Each of these functions modifies the data passed to them. For example, the Mod.repeat() function creates repetitions of the given musical material:

Mod.repeat(phrase, 41)

This will modify phrase to contain a total of 41 copies of the original musical material.

Creating a Mod

Mod is a static utility; you don't instantiate it like other objects. Call its methods on the class itself. For example,

Mod.fadeIn(score)

Functions

The following Mod functions are always available:

Volume

The following functions modify the volume (or dynamic) of notes in a phrase, part, or score:

Function Description
Mod.accent(material, meter) Make certain beats of each measure louder, in place.
Mod.compress(material, ratio) Squeeze or stretch the loudness range of the notes, in place.
Mod.crescendo(material, startTime, endTime, startVolume, endVolume) Slide the volume smoothly from one level to another over a span of time, in place.
Mod.fadeIn(material, fadeLength) Fade the music up from silence to its normal volume, in place.
Mod.fadeOut(material, fadeLength) Fade the music down from its normal volume to silence, in place.
Mod.normalize(material) Scale every note's volume up so the loudest note reaches the maximum, in place.

Duration

The following functions modify the duration of notes in a phrase, part, or score.

Function Description
Mod.append(material1, material2) Add the second material onto the end of the first, in place.
Mod.elongate(material, scaleFactor) Stretch or squeeze every note's length by a scaling factor, in place.
Mod.changeLength(phrase, newLength) Stretch or squeeze a phrase so it lasts a set number of beats, in place.
Mod.cycle(phrase, numberOfNotes) Repeat a phrase until it holds a set number of notes, in place.
Mod.palindrome(material) Double the music by adding a reversed copy of itself onto the end, in place.
Mod.repeat(material, times) Repeat the music a set number of times, in place.
Mod.quantize(material, quantum) Round note start times and durations to a grid, in place.

NOTE: Use cycle() when you wish to fit a particular length. Use repeat() when you wish to repeat a particular number of times, regardless of length. When repeating overlapping phrases of different lengths, cycle() will guarantee they all end at approximately the same time.

Pitch

The following functions modify the pitches of notes in a phrase, part, or score.

Function Description
Mod.invert(phrase, pitchAxis) Flip the pitches of a phrase around a center pitch, in place.
Mod.transpose(material, steps) Shift the pitch of every note, in place.
Mod.retrograde(material) Reverse the order of the notes, in place.
Mod.rotate(phrase) Shift the notes around the phrase, in place.

Panning

| Mod.bounce(material) | Pan notes hard left and right, alternating from note to note, in place. |

Randomness

The following functions use randomness to modify notes in a phrase, part, or score.

Function Description
Mod.shuffle(material) Randomly reorder the notes, in place.
Mod.mutate(phrase) Randomly change one note's pitch and one note's duration, in place.
Mod.randomize(material, pitchAmount) Nudge each note's pitch, duration, and volume by random amounts, in place.
Mod.shake(material) Randomly vary the notes' volumes for an uneven, human feel, in place.
Mod.spread(material) Randomly pan the notes for an even spread across the stereo field, in place.

Other Functions

Here are some other mod functions:

Function Description
Mod.consolidate(part) Merge all of a part's phrases into a single phrase, in place.
Mod.fillRests(material) Replace each note-then-rest with one longer note, in place.
Mod.merge(material1, material2) Combine the second material into the first so they sound together, in place.
Mod.shift(material, time) Move every phrase's start time earlier or later, in place.
Mod.tiePitches(material) Join neighboring notes of the same pitch into one longer note, in place.
Mod.tieRests(material) Join neighboring rests into one longer rest, in place.