[ << Pitches ] | [Top][Contents] | [ Rhythms >> ] |
[ < Forcing a clef symbol to be displayed ] | [ Up : Pitches ] | [ Hiding accidentals on tied notes at the start of a new system > ] |
Generating random notes
This Scheme-based snippet generates random notes. Use as
\randomNotes
n
from
to
dur
to generate n random notes between pitches from and to, with duration dur.
randomNotes = #(define-music-function (n from to dur) (integer? ly:pitch? ly:pitch? ly:duration?) (let ((from-step (ly:pitch-steps from)) (to-step (ly:pitch-steps to))) (make-sequential-music (map (lambda (_) (let* ((step (+ from-step (random (- to-step from-step)))) (pitch (ly:make-pitch 0 step 0))) #{ $pitch $dur #})) (iota n))))) \randomNotes 24 c' g'' 8
[ << Pitches ] | [Top][Contents] | [ Rhythms >> ] |
[ < Forcing a clef symbol to be displayed ] | [ Up : Pitches ] | [ Hiding accidentals on tied notes at the start of a new system > ] |