X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fmidi.scm;h=cf43d3af7592759e5f5887812a1b6f2667665ce1;hb=def21b306e2b8fa2d5630fab0878e9922e197f0c;hp=807a020a3ba4f14af30a779272e06272b28f329f;hpb=69dd6f7e540258550b68fcbc952ac523fd4c6939;p=lilypond.git diff --git a/scm/midi.scm b/scm/midi.scm index 807a020a3b..cf43d3af75 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 +;;;; midi.scm -- scm midi variables and functions +;;;; +;;;; source file of the GNU LilyPond music typesetter +;;;; +;;;; (c) 2000--2007 Jan Nieuwenhuizen @@ -18,17 +18,17 @@ '( ("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)) @@ -56,7 +56,12 @@ ) instrument-equalizer-alist)) -;; (name . program+32768*(channel10 ? 1 : 0) ) +(define-public (default-instrument-equalizer s) + (let ((entry (assoc s instrument-equalizer-alist))) + (if entry + (cdr entry)))) + +;; (name . program+32768*(channel10 ? 1 : 0)) (define instrument-names-alist '()) (set! instrument-names-alist (append @@ -246,38 +251,24 @@ ("mt-32 drums" . ,(+ 32768 127)) ("cm-64 kit" . ,(+ 32768 127)) ("cm-64 drums" . ,(+ 32768 127)) - ) - instrument-names-alist - ) -) - - -(define-public (default-instrument-equalizer s) - (let ((entry (assoc s instrument-equalizer-alist))) - (if entry - (cdr entry)))) - + ) + instrument-names-alist)) (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 inst instrument-names-alist))) + (and entry (>= (cdr entry) 32768)))) (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 inst instrument-names-alist))) + (if entry (modulo (cdr entry) 32768) #f))) ;; 90 == 90/127 == 0.71 is supposed to be the default value ;; urg: we should set this at start of track @@ -285,4 +276,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))))))