[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: template for a "simple" theory exercise randomizer
From: |
Aaron Hill |
Subject: |
Re: template for a "simple" theory exercise randomizer |
Date: |
Sun, 31 Jul 2022 13:18:03 -0700 |
On 2022-07-31 12:48 pm, Aaron Hill wrote:
On 2022-07-31 12:00 pm, Kieren MacMillan wrote:
Thanks for any help you can give!
Here is something I threw together quickly... Hope it offers some
inspiration:
And here is a better and more readable version:
(Why I had all those unnecessary Scheme<->LilyPond escapes is beyond
me...)
%%%%
\version "2.22.0"
createExercise =
#(define-scheme-function
(clef key root)
(symbol? ly:pitch? ly:pitch?)
#{ \markup \score {
\layout { indent = 0 }
\new Staff {
\omit Score.TimeSignature
\clef #(symbol->string clef)
\key $key \major $root 1 \bar "||"
}
} #})
randomElement =
#(define-scheme-function
(list-of-elements) (list?)
(list-ref list-of-elements
(random (length list-of-elements))))
scaleDegreesFor =
#(define-scheme-function
(key) (ly:pitch?)
(music-pitches (ly:music-transpose
#{ { c' d' e' f' g' a' } #} key)))
clefKeys.treble = { bes b c' des' d' ees' e' f' fis' g' aes' a' }
clefKeys.bass = { f, fis, g, aes, a, bes, b, c des d ees e }
\markup \wordwrap {
#@(map (lambda _
(let* ((clefKey (randomElement clefKeys))
(clef (car clefKey))
(keys (music-pitches (cdr clefKey)))
(key (randomElement keys))
(scaleDegrees (scaleDegreesFor key))
(root (randomElement scaleDegrees)))
(createExercise clef key root))
) (iota 24))
}
%%%%
-- Aaron Hill
exercise.cropped.png
Description: PNG image