\test "" ##[ \cueDuring #"foo" #1 { c d } #]
\test "" ##[ \quoteDuring #"foo" { c d } #]
+%% \ottava
+\test "" ##[ \ottava #1 #] % OttavaMusic
%% end test.
'pitch (pitch-of-note pitch-note)))
ottava =
-#(define-music-function (parser location octave) (number?)
+#(define-music-function (parser location octave) (integer?)
(_i "Set the octavation.")
- (make-ottava-set octave))
+ (make-music 'OttavaMusic
+ 'ottava-number octave))
overrideTimeSignatureSettings =
#(define-music-function
(define-display-method SkipMusic (skip parser)
(format #f "\\skip ~a" (duration->lily-string (ly:music-property skip 'duration) #:force-duration #t)))
+(define-display-method OttavaMusic (ottava parser)
+ (format #f "\\ottava #~a" (ly:music-property ottava 'ottava-number)))
+
;;;
;;; Notes, rests, skips...
;;;
(origin ,ly:input-location? "Where was this piece of music defined?")
(original-chord ,ly:music? "Original chord of a repeated chord.
Used by repeated chords in \\relative mode, to determine the first note octave")
+ (ottava-number ,integer? "The octavation for @code{\\ottava}.")
(page-break-permission ,symbol? "When the music is at top-level,
whether to allow, forbid or force a page break.")
(make-music 'BarCheck
'origin location))))
+(define (make-ottava-set music)
+ "Set context properties for an ottava bracket."
+ (let ((octavation (ly:music-property music 'ottava-number)))
+
+ (list (context-spec-music
+ (make-apply-context
+ (lambda (context)
+ (let ((offset (* -7 octavation))
+ (string (assoc-get octavation '((2 . "15ma")
+ (1 . "8va")
+ (0 . #f)
+ (-1 . "8vb")
+ (-2 . "15mb")))))
+ (set! (ly:context-property context 'middleCOffset) offset)
+ (set! (ly:context-property context 'ottavation) string)
+ (ly:set-middle-C! context))))
+ 'Staff))))
+
(define-public music-descriptions
`(
(AbsoluteDynamicEvent
(types . (general-music event note-grouping-event))
))
+ (OttavaMusic
+ . ((description . "Start or stop an ottava bracket.")
+ (iterator-ctor . ,ly:sequential-iterator::constructor)
+ (elements-callback . ,make-ottava-set)
+ (types . (general-music ottava-music))
+ ))
+
(OverrideProperty
. ((description . "Extend the definition of a graphical object.
(make-procedure-with-setter ly:prob-property
ly:prob-set-property!))
+(define-public ly:context-property
+ (make-procedure-with-setter ly:context-property
+ ly:context-set-property!))
+
(define-public (music-map function music)
"Apply @var{function} to @var{music} and all of the music it contains.
(make-music 'PropertyUnset
'symbol sym))
-(define-public (make-ottava-set octavation)
- (let ((m (make-music 'ApplyContext)))
- (define (ottava-modify context)
- "Either reset middleCPosition to the stored original, or remember
-old middleCPosition, add OCTAVATION to middleCPosition, and set
-OTTAVATION to `8va', or whatever appropriate."
- (if (number? (ly:context-property context 'middleCOffset))
- (let ((where (ly:context-property-where-defined context 'middleCOffset)))
- (ly:context-unset-property where 'middleCOffset)
- (ly:context-unset-property where 'ottavation)))
-
- (let* ((offset (* -7 octavation))
- (string (assoc-get octavation '((2 . "15ma")
- (1 . "8va")
- (0 . #f)
- (-1 . "8vb")
- (-2 . "15mb")))))
- (ly:context-set-property! context 'middleCOffset offset)
- (ly:context-set-property! context 'ottavation string)
- (ly:set-middle-C! context)))
- (set! (ly:music-property m 'procedure) ottava-modify)
- (context-spec-music m 'Staff)))
-
-(define-public (set-octavation ottavation)
- (ly:export (make-ottava-set ottavation)))
-
;;; Need to keep this definition for \time calls from parser
(define-public (make-time-signature-set num den)
"Set properties for time signature NUM/DEN."