--- /dev/null
+;;;; This file is part of LilyPond, the GNU music typesetter.
+;;;;
+;;;; Copyright (C) 1998--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
+;;;; Jan Nieuwenhuizen <janneke@gnu.org>
+;;;; Neil Puttock <n.puttock@gmail.com>
+;;;; Carl Sorensen <c_sorensen@byu.edu>
+;;;;
+;;;; LilyPond is free software: you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation, either version 3 of the License, or
+;;;; (at your option) any later version.
+;;;;
+;;;; LilyPond is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;;; GNU General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
+
+;; TODO: should link back into user manual.
+
+(define (mm-rest-child-list music)
+ "Generate events for multimeasure rests,
+to be used by the sequential-iterator"
+ (let ((location (ly:music-property music 'origin))
+ (duration (ly:music-property music 'duration)))
+ (list (make-music 'BarCheck
+ 'origin location)
+ (make-event-chord (cons (make-music 'MultiMeasureRestEvent
+ 'origin location
+ 'duration duration)
+ (ly:music-property music 'articulations)))
+ (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 (make-time-signature-set music)
+ "Set context properties for a time signature."
+ (let* ((arguments (ly:music-property music 'time-signature-arguments))
+ (num (car arguments))
+ (den (cadr arguments))
+ (rest (caddr arguments))
+ (fraction (cons num den)))
+ (list (descend-to-context
+ (context-spec-music
+ (make-apply-context
+ (lambda (context)
+ (let* ((time-signature-settings
+ (ly:context-property context 'timeSignatureSettings))
+ (my-base-fraction
+ (base-fraction fraction time-signature-settings))
+ (my-beat-structure
+ (if (null? rest)
+ (beat-structure my-base-fraction
+ fraction
+ time-signature-settings)
+ rest))
+ (beaming-exception
+ (beam-exceptions fraction time-signature-settings))
+ (new-measure-length (ly:make-moment num den)))
+ (ly:context-set-property!
+ context 'timeSignatureFraction fraction)
+ (ly:context-set-property!
+ context 'baseMoment (fraction->moment my-base-fraction))
+ (ly:context-set-property!
+ context 'beatStructure my-beat-structure)
+ (ly:context-set-property!
+ context 'beamExceptions beaming-exception)
+ (ly:context-set-property!
+ context 'measureLength new-measure-length))))
+ 'Timing)
+ 'Score))))
properties)
(new-line->lily-string))))
+(define-display-method TimeSignatureMusic (expr parser)
+ (let* ((arguments (ly:music-property expr 'time-signature-arguments))
+ (num (car arguments))
+ (den (cadr arguments))
+ (rest (caddr arguments)))
+ (if (null? rest)
+ (format #f
+ "\\time ~a/~a~a"
+ num den
+ (new-line->lily-string))
+ (format #f
+ "#(set-time-signature ~a ~a ~a)~a"
+ num den rest
+ (new-line->lily-string)))))
+
;;; \melisma and \melismaEnd
(define-extra-display-method ContextSpeccedMusic (expr parser)
"If expr is a melisma, return \"\\melisma\", otherwise, return #f."
#f))))
;;; \time
-(define-extra-display-method ContextSpeccedMusic (expr parser)
- "If `expr' is a time signature set, return \"\\time ...\".
-Otherwise, return #f. Note: default grouping is not available."
- (with-music-match
- (expr (music
- 'ContextSpeccedMusic
- element (music
- 'ContextSpeccedMusic
- context-type 'Timing
- element (music
- 'SequentialMusic
- elements ?elts))))
- (and
- (> (length ?elts) 2)
- (with-music-match ((cadr ?elts)
- (music 'PropertySet
- symbol 'baseMoment))
- #t)
- (with-music-match ((caddr ?elts)
- (music 'PropertySet
- symbol 'measureLength))
- #t)
- (with-music-match ((car ?elts)
- (music 'PropertySet
- value ?num+den
- symbol 'timeSignatureFraction))
- (if (eq? (length ?elts) 3)
- (format
- #f "\\time ~a/~a~a"
- (car ?num+den) (cdr ?num+den) (new-line->lily-string))
- (format
- #f "#(set-time-signature ~a ~a '(<grouping-specifier>))~a"
- (car ?num+den) (cdr ?num+den) (new-line->lily-string)))))))
+;(define-extra-display-method ContextSpeccedMusic (expr parser)
+; "If `expr' is a time signature set, return \"\\time ...\".
+;Otherwise, return #f. Note: default grouping is not available."
+; (with-music-match
+; (expr (music
+; 'ContextSpeccedMusic
+; element (music
+; 'ContextSpeccedMusic
+; context-type 'Timing
+; element (music
+; 'SequentialMusic
+; elements ?elts))))
+; (and
+; (> (length ?elts) 2)
+; (with-music-match ((cadr ?elts)
+; (music 'PropertySet
+; symbol 'baseMoment))
+; #t)
+; (with-music-match ((caddr ?elts)
+; (music 'PropertySet
+; symbol 'measureLength))
+; #t)
+; (with-music-match ((car ?elts)
+; (music 'PropertySet
+; value ?num+den
+; symbol 'timeSignatureFraction))
+; (if (eq? (length ?elts) 3)
+; (format
+; #f "\\time ~a/~a~a"
+; (car ?num+den) (cdr ?num+den) (new-line->lily-string))
+; (format
+; #f "#(set-time-signature ~a ~a '(<grouping-specifier>))~a"
+; (car ?num+den) (cdr ?num+den) (new-line->lily-string)))))))
;;; \bar
(define-extra-display-method ContextSpeccedMusic (expr parser)
in a part.")
(tempo-unit ,ly:duration? "The unit for the metronome count.")
(text ,markup? "Markup expression to be printed.")
+ (time-signature-arguments ,list? "The arguments to a time-signature call.")
(to-relative-callback ,procedure? "How to transform a piece of music
to relative pitches.")
(tonic ,ly:pitch? "Base of the scale.")
;; TODO: should link back into user manual.
-(define (mm-rest-child-list music)
- "Generate events for multimeasure rests,
-to be used by the sequential-iterator"
- (let ((location (ly:music-property music 'origin))
- (duration (ly:music-property music 'duration)))
- (list (make-music 'BarCheck
- 'origin location)
- (make-event-chord (cons (make-music 'MultiMeasureRestEvent
- 'origin location
- 'duration duration)
- (ly:music-property music 'articulations)))
- (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 . (time-scaled-music music-wrapper-music general-music))
))
+ (TimeSignatureMusic
+ . ((description . "Set a new time signature")
+ (iterator-ctor . ,ly:sequential-iterator::constructor)
+ (elements-callback . ,make-time-signature-set)
+ (types . (general-music time-signature-music))
+ ))
+
(TransposedMusic
. ((description . "Music that has been transposed.")
(iterator-ctor . ,ly:music-wrapper-iterator::constructor)
'("lily-library.scm"
"file-cache.scm"
"define-event-classes.scm"
+ "define-music-callbacks.scm"
"define-music-types.scm"
"output-lib.scm"
"c++.scm"
1))
;; # of dots is equal to the 1 in bitwise representation (minus 1)!
(dots (1- (logcount (* times children))))
- ;; The remaining missing multiplicator to scale the notes by
+ ;; The remaining missing multiplicator to scale the notes by
;; times * children
(mult (/ (* times children (ash 1 dots)) (1- (ash 2 dots))))
(shift (- (ly:intlog2 (floor mult))))
;;; 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."
- (make-beam-rule-time-signature-set num den '()))
+ (make-music 'TimeSignatureMusic
+ 'time-signature-arguments
+ (list num den '())))
;;; Used for calls that include beat-grouping setting
(define-public (set-time-signature num den . rest)
"Set properties for time signature @var{num/den}.
If @var{rest} is present, it is used to set
@code{beatStructure}."
- (ly:export (apply make-beam-rule-time-signature-set
- (list num den rest))))
+ (ly:export
+ (make-music 'TimeSignatureMusic
+ 'time-signature-arguments
+ (list num den (if (null? rest) rest (car rest))))))
(define-public (make-beam-rule-time-signature-set num den rest)
"Implement settings for new time signature. Can be