Function summary
ambitus-field-fenv sequence ambitus-low ambitus-range &key (chord-ambitus 13) section
chord->line sequence position
chord-multiplication chord1 chord2
close-variations sequence &key (transposition 0) (ambitus 0) (invert? 0) (append? nil)
fenv->pitches fenv n
fenv-transpose-pitch sequence fenv &rest args
invert-in-ambitus sequence
line->chord sequence chord &key (position :top) flat section
make-is-trill-length? length
pc->pitch pc octave
pcs->chord pcs &optional (octave 4)
pitch->pc pitch
pitch-retrograde-omn sequence &key (flat t)
pitches->fenv pitches
pitches->integers->fenv pitches
set-ambitus interval sequence &key section omn flat
spectra-transpositions-fitting-in-scale spectra scale
stretch-pitches pitches factor &key (round t)
stretch-pitches2 number chord factor &key (round t)
thomassen-accents sequence &optional (format :omn)
trill-selected-notes sequence test &key (interval 2) (ignore-articulations '(marc))
pc->pitch   pc octave  [Function]

Converts the pitch class `pc' into an OMN pitch in the given `octave'.


    (pc->pitch 1 4) 
     => cs4 
pcs->chord   pcs &optional (octave 4)  [Function]

Expects a list of pitch class integers and returns an Opusmodus chord symbol.


    (pcs->chord '(0 4 7)) 
     => c4e4g4 
pitch->pc   pitch  [Function]

Converts the OMN pitch `pitch' into a pitch class integer

chord-multiplication   chord1 chord2  [Function]

Boulez's multiplication of chords. The intervals of `chord1' are built over every pitch of `chord2'.


Over every pitch of the C-major triad (chord2) the fifths of chord1 is created.

    (chord-multiplication '(d4 a4) '(c4 e4 g4)) 


Boulez, Pierre (1963) Musikdenken heute. Schott's Söhne, Mainz.

stretch-pitches   pitches factor &key (round t)  [Function]

Proportional streching/shrinking of intervals.


  • pitches: list of Opusmodus pitches

  • factor (integer, float or fraction): Factor by which all but the first `pitches' are stretched or shrunk.

  • round: whether or not to round the result to semitones. Must be T for now, but in future when Opusmodus supports microtonal music this might be refined.


    (stretch-pitches '(c4 e4 g4) 2) 
     (stretch-pitches '(c4 e4 g4) 1.5) 
     (stretch-pitches '(c4 e4 g4) 2/3)   


Boulez, Pierre (1963) Musikdenken heute. Schott's Söhne, Mainz.

stretch-pitches2   number chord factor &key (round t)  [Function]

Creates `number' derivates from chord following a procedure suggested by Giacomo Manzoni where the chord intervals are systematically stretched or shrunk.


  • number (int): number of chords to generate.

  • chord: list of Opusmodus pitches

  • factor (integer, float or fraction): controls the interval between resulting chord pitches. If 1, the first chord interval is increased by 1 semitone, the second by 2 and so on. If 2, the first interval is increased by 2 semitones, the second by 4 etc.


    (stretch-pitches2 5 '(c4 e4 g4) 1) 
     (stretch-pitches2 5 '(c4 e4 g4) 1.5) 


Series of conferences by Giacomo Manzoni at Fiesole (Florence, Italy) School of Music from 26th of June to 1st of July, 1988.

spectra-transpositions-fitting-in-scale   spectra scale  [Function]

Function for generating a chord/spectral domain. Returns all transpositions of the given spectral that fit in the given scale (i.e., all their pitch classes are contained in the scale).


  • spectra (OMN chords): a list of untransposed spectra

  • scale (OMN pitch list)

pitches->fenv   pitches  [Function]

Translates a sequence of pitches into a fenv that linearily inerpolates between the pitches. Fenv values encode pitches by their corresponding MIDI note.

pitches->integers->fenv   pitches  [Function]

Variant of pitches->fenv where pitches are first translated into transposition intervals before turning them into fenvs.

fenv->pitches   fenv n  [Function]

Translates a fenv into a sequence of pitches. Fenv values encode pitches by their corresponding MIDI note.

fenv-transpose-pitch   sequence fenv &rest args  [Function]

Transposes pitches in sequence by their corresponding fenv value.


  • sequence: (possibly nested) list of pitches or OMN expression

  • fenv: a fenv that ranges over the full sequence; mapping of notes to fenv value by position in sequence (not temporal position); intervals are specified in semitones; intervals are rounded to their closes integer All arguments of pitch-transpose-n are supported as well.


    (fenv-transpose-pitch '(c4 c4 g4 g4) (fenv:linear-fenv (0 0) (1 2))) 
     => (c4 cs4 gs4 a4) 

    (fenv-transpose-pitch '(c4 c4 g4 g4) (fenv:linear-fenv (0 0) (1 2)) :ambitus '(d4 a4)) 
     => (d4 eb4 gs4 a4) 

    (fenv-transpose-pitch '((q c4 e c4 g4) (h g4)) (fenv:linear-fenv (0 0) (1 2))) 
     => ((q c4 e cs4 gs4) (h a4)) 
pitch-retrograde-omn   sequence &key (flat t)  [Function]

My version of pitch-retrograde that is working until the original is fixed for OMN expressions with flattened input.

set-ambitus   interval sequence &key section omn flat  [Function]

This function is similar to the build-in function `ambitus-field', but this function only compresses or expandes a given sequence without transposing it (the originally lowest pitch remains unchanged). Therefore, instead of a range only an interval is specified (by an integer).


  • interval (int): resulting ambitus interval.

  • sequence: OMN sequence, can be nested.

  • section (list of ints or nil): sublists (bars) to process. Arg is ignored if `flat' is T.

  • flat (Boolean): whether or not a flat list is processed.

  • omn (Boolean): whether or not to force OMN style output.


    (set-ambitus 12 '(q bb4 a4 c5 b4)) 

If interval is a negative number, the formerly lowest pitch becomes the highest pitch (the music is inverted).

    (set-ambitus -12 '(q bb4 a4 c5 b4)) 

Special case: if interval is 0, then the original sequence is returned (instead of forcing all pitches to the same note).

    (set-ambitus 0 '(q bb4 a4 c5 b4)) 
invert-in-ambitus   sequence  [Function]

Inverts the pitches of given sequence by preserving its original overall ambitus (instead of inverting around its first pitch or some given pitch).


    (invert-in-ambitus '(c4 e4 g4)) 
     => (g4 eb4 c4) 

Contrast: `pitch-invert' inverts around first note of `sequence'.

    (pitch-invert '(c4 e4 g4)) 
     => (c4 gs3 f3) 

Processing of full OMN sequences supported.

    (invert-in-ambitus '((q c3 ff snap+gliss q g3 cue) (-e s e3 > pizz gs3 > pizz g3 > pizz e3 > pizz eb3 > pizz gs3 p pizz) (h c4 f pizz))) 
close-variations   sequence &key (transposition 0) (ambitus 0) (invert? 0) (append? nil)  [Function]

This functions conveniently combines several common pitch variation techniques that retain a high degree of recognisability to the original input.

The input `sequence' for this function could be generated, e.g., with the function `alternate-omns' such that more remote variations are controlled with `alternate-omns' and closer variations with the present function.


  • sequence (OMN expression that is either flat, single or double nested): input music. Double nesting is supported to allow for processing sections/motifs that consist of multiple bars.

  • transposition (int, or list of ints): transposition interval of individual resulting motifs/sections

  • ambitus (int, or list of ints): ambitus interval of resulting motifs. The lowest pitch of a motif is not affected by this argument, only its highest pitch, as the lowest pitch change be shifted separately with the transposition interval. Negative values result in an inversion of a motif. If 0, ambitus processing is skipped.

  • invert (0, or 1, or list of such binary numbers): binary numbers indicate whether motifs are inverted or not

  • append? (Boolean): whether or not nested OMN sequences should be appended instead of been combined in a list.

If you need more detailed control (e.g., a section argument for some of the variations), then simply use the original build-in function like pitch-transpose, pitch-invert and ambitus-field (or set-ambitus).


    (setf motif '((q c3 ff snap+gliss q g3 cue) (-e s e3 > pizz gs3 > pizz g3 > pizz e3 > pizz eb3 > pizz gs3 p pizz) (h c4 f pizz))) 

    (close-variations (gen-repeat 3 (list motif)) :transposition '(0 12 2) :invert? '(0 1 0) :append? T) 

    (close-variations (gen-repeat 3 (list motif)) :transposition '(0 1 2) :ambitus '(12 11 10) :append? T) 
trill-selected-notes   sequence test &key (interval 2) (ignore-articulations '(marc))  [Function]

Increases rhythmic interest by subdividing all notes that meet the function test and turning these into a trill.


  • sequence: nested OMN sequence

  • test: function expecting four arguments of a given note, its length, pitch, velocity and articulation.

  • interval: integer specifying size and direction of trill interval (positive is up, negative is down).

  • ignore-articulations: list of articulations not to repeat at inserted notes.


    (trill-selected-notes '((q c4 e e) (q d4 e e)) (make-is-trill-length? 'e)) 
     => ((q c4 mf 1/16 c4 mf 1/16 d4 mf 1/16 c4 mf 1/16 d4 mf) (q d4 mf 1/16 d4 mf 1/16 e4 mf 1/16 d4 mf 1/16 e4 mf)) 

make-is-trill-length?   length  [Function]

[Helper function for trill-selected-notes] Returns a function to be used as `test' argument for function `trill-selected-notes'. The returned function returns true for all notes of the given `length'.

line->chord   sequence chord &key (position :top) flat section  [Function]

Builds `chord' over or under every note in `sequence'.


  • sequence (OMN sequence)

  • chord (OMN chord or list of chords): if a list, the chords are circled through.

  • position (either :top or :bottom): whether the pitches of `sequence' are the top or bottom pitch of the transposed chords.


    (line->chord '(h c4 ten q d4 stacc e4 stacc) 'c4e4g4) 

    (line->chord '((h c4 ten) (q d4 stacc e4 stacc)) 'c4e4g4 :position :bottom :section '(0)) 

Using a list of different chords

    (line->chord '(h c4 ten q d4 stacc e4 stacc) '(c4e4g4bb4 c4e4a4 c4)) 
chord->line   sequence position  [Function]

Transforms chords in `sequence' into single notes, extracting the chord pitch at `position' (or the closest pitch, if there is no pitch at `position').


  • sequence (OMN seq)

  • position (0-based integer)


    (chord->line '((h c4e4g4 q) (h.)) 0) 
ambitus-field-fenv   sequence ambitus-low ambitus-range &key (chord-ambitus 13) section  [Function]

Variant of built-in function `ambitus-field': this function compresses or expanded the pitch range of the given `sequence', and the boundaries how much this compression/expansion happens can be changed over time with fenvs or value lists. This is a useful function for shaping musical results.

Note that a change of ambitus values happens only per sublist (bar), which is not really a restriction, as multiple pitches are required to fill a given range.

If you plan to harmonically revise your music (e.g., with `tonality-map') then you obviously better apply this function before the harmonic revision.


  • sequence (nested OMN expression)

  • ambitus-low (fenv or list of integers or pitches): specifies the evolving lower boundary

  • ambitus-range (fenv, int or list of ints): specifies the evolving distance between the lower and upper boundary

  • chord-ambitus (integer): max interval between lowest and highest tone of chords to restrict chords to playable range for keyboard player.

If the argument section is given, then only `(length section)' samples are taken from ambitus-low ambitus-range (if these are fenvs). In other words, in that case the fenv does not range across the full `sequence', but only the selected sections.


Static ambitus-range

    (ambitus-field-fenv (gen-repeat 4 '((q c4 e4 g4))) 
     		    (fenv:linear-fenv (0 0) (1 12)) 12) 

Evolving range

    (ambitus-field-fenv (gen-repeat 4 '((q c4 e4 g4))) 
     		    (fenv:linear-fenv (0 0) (1 12)) 
     		    (fenv:linear-fenv (0 12) (1 4))) 

Note that the spread of chords is adapted to the given range

    (ambitus-field-fenv (gen-repeat 4 '((q c4e4g4 b4))) 
     		    (fenv:linear-fenv (0 0) (1 12)) 12) 

    (ambitus-field-fenv (gen-repeat 4 '((q c4e4g4 b4))) 
     		    (fenv:linear-fenv (0 0) (1 12)) 7) 

However, the spread intervals within chords is automatically adapted to stay within a keyboard players hands.

    (ambitus-field-fenv (gen-repeat 4 '((q c4e4g4 b4))) 
     		    (fenv:linear-fenv (0 0) (1 12)) 25) 

This setting can be adjusted with the argument `chord-ambitus'

    (ambitus-field-fenv (gen-repeat 4 '((q c4e4g4 b4))) 
     		    (fenv:linear-fenv (0 0) (1 12)) 
     		    25 :chord-ambitus 15) 
thomassen-accents   sequence &optional (format :omn)  [Function]

Expects an OMN sequence (or a different format, see below), and returns a *flat* list of floats representing the associated melodic accent value of each pitch as defined by the Thomassen model.


  • format (keyword): sets the format of `sequence'.

    • :omn - full OMN sequence, possibly nested (though the result will be flat)

    • :pitch - list of OMN pitches, possibly nested

    • :midi - list of MIDI note numbers

Note that no accent values are available for the first two and the last pitch, therefor nil is return for those pitches.


Hack: Quick evaluation: strong melodic accents have an accent value greater than 0.4.

  • Thomassen, J. M. (1982) Melodic accent: Experiments and a tentative model. The Journal of the Acoustical Society of America. 71 (6), 1596–1605.

  • Huron, D. & Royal, M. (1996) What is melodic accent? Converging evidence from musical practice. Music Perception. 489–516.