X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=scm%2Fmidi.scm;h=11b565ea478ec43fe35f834d73d14c036fa8261d;hb=1da7272f54aace50b751b7cfa5ac50e5f7f9b12b;hp=ca26e2dfb1780a4a61cd39dc419544a6ff5d997b;hpb=cc442d6c8d1564a78caac37b2ef0c8b9bdc76fbc;p=lilypond.git diff --git a/scm/midi.scm b/scm/midi.scm index ca26e2dfb1..11b565ea47 100644 --- a/scm/midi.scm +++ b/scm/midi.scm @@ -1,8 +1,8 @@ ;;;; midi.scm -- scm midi variables and functions ;;;; ;;;; source file of the GNU LilyPond music typesetter -;;;; -;;;; (c) 2000--2005 Jan Nieuwenhuizen +;;;; +;;;; (c) 2000--2009 Jan Nieuwenhuizen @@ -14,7 +14,7 @@ ;; define factor of total volume per dynamic marking (define-public absolute-volume-alist '()) (set! absolute-volume-alist - (append + (append '( ("sf" . 1.00) ("fffff" . 0.95) @@ -28,19 +28,17 @@ ("pp" . 0.49) ("ppp" . 0.42) ("pppp" . 0.34) - ("ppppp" . 0.25) ) + ("ppppp" . 0.25) ) absolute-volume-alist)) (define-public (default-dynamic-absolute-volume s) - (let ((entry (assoc s absolute-volume-alist))) - (if entry - (cdr entry)))) + (assoc-get s absolute-volume-alist)) ;; define factors of total volume of minimum and maximum volume (define-public instrument-equalizer-alist '()) (set! instrument-equalizer-alist - (append + (append '( ("flute" . (0 . 0.7)) ("oboe" . (0 . 0.7)) @@ -57,9 +55,7 @@ instrument-equalizer-alist)) (define-public (default-instrument-equalizer s) - (let ((entry (assoc s instrument-equalizer-alist))) - (if entry - (cdr entry)))) + (assoc-get s instrument-equalizer-alist)) ;; (name . program+32768*(channel10 ? 1 : 0)) (define instrument-names-alist '()) @@ -103,7 +99,7 @@ ("electric guitar (muted)" . ,(- 29 1)) ("overdriven guitar" . ,(- 30 1)) ("distorted guitar" . ,(- 31 1)) - ("guitar harmo(dinics" . ,(- 32 1)) + ("guitar harmonics" . ,(- 32 1)) ; (33-40 bass) ("acoustic bass" . ,(- 33 1)) @@ -122,7 +118,7 @@ ("contrabass" . ,(- 44 1)) ("tremolo strings" . ,(- 45 1)) ("pizzicato strings" . ,(- 46 1)) - ("orchestral strings" . ,(- 47 1)) + ("orchestral harp" . ,(- 47 1)) ("timpani" . ,(- 48 1)) ; (49-56 ensemble) @@ -259,16 +255,19 @@ 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)))) + (entry (assoc-get inst instrument-names-alist))) + (and entry (>= entry 32768) + entry))) (define-public (midi-program instrument) " returns the program of the instrument " (let* ((inst (symbol->string instrument)) - (entry (assoc inst instrument-names-alist))) - (if entry (modulo (cdr entry) 32768) #f))) + (entry (assoc-get inst instrument-names-alist))) + (if entry + (modulo entry 32768) + #f))) ;; 90 == 90/127 == 0.71 is supposed to be the default value ;; urg: we should set this at start of track @@ -276,4 +275,25 @@ returns the program of the instrument (define-public (alterations-in-key pitch-list) "Count number of sharps minus number of flats" - (/ (apply + (map cdr pitch-list)) 2)) + + (* (apply + (map cdr pitch-list)) 2)) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; + +(define-public (write-performances-midis performances basename . rest) + (let ((midi-ext (ly:get-option 'midi-extension))) + (let + loop + ((perfs performances) + (count (if (null? rest) 0 (car rest)))) + (if (pair? perfs) + (begin + (ly:performance-write + (car perfs) + (if (> count 0) + (format #f "~a-~a.~a" basename count midi-ext) + (format #f "~a.~a" basename midi-ext))) + (loop (cdr perfs) (1+ count)))))))