An important prerequisite for composing music with the aid of computers is that the musical ideas of a composition must be communicated to the computer: OMN provides a notation for music, just as traditional notation does on paper. The immediate question then is: how does OMN work so a composer can express musical ideas? Like traditional notation, OMN expresses musical units such as rhythms and pitches. The Introduction to OMN The Language explains the four elements, indicating:
length as 'q (quarter),
pitch as 'c4,
velocity as mp,
and articulation trem(olo),
in that order.
(q c4 mp trem)
Such a musical unit is expressed between parenthesis to allow a clear distinction between other units:
((q c4 mp trem) (q c5 ff fermata))
Clearly, musical units can be sequenced:
((s a4 d5 fs4 d5 g4 d5) (s a4 d5 fs4 d5 g4 d5) (s a4 d5 cs5 b4 a4 g4) (s fs4 d4 e4 c4 e d4))
To make OMN (and Lisp) do something for you, you type an expression. An expression is simply a list, starting with an opening parenthesis, followed by an number of symbols and finally closed by a close parenthesis:
(gen-retrograde '(s a4 d5 fs4 d5 g4 d5)) => (s d5 g4 d5 fs4 d5 a4)
The expression above is a list. The first element of the list is a function name. The rest of the list are arguments or values to which the function is applied. As Lisp will (try to) evaluate everything you type at it, there must be a way to tell Lisp to take expressions as data. To inform Lisp that you want an expression to be treated as data, quote that expression:
'((s a4 d5 fs4 d5 g4 d5) (s a4 d5 fs4 d5 g4 d5) (s a4 d5 cs5 b4 a4 g4) (s fs4 d4 e4 c4 e d4))
It is just like a quotation in real life: in case we want to say that Paris is the capital of France, we use the word without quotes, but we do use quotes when saying that "paris" has five letters. So, if you want Lisp to see (q c5 ff tr2) as data, let the expression be preceded by a single quote:
'(q c5 ff tr2)
Now, lets try the expression (gen-integer 12) with and without a quote to see the difference. To do that we need to evaluate our expression. Place the curser after the last closing paranthesis ')' and press 'Enter' key. The evluation will display in the Listener panel.
(gen-integer 12) ; returns list of numbers from 0 to 12 => (0 1 2 3 4 5 6 7 8 9 10 11 12)
By the way, an arrow sign (=>) means evaluation, what is written after semicolon is a comment.
'(gen-integer 12) ; is a list with 2 values => (gen-integer 12)
Here are two functions you will find useful during your work:
If you want to process a sequence it is useful to assign that sequence to a variable. SETF allows us to do that. Here the variable is named 'song' and is assigned to a sequence of omn lists:
(setf song '((3e gb6 bb6 db6 gb6 eb6 gb6 db6 gb6 bb5 db6 gb5 bb5) (3e gb5 bb5 db5 gb5 eb5 gb5 db5 gb5 bb4 db5 gb4 bb4) (3e db4 db5 ab4 db5 ab4 ab5 ab4 ab5 eb5 ab5 eb5 eb6) (3e eb5 eb6 ab5 eb6 ab5 ab6 ab5 ab6 db6 ab6 db6 db7)))
After assignment, you can use 'song' to refer to its value.
The function LIST makes lists, as its name says. Lists can have any length, therefore the function LIST takes any number of arguments (data):
(list '(q c4 mp tr2) '(q cs5 f fermata) '(q d6 ff tr2) '(q eb5 p fermata))
As we have assigned the variable named song. We might as well use it in our expression.
(list song song)
Next page OMN Examples
Edited by opmo