X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fmidi.scm;h=11b565ea478ec43fe35f834d73d14c036fa8261d;hb=001ad87ae4b9cccc9588557e4b944b11b8fe05f1;hp=ed82a5a525c2e56aef6db4f71c9b5f6f07742978;hpb=d983c03ae234308c7b284f42e00aff40fd93e14c;p=lilypond.git diff --git a/scm/midi.scm b/scm/midi.scm index ed82a5a525..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--2004 Jan Nieuwenhuizen +;;;; +;;;; (c) 2000--2009 Jan Nieuwenhuizen @@ -14,33 +14,31 @@ ;; 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) - ("ffff" . 0.91) - ("fff" . 0.81) - ("ff" . 0.71) - ("f" . 0.61) - ("mf" . 0.50) - ("mp" . 0.40) - ("p" . 0.30) - ("pp" . 0.20) - ("ppp" . 0.10) - ("pppp" . 0.08) - ("ppppp" . 0.05) + ("ffff" . 0.92) + ("fff" . 0.85) + ("ff" . 0.80) + ("f" . 0.75) + ("mf" . 0.68) + ("mp" . 0.61) + ("p" . 0.55) + ("pp" . 0.49) + ("ppp" . 0.42) + ("pppp" . 0.34) + ("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)) @@ -56,6 +54,9 @@ ) instrument-equalizer-alist)) +(define-public (default-instrument-equalizer s) + (assoc-get s instrument-equalizer-alist)) + ;; (name . program+32768*(channel10 ? 1 : 0)) (define instrument-names-alist '()) (set! instrument-names-alist @@ -98,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)) @@ -117,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) @@ -249,26 +250,24 @@ ) instrument-names-alist)) -(define-public (default-instrument-equalizer s) - (let ((entry (assoc s instrument-equalizer-alist))) - (if entry - (cdr entry)))) - (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)))) + (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)))))))