Melrōse

interactively programming melodies

View the Project on GitHub

Home

Language

expressions

Musical objects are created, composed and played using the melrõse tool by evaluating expressions. Expressions use any of the predefined functions (creation,composition,audio control). By assigning an expression to a variable name, you can use that expression by its name to compose other objects.

variables

Variable names must start with a non-digit character and can have zero or more characters in [a-z A-Z _ 0-9]. An assignment “=” is used to create a variable. To delete a variable, assign it to the special value “nil”.

comment

Use “//” to add comment, either on a new line or and the end of an expression.

Creation functions

Composition functions

Audio control functions

at

Create an index getter (1-based) to select a musical object.

at(1,scale('E/m')) // => E

begin

Begin loop(s). Ignore if it was running.

lp_cb = loop(sequence('C D E F G A B'))

begin(lp_cb) // end(lp_cb)

biab

Set the Beats in a Bar [1..6]; default is 4.

biab(4)

bpm

Set the Beats Per Minute (BPM) [1..300]; default is 120.

bpm(90)

channel

Select a MIDI channel, must be in [1..16]; must be a top-level operator.

channel(2,sequence('C2 E3')) // plays on instrument connected to MIDI channel 2

chord

Create a Chord from its string notation.

chord('C#5/m/1')

chord('G/M/2')

duration

Creates a new modified musical object for which the duration of all notes are changed. The first parameter controls the length (duration) of the note, e.g. 1=whole, 0.5 or 2 = half, 0.25 or 4 = quarter, 0.125 or 8 = eight, 0.0625 or 16 = sixteenth. .

duration(8,sequence('E F')) // => ⅛E ⅛F , shorten the notes from quarter to eigth

dynamic

Creates a new modified musical object for which the dynamics of all notes are changed. The first parameter controls the emphasis the note, e.g. + (mezzoforte,mf), – (piano,p). .

dynamic('++',sequence('E F')) // => E++ F++

end

End running loop(s). Ignore if it was stopped.

l1 = loop(sequence('C E G'))

begin(l1) // end(l1)

export

Writes a multi-track MIDI file.

export('myMelody-v1',myObject)

go

Play all musical objects together in the background (do not wait for completion).

go(s1,s1,s3) // play s1 and s2 and s3 simultaneously

group

Create a new sequence in which all notes of a musical object are grouped.

group(sequence('C D E')) // => (C D E)

import

Evaluate all the statements from another file.

import('drumpatterns.mel')

interval

Create an integer repeating interval (from,to,by,method). Default method is ‘repeat’, Use next() to get a new integer.

int1 = interval(-2,4,1)

lp_cdef = loop(pitch(int1,sequence('C D E F')), next(int1))

iterator

Iterator that has an array of constant values and evaluates to one. Use next() to increase and rotate the value.

i = iterator(1,3,5,7,9)

		p = pitch(i,note('c'))

		lp = loop(p,next(i))

		

join

Joins two or more musical objects as one.

a = chord('A')

b = sequence('(C E G)')

ab = join(a,b)

joinmap

Creates a new join by mapping elements based on an index (1-based).


loop

Create a new loop from one or more musical objects; must be assigned to a variable.

cb = sequence('C D E F G A B')

lp_cb = loop(cb,reverse(cb))

merge

Merges multiple sequences into one sequence.

m1 = notemap('..!..!..!', note('c2'))

m2 = notemap('4 7 10', note('d2'))

all = merge(m1,m2) // => = = C2 D2 = C2 D2 = C2 D2 = =

midi

Create a Note from MIDI information and is typically used for drum sets. The first parameter is the duration and must be one of {0.0625,0.125,0.25,0.5,1,2,4,8,16}. A duration of 0.25 or 4 means create a quarter note. Second parameter is the MIDI number and must be one of [0..127]. The third parameter is the velocity (~ loudness) and must be one of [0..127].

midi(0.25,52,80) // => E3+

midi(16,36,70) // => 16C2 (kick)

multi

Create a multi-track object from zero or more tracks.

multi(track1,track2,track3) // one or more tracks in one multi-track object

next

Is used to produce the next value in a generator such as random and interval.

i = interval(-4,4,2)

pi = pitch(i,sequence('C D E F G A B'))

lp_pi = loop(pi,next(i))

begin(lp_pi)

note

Create a Note using this format.

note('e')

note('2.e#--')

notemap

Creates a mapper of notes by index (1-based) or using dots (.) and bangs (!).

m1 = notemap('..!..!..!', note('c2'))

m2 = notemap('3 6 9', note('d2'))

octave

Change the pitch of notes by steps of 12 semitones for one or more musical objects.

octave(1,sequence('C D')) // => C5 D5

octavemap

Create a sequence with notes for which the order and the octaves are changed.

octavemap('1:-1,2:0,3:1',chord('C')) // => (C3 E G5)

onbar

Puts a musical object on a track to start at a specific bar.

tr = track("solo",2, onbar(1,soloSequence)) // 2 = channel

pitch

Change the pitch with a delta of semitones.

pitch(-1,sequence('c d e'))

p = interval(-4,4,1)

pitch(p,note('c'))

play

Play all musical objects.

play(s1,s2,s3) // play s3 after s2 after s1

print

Prints the musical object when evaluated (play,go,loop).


progression

Create a Chord progression using this format.

progression('E F') // => (E A♭ B) (F A C5)

progression('(C D)') // => (C E G D G♭ A)

random

Create a random integer generator. Use next() to generate a new integer.

num = random(1,10)

next(num)

record

Create a recorded sequence of notes from the current MIDI input device.

r = record() // record notes played on the current input device and stop recording after 5 seconds

s = r.S() // returns the sequence of notes from the recording

repeat

Repeat the musical object a number of times.

repeat(4,sequence('C D E'))

replace

Replaces all occurrences of one musical object with another object for a given composed musical object.

c = note('c')

d = note('d')

pitchA = pitch(1,c)

pitchD = replace(pitchA, c, d) // c -> d in pitchA

reverse

Reverse the (groups of) notes in a sequence.

reverse(chord('A'))

scale

Create a Scale using this format.

scale(1,'E/m') // => E F G A B C5 D5

sequence

Create a Sequence using this format.

sequence('C D E')

sequence('(8C D E)') => (C D E)

sequence('c (d e f) a =')

sequencemap

Creates a mapper of sequence notes by index (1-based).

s1 = sequence('C D E F G A B')

i1 = sequencemap('6 5 4 3 2 1',s1) // => B A G F E D

i2 = sequencemap('(6 5) 4 3 (2 1)',s1) // => (B A) G F (E D)

track

Create a named track for a given MIDI channel with a musical object.

track("lullaby",1,sequence('C D E')) // => a new track on MIDI channel 1

undynamic

Set the dymamic to normal for all notes in a musical object.

undynamic('A+ B++ C-- D-') // =>  A B C D

ungroup

Undo any grouping of notes from one or more musical objects.

ungroup(chord('E')) // => E G B

ungroup(sequence('(C D)'),note('E')) // => C D E
generated by dsl-md.go