gramophone2(1)
π gramophone2(1) β GRAMophone II user manual π
versione 0.5.1a Β· 17 Agosto, 2007 Β· bestie edition, no cap
okay so. you found the manual for GRAMophone II, the algorithmic music composition generator, and honestly? it's giving mad scientist energy but in the cutest way possible. this is part one of three, so grab a strawberry drink π and let's get into it.
β¨ NAME β¨
gramophone2 β GRAMophone is an algorithmic generator of music composition. πΆ
β¨ SYNOPSYS β¨
(yes the original spells it like that and we respect the typo era π )
gramophone2 [-c|-d] sourcefile [midifile]
so it's literally: you hand it a sourcefile, and optionally a midifile, and it does its lil music thing. that's the whole vibe.
β¨ OPTIONS β¨
-cβ this one lets you check the syntax of your sourcefile without generating any music at all. like a grammar vibe check, no bops produced. π§-dβ this turns on debug mode, which means you get video output of the composition and player parameters <em>plus</em> the generated notes. so you can literally watch what's happening. obsessed. π
β¨ DESCRIPTION β¨
In GRAMophone, the music gets generated using two kinds of formal grammar:
- Chomsky's regular grammar (or Type 3) β used for a TOP DOWN approach to the composition π¦
- a reduced version of Lindenmayer grammar β used for a BOTTOM UP approach π±
two grammars, two directions, one gorgeous little music machine. periodt.
β¨ BASIC CONCEPT OF GRAMophone β¨
GRAMophone is partly based on an idea of Jon McCormack's, who invented the whole concept of a virtual player (a virtual musician, basically). The player in question is associated with a MIDI track, and it interprets instructions telling it what to do. Generally, those instructions say play notes (i.e. send MIDI messages).
GRAMophone's players together make up an orchestra, which plays a composition. π»πΊπ₯
Any number of players can play a composition, but in practice the hardware you're using might impose an upper limit. (<em>the hardware said "enough" bestie</em> π)
In general every player plays an instrument and each has a different set of grammar rules. An individual player is characterised by a set of parameters which are shared by the whole orchestra and/or a personal parameter set.
The orchestra's parameters consist of:
- the kind of grammar used (Chomsky or Lindenmayer);
- the metronome;
- the measure;
- the number of iterations used in the production process.
Each individual player's parameters consist of:
- the kind of grammar used (Chomsky or Lindenmayer);
- the instrument;
- the MIDI channel associated with the player;
- the number of iterations used in the production process;
A player's notes have a current state consisting of:
- octave
- volume
- duration
- release
These characteristics can be controlled parametrically by a player declaring its associated variables. GRAMophone, then, allows for the non-deterministic generation of music, using either Chomsky or Lindenmayer grammar. π
β¨ GUIDE TO GRAMophone β¨
πΈ "Give Me A" (The "Hello, World!" for GRAMophone")
To introduce you to the basic ideas, here is the simplest algorithmic composition that can be generated with GRAMophone: this composition simply generates the note A and is presented through both the Chomsky and Lindenmayer methods.
composition "Give Me A" of "Schroeder" {
//this composition generates the A note with the Chomsky grammar
grammar chomsky
tempo 120
time_signature 4/4
%
player Schroeder {
instrument 0
%
@composition->A[,,,];
}
}
composition "Give Me A" of "Schroeder" {
//this composition generates the A note with the Lindenmayer grammar
grammar lindenmayer
tempo 120
time_signature 4/4
%
player Schroeder {
instrument 0
%
axiom->A[,,,];
}
}
look at her. two whole compositions, one single note, main character energy. π
πΈ THE KEYWORDS composition E of
All compositions must begin with the keyword composition followed by a string (in inverted commas) containing the name of the composition. This must be followed by the keyword of, then another string containing the copyright of the piece.
πΈ THE COMPOSITION BLOCK
The composition block is placed in brackets. It is subdivided into three sections:
- one section defines parameters of the composition,
- one declares and initiates any global variables,
- an orchestra section where the players who will 'play' the piece are defined.
The first two sections are separated by the % symbol. π
πΈ THE player KEYWORD
Each player is defined with the keyword player, followed by an identifier.
πΈ THE player BLOCK
The player block is placed in brackets and is divided into three sections:
- one section defines the parameters of the track associated with the player,
- one declares any local variables for the player,
- one is for the formal rules.
The first two sections are separated by the % symbol.
πΈ COMMENTS
In GRAMophone, comments are C-like: they must begin with the character pair /* and end with the character pair */. There must be no space between the asterisk and the slash. Everything between these pairs of symbols will be ignored by the GRAMophone parser.
Whole lines of comments may also be included. Lines of comments begin with the symbol // and end at the end of the line, as in the two initial examples. β¨
πΈ Section defining the composition's parameters
The parameters shared by all the orchestra's players are declared here. The parameters that may be declared are:
grammarresolutioniterationstempotime_signature
This section must end with the % symbol.
π± grammar
This parameter is obligatory and defines the kind of grammar to be used in the generation. This can be either chomsky or lindenmayer.
π± resolution
This parameter defines the number of time units of 1/4 duration. If omitted, the default value 480 will be used.
π± iterations
This parameter defines the number of iterations contained in the generation. Its meaning depends on the kind of grammar chosen, as explained below. If omitted, the default value 1 will be used.
π± tempo
This parameter defines the composition's rhythm. If omitted, the default value 120 will be used.
π± time_signature
This parameter defines the composition's measure. If omitted, the default value 4/4 will be used.
πΈ Section declaring the composition's global variables
The variables control the parameters of a note's attributes, as explained below.
πΈ Section defining the player's parameters
Each player's personal parameters and variables are declared here. The personal parameters that may be declared are:
instrumentchanneliterations
This section must end with the % symbol.
π instrument
This parameter indicates the player's instrument type. GRAMophone's instrument set is the same as that of General MIDI. The acceptable range of values is 0 to 127; there are therefore 128 instruments to choose from. A table showing the instrument codes appears below:
0Piano1Brite Piano2HammerPiano3Honkey Tonk4New Tines5Digital Piano6Harpsichord7Clavi8Celesta9Glocken10Music Box11Vibes12Marimba13Xylophon14Tubular Bell15Santur16Full Organ17Percussive Organ18BX-3 Organ19Church Organ20Positive21Musette22Harmonica23Tango24Classic Guitar25Acoustic Guitar26Jazz Guitar27Clean Guitar28Mute Guitar29Overdrive Guitar30Distorted Guitar31Harmonics32Jazz Bass33Deep Bass34Pick Bass35Fretless Bass36Slap Bass 137Slap Bass 238Syntethized Bass 139Syntethized Bass 240Violin41Viola42Cello43Contra Bass44Tremolo String45Pizzicato46Harp47Timpani48Marcato49Slow String50Analog Pad51String Pad52Choir53Doo Voice54Voices55Orchestra Hit56Trumpet57Trombone58Tuba59Mute Trumpet60French Horn61Brass Section62Synthetized Brass 163Synthetized Brass 264Soprano Sax65Alto Sax66Tenor Sax67Baritone Sax68Sweet Oboe69English Horn70Bassoon Oboe71Clarinet72Piccolo73Flute74Recorder75Pan Flute76Bottle77Shakhukuhachi78Whistle79Ocarina80Square Lead81Saw Lead82Caliope Lead83Chiff Lead84Charang Lead85Air Chorus86Rezzo4ths87Bass & Lead88Fantasia89Warm Pad90Poly Synth Pad91Ghost Pad92Bowed Pad93Metal Pad94Halo Pad95Sweep Pad96Ice Rain97Soundtrack98Crystal99Atmosphere100Brightness101Goblin102Echo Drop103Star Theme104Sitar105Banjo106Shamisen107Koto108Kalimba109Scotland110Fiddle111Shanai112Metal Bell113Agogo114Steel Drums115Wood Blok116Taiko Drum117Melodic Tom118Synth Tom119Reverse Cymbal120Fret Noise121Noise Chiff122Seashore123Birds124Telephone125Helicopter126Stadium!!127Gunshot
If omitted, the default instrument value 0 is used.
π channel
This parameter defines which Midi channel will be associated with the player. There are 16 possible channels. Channel 10 is reserved for percussion instruments. If omitted, the default channel value 1 is used.
π iterations
This parameter defines the number of iterations in the generation. Its meaning depends on the kind of grammar chosen, as explained below. If the iterations parameter has been included in the composition declarations, the latter declaration will be ignored.
π«Ά heads up bestie β that's a real rule, not me being dramatic. if it's already up in the composition declarations, the one down here gets ignored. that's just what the manual says.
πΈ Section declaring the player's local variables
The variables control the parameters of a note's attributes, as explained below.
πΈ Notes in GRAMophone πΈ
β¨ HOW NOTES ARE WRITTEN DOWN IN GRAMophone β¨
Okay bestie, notes are the first category of terminal symbols in GRAMophone. First ones, the OGs. π
GRAMophone uses the English notation for notes:
A B C D E F G
The names of notes must be written in capital letters, okay? Not optional, not negotiable. And the flat and sharp symbols are represented by b and # respectively β and like, no space should appear between these symbols and the name of the note: A#, Gb, etc. Zero space. None. Keep them glued together fr fr.
π NOTE ATTRIBUTES π
Notes can have four attributes in GRAMophone: octave, velocity, duration and release. The octave attribute varies between -2 and 8, while the velocity and release attributes vary from 0 to 127.
If the note is written without attributes, then these default values are used: 3 for octave, 64 for velocity and release. And the current default value for duration is a crotchet. π΅
So in the example, "Give me A" is written simply as A[,,,]. That means an A is generated at the third octave, with a duration of 1/4 and a velocity and release of 64. She's simple, she's clean, she ate. π«Ά
π DEFINING THE ATTRIBUTES OF A NOTE π
The attributes of a note are defined by writing them inside the square brackets which follow the name of the note, without spaces. A note can have four attributes at most and each attribute type may have only one value. One value per type, that's the rule bestie.
The attributes must be defined in the following order:
- octave
- velocity
- duration
- release
If all three attributes are not defined, the default value is used for the missing ones. (Yes, the original says three β we don't ask, we just report. π)
Here are some examples of notes with attributes:
C[2, 50+60/2, 240*4,]β plays a C at the second octave, with a velocity of80, duration of960(minim with a resolution of480) and a release of64(default value);Db[4,,,]β plays a D flat at the fourth octave, using the default values for velocity, duration and release;F#[,,,]β use the default values for all the attributes;
Incorrect examples are:
Db[3, 127, 960, 64, x]β too many attributes (xis a variable). Not her trying to sneak a fifth one in π
π¦ PAUSE π¦
Pauses are another category of terminal symbol in GRAMophone. They are indicated by the letter R and only take a duration type attribute. If unspecified, the default resolution value is used. Attributes are defined in the same way as for notes.
Here are some examples of pauses:
R[480/2]β pause with a duration of240;R[]β use the default value for the attribute of type duration.
π CHORDS π
Chords are the final category of terminal symbol used in GRAMophone. A chord is a series of notes played simultaneously. In GRAMophone, notes played in a chord are enclosed between two ^ symbols. Cute little hats, iconic.
Here are some examples of chords:
^C[,,,]E[,,,]G[,,,]^β plays a C major chord, using each note's default values.^A[2,80,240,]C[2,,240,]E[2,,240,]^β plays an A minor chord with duration1/8, with all notes at the second octave and velocity64(default value), with the first note of the chord played with a velocity of80and the remaining two at a velocity of64(default value).
β THE ROLE OF R IN COMPLEX CHORDS β
The notes of a chord do not always have the same duration. For example it is possible that, while the note C[2,,1920,] of duration 4/4 is playing, the musician has to play four crotchets in the following order: C[,,,], E[,,,], G[,,,], Bb[,,,].
There has to be a way of telling GRAMophone that the notes C[2,,1920,] and C[,,,] must start at the same time, that E[,,,] must begin after a pause of 1/4, G[,,,] after 2/4 and Bb[,,,] after 3/4. In GRAMophone this is written as follows:
^C[2,,1920,]C[,,,]R[]E[,,,]R[960]G[,,,]R[1440]Bb[,,,]^
In other words, every note in the chord can be preceded by a pause definition representing the time to wait before playing the note. It does not matter which order you write the notes down in a chord. The chord in the example above can also be written:
^R[]E[,,,]C[2,,1920,]R[1440]Bb[,,,]C[,,,]R[960]G[,,,]^
π IDENTIFIERS π
Some of GRAMophone's language entities β variables, macros and non-terminal symbols in Chomsky grammar for example β must have names by which they can be identified. These names are called identifiers and are chosen by the composer.
GRAMophone's identifiers follow the system of identifiers used in the programming language Pascal. In fact an identifier is made up of a letter followed by a sequence of letters or digits. GRAMophone's identifiers must also be written in lower case. lowercase gang rise up β¨
π Chomsky Grammar π
π₯ NON-TERMINAL SYMBOLS π₯
In Chomsky grammar non-terminal symbols are used to give a structure or 'style' to the musical composition. They are written with an @ immediately followed by an identifier. The Chomsky grammar used by GRAMophone is context free so the head of the production can only be a non-terminal.
π THE NON-TERMINAL SYMBOL @composition π
This non-terminal symbol, which corresponds to the final composition of a single player, is obligatory. You literally cannot skip it bestie.
π PRODUCTION OPERATOR π
This is defined by the character sequence -> and separates the head of the production from the body.
π BODY OF THE PRODUCTION π
This may contain sequences of terminal (notes, pauses and chords) and non-terminal symbols. Each production must end with a semi-colon.
π | (OR) OPERATOR π
A production may be non-deterministic: in other words it may present two or more choices during generation. The body of a non-deterministic production is made up of the various choices separated by the | operator. For example
@non_det->A[,,,]B[,,,]@Seq1|^A[,,,]B[,,,]C[,,,]^@Seq2R[]C[,,,];
is a non-deterministic production. Pick a lane, girl! (affectionate) π
π MEANING OF ITERATION IN CHOMSKY GRAMMAR π
In Chomsky grammar a production may include cycles, i.e. production bodies containing non-terminal symbols that refer to the production actually being produced. For example:
@Sequenza1->B[,,,]A[,,,]C[,,,]@Sequenza1;
To avoid an infinite loop during generation, the non-terminal symbol @Sequenza1 is processed an equal number of times to the iterations parameter. So like, the iterations parameter is the seatbelt here. Wear it. π«Ά
πΈ Lindenmayer Grammar πΈ
Lindenmayer grammar only deals with terminal symbols and GRAMophone's version can be context-free or work in a polyphonic context. Therefore, single notes or chords can appear at the head of the production. All productions are separated by a semi-colon.
π¦ AXIOM π¦
This is the initial production from which generation begins. It is obligatory.
π¦ PRODUCTION OPERATOR π¦
This is defined by the character sequence -> and separates the head of the production from the body.
π¦ | (OR) OPERATOR π¦
A production may be non-deterministic: in other words it may present two or more choices during generation. The body of a non-deterministic production is made up of the various choices separated by the | operator. For example
A[,,,]->A[,,,]B[,,,]|C[,,,]D[,,,];
is a non-deterministic production.
π¦ MEANING OF ITERATIONS IN LINDENMAYER GRAMMAR π¦
At each step all the grammar's productions are simultaneously applied to the note string. In this case the iterations parameter represents the number of steps to be carried out. Simultaneously!! Everyone moves at once, it's giving synchronized swimming. π
β Use of variables β
π DECLARATION AND INITIALISATION OF VARIABLES π
GRAMophone is able to control the attributes of a note parametrically through the use of variables. These variables are declared in the player's declaration section and may be of the following types: octave, velocity, duration and msb.
A variable is declared by writing its type followed by one or more identifiers separated by a comma. The declaration must end with a semi-colon. A player's identifier must be declared only once.
The following are correct declarations:
velocity x, y;
octave oct, z;
duration w;
The following are incorrect declarations:
velocity x, x;
octave z;
duration z;
Following the declaration section and before the grammar it is possible to initialise variables by means of the = operator.
The following is an example of declaration and initialisation:
velocity x;
x=0;
π USING VARIABLES WITH NOTES π
Variables are used in note attribute expressions. GRAMophone controls the types within expressions, so it is not possible to add an octave variable to a velocity variable, for example. No mixing bestie, the types said no. π
The following is an example of a note variable:
velocity x;
duration z, w;
A[4,x,z+w,].
π EXAMPLE π
composition "Crescendo" of "Schroeder" {
//this composition generates 64 A notes with a growing velocity
grammar chomsky
tempo 120
time_signature 4/4
iterations 64
%
player Schroeder {
instrument 40
%
velocity x=0;
@composition->A[,x=x+1,,]@composition;
}
}
π CONDITIONS π
In both Chomsky and Lindenmayer grammars it is possible to define conditions for the variables in the production body. If the condition is true, the production is executed; otherwise it is not. A condition is defined immediately after the name of the production by means of the ? symbol, followed by one or more Boolean expressions.
The Boolean operators are:
!β not&&β and||β or
The relational operators are:
==β uguale!=β diverso<β minore>β maggiore<=β minore o uguale>=β maggiore o uguale
The following is an example of a conditional production.
@battuta?x!=0->A[,x=x-10,,]@battuta;
which means: while x is not equal to zero, generate the @battuta production; otherwise do not.
π Discography, GRAMophone's library π
GRAMophone is able to include external libraries, called discographies. To include a discography in a source file, use the keyword discography followed by its file name. A discography can be included at any point in the source file, as long as its contents match the position of the source where it has been included. Vibes must align, basically. β¨
π Macros π
Macros can be defined using the keyword define, followed by a lower-case identifier and a string placed in inverted commas. Macros must be defined at the beginning of the source composition, before the composition keyword.
For example, in order to simply write a instead of A[,,,], the following macro must be defined: define a "A[,,,]"
π«Ά Functions in GRAMophone π«Ά
π THE repeat() FUNCTION π
The repeat() function takes an msb type value plus a Chomsky or Lindenmayer sequence. It enables the included sequence to be repeated a number of times that is equal to the msb type value.
π THE rand() FUNCTION π
The rand() function takes an expression and returns a random value which is less than the value of the expression.
π Melodic operators in GRAMophone π
Like, the three glow-up operators you can slap onto a sequence, bestie π
transpose() β okay so this one is a whole vibe β¨. You hand it an msb type value plus a Chomsky or Lindenmayer sequence, and it gives you back a sequence where every single note in the relevant sequence has been transposed by a number of semitones equal to that msb type value. That's it, that's the whole thing. Semitones in, shifted notes out, iconic behaviour π
inversion() β this one takes a Chomsky or Lindenmayer sequence π¦. What it spits out is a sequence where the intervals between the first note and the other notes in the sequence taken are calculated in reverse. So yeah, the intervals get flipped. Periodt π
retrograde() β takes a Chomsky or Lindenmayer sequence, no notes, no extra args, she's low maintenance π. It generates a sequence which is the contrary of the sequence you inserted. That's literally the entire description. Do with that what you will π
π AUTHOR π
Giovanni Ferranti <giovanni_at_giovanniferranti_dot_it> π
And that's a wrap on gramophone2(1), bestie π«Ά this whole thing is version 0.5.13a, dated 30 November , 2007, and it's gramophone2(1) β go make something gorgeous with it πΈβ¨ no cap, you got this π
π¦ where this page comes from
- debian bookworm: gramophone2 0.8.13a-3.2
- debian trixie: gramophone2 0.8.13a-3.5
- ubuntu jammy: gramophone2 0.8.13a-3.1ubuntu1
- ubuntu noble: gramophone2 0.8.13a-3.3
- ubuntu resolute: gramophone2 0.8.13a-3.5
- ubuntu stonking: gramophone2 0.8.13a-3.7 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms