[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Creating music with Scheme - can this be done in a simpler way?
From: |
Alard de Boer |
Subject: |
Creating music with Scheme - can this be done in a simpler way? |
Date: |
Mon, 9 Jul 2007 21:51:02 +0200 |
Hello list,
I've been working on an arrangement of Mars (from The Planets by
Gustav Holst), which contains many occurrences of the following
rhythm:
\times 2/3 { c8 c c } c4 c4 c8 c8 c4
at various pitches. For this, I tried to create a music function that
takes a pitch and creates this sequence of notes. However, I cannot
seem to find a way to do this using a simple #{ #} substitution
since I cannot "remove" the duration from a note and use my own
durations.
The following works (heavily borrowed from the Tips and Tricks
document), but is there a simpler way to do this?
If not, I will go ahead and add it to the LSR :)
---
\version "2.10.25"
#(define (make-note-req p d)
(make-music 'NoteEvent
'duration d
'pitch p))
#(define (make-note p d)
(make-music 'EventChord
'elements (list (make-note-req p d))))
#(define (seq-music-list elts)
(make-music 'SequentialMusic
'elements elts))
#(define (make-triplet elt)
(make-music 'TimeScaledMusic
'denominator 3
'numerator 2
'element elt))
rhythm = #(define-music-function (parser location note) (ly:music?)
"Make the rhythm in Mars (the Planets) at the given note's pitch"
(let* ((p (ly:music-property
(car (ly:music-property note 'elements))
'pitch)))
(seq-music-list (list
(make-triplet (seq-music-list (list
(make-note p (ly:make-duration 3 0 2 3))
(make-note p (ly:make-duration 3 0 2 3))
(make-note p (ly:make-duration 3 0 2 3))
)))
(make-note p (ly:make-duration 2 0))
(make-note p (ly:make-duration 2 0))
(make-note p (ly:make-duration 3 0))
(make-note p (ly:make-duration 3 0))
(make-note p (ly:make-duration 2 0))
))))
\score {
\new Staff {
\time 5/4
\rhythm c'
\rhythm c''
\rhythm g
}
}
--
Groeten,
Alard.
Ceterum censeo MS Word esse delendam.
- Creating music with Scheme - can this be done in a simpler way?,
Alard de Boer <=