]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/midi.scm
* Merge from stable:
[lilypond.git] / scm / midi.scm
index 46cb81c803e412000f430a46c454a2ff53356c24..79ffe5846af555bbbb998ab1879d64c5a74e80d5 100644 (file)
@@ -2,7 +2,7 @@
 ;;;
 ;;;  source file of the GNU LilyPond music typesetter
 ;;; 
-;;; (c) 2000--2001 Jan Nieuwenhuizen <janneke@gnu.org>
+;;; (c) 2000--2002 Jan Nieuwenhuizen <janneke@gnu.org>
 
 
 ;; define factor of total volume per dynamic marking
@@ -26,7 +26,7 @@
        )
       absolute-volume-alist))
 
-(define (default-dynamic-absolute-volume s)
+(define-public (default-dynamic-absolute-volume s)
   (let ((entry (assoc s absolute-volume-alist)))
     (if entry
        (cdr entry))))
 )
 
 
-(define (default-instrument-equalizer s)
+(define-public (default-instrument-equalizer s)
   (let ((entry (assoc s instrument-equalizer-alist)))
     (if entry
        (cdr entry))))
 
-;; returns whether the instrument should use midi channel 9
-(define (percussion-p instrument)
+
+(define-public (percussion? instrument)
+  "
+returns whether the instrument should use midi channel 9
+"
   (let* ((inst  (symbol->string instrument))
          (entry (assoc inst instrument-names-alist))
        )
      (and entry (>= (cdr entry) 32768))
   )
 )
-
-;; returns the program of the instrument
-(define (midi-program instrument)
+(define-public (midi-program instrument)
+"
+returns the program of the instrument
+"
   (let* ((inst  (symbol->string instrument))
          (entry (assoc inst instrument-names-alist))
        )
 
 ;; 90 == 90/127 == 0.71 is supposed to be the default value
 ;; urg: we should set this at start of track
-(define dynamic-default-volume 0.71)
+(define-public dynamic-default-volume 0.71)
 
-;; Count number of sharps minus number of flats
-(define (accidentals-in-key pitch-list)
+(define-public (accidentals-in-key pitch-list)
+  "Count number of sharps minus number of flats"
   (apply + (map cdr pitch-list)))
 
-;; Characterise the key as major if the alteration of the 
-;; third scale note is the same as that of the main note
-;; Note: MIDI cannot handle other tonalities than major/minor.
-(define (major-key pitch-list)
-  (eq? (cdr (list-ref pitch-list 4)) (cdr (list-ref pitch-list 6))))
+(define-public (major-key pitch-list)
+  "Characterise the key as major if the alteration of the 
+third scale note is the same as that of the main note.
+Note: MIDI cannot handle other tonalities than major/minor.
+"
+  ;; This charactersition is only true for a scale that starts at `c'.
+  (if (not (equal? (car pitch-list) '(0 . 0)))
+      (begin
+       (ly:warn "Attempt to determine tonality of transposed scale")
+       #t)
+  (eq? (cdr (list-ref pitch-list 4)) (cdr (list-ref pitch-list 6)))))