Melrōse

MCP Server

melrose-mcp is a tool that uses the MCP protocol to receive melrōse expressions to play. You install this tool locally on your machine and connect it from an MCP client such as Claude Desktop, Goose, VSC etc.

example

Prompt:

play a tune from Claude Debussy

AI:

I'll create a small segment inspired by Claude Debussy's impressionist style using the Melrose language.

MCP server:

{
    `expression`: `sequence('(F4 A4 D5) 4(F4 A4 D5) (G4 B4 E5) 4(G4 B4 E5) (A4 C5 F5) 4(A4 C5 F5) (G4 B4 E5) 4(G4 B4 E5) (F4 A4 D5) 8= 8(E4 G4 C5) 4(F4 A4 D5)')`
}

See melrose-mcp for details how to install and use it.

Introducing 'map'

The function map is used to create a composition by applying a transformation on each sequence in a collection.

1
2
3
4
5
6
7
a1 = sequence('G_3 D_ G_ A D_5 G_5')
a2 = sequence('D_3 A_3 D_ E A_ D_5')
a3 = sequence('E3 B3 E A_ B E5 ')
a4 = sequence('B2 G_3 B3 E_ G_ B')

c = map( join(a1,a3,a4,a2), fraction(8,resequence('1 4 2 4 3 6 5 4', _ )) )
loop(c)

line 1..4

Four sequences are created that play a nice combination of arpeggios.

More Drum Patterns

Using the notemap function with dots . and bangs ! you can write a pattern for an instrument. In this example, multiple instruments are choosen from the General MIDI set. The note C2 is typically assigned to a Kick drum. The loop plays the 16 beats in a bar and for each bang ! it will shortly (16th) play the note. You can start and stop each loop individually.

Once you have a MIDI capable sound program (such as a DAW) opened then tryout this example with the online Melrōse Playground yourself.

Drum Pattern

This script is an example that uses the Melrōse language to create your own drum beats. Line by line, I will explain how it is composed.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
bpm(85)

// https://usermanuals.finalemusic.com/SongWriter2012Win/Content/PercussionMaps.htm

open = midi(16,46,60)
close = midi(16,42,60)
clap = midi(16,39,60)
kick = midi(16,36,80)

d1 = notemap(' 3 10 11',open)
d2 = notemap('4 12',close)
d3 = notemap('5 13',clap)
d4 = notemap('1 2 4 7 9 10 12 15',kick)
d5 = notemap('16',note('16=')) // 1/16 rest at the end to make 16 notes in the set
set = merge(d1,d2,d3,d4,d5)
lp_set = loop(channel(10, set)) // channel 10 is the general midi for a drumkit

🎶 Play

Iterating over patterns

1
2
3
4
5
6
7
8
9
bpm(90)
s = sequence('c e g b')
i = iterator(
    '(1 2) (3 4)',
    '(1 3) (2 4)', 
    '1 (2 3) 4', 
    '(1 4) (2 3)')
m = resequence(i,s)
l = loop(m,next(i))
🎶 Play

Using resequence you can compose a new sequence with index-based entries. The first compostion played by the loop is (C E) (G B).

DAW - Apple Logic Pro X

logicpro

Logic Pro is a product of Apple Inc.

Goal

Logic Pro is a professional Digital Audio Workstation (DAW) available for Apple Mac OSX. Melrōse can communicate with Logic Pro by sending MIDI messages. Logic Pro has a rich set of sounds and instruments to play MIDI notes. In addition, Logic Pro is able to play multiple MIDI channels simultaneously which can be programmed individualy by melrōse.

This article describes the steps to get Melrōse working with Logic Pro such that you can play your melody per-channel.

DAW - Apple Garageband

garageband

GarageBand is a registered trademark of Apple Inc.

Goal

Garageband is a simple Digital Audio Workstation (DAW) that comes with the standard installation of Apple Mac OSX on devices such as MacBook or MacPro. Melrōse can communicate with GarageaBand by exchanging MIDI messages. GarageBand has a rich set of sounds and instruments to play MIDI notes.

This article describes the steps to get Melrōse working with GarageBand such that you can play your melodies.

Melrōse, a language to program and play music

TL;DR

Melrōse is both a language and a tool to create and listen to music interactively, The language uses musical primitives (note, sequence, chord) and many functions (map, group, transpose) that can be used to create more complex patterns, loops and tracks. Melrōse uses MIDI output to produce sound by any (hard or software) device attached. Melrōse can also react on MIDI inputs to start, record and stop playing musical objects. A plugin is available for Microsoft Visual Studio for the best usage experience. For a quickstart, without any installation, you can use the Melrōse playground.