X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fmidi.scm;h=11b565ea478ec43fe35f834d73d14c036fa8261d;hb=001ad87ae4b9cccc9588557e4b944b11b8fe05f1;hp=715c8c0e37fc8fa1ddf2d32fb9bfae90f188069e;hpb=17098f34eace028d047ee7f9cd6f81a84e0e7537;p=lilypond.git diff --git a/scm/midi.scm b/scm/midi.scm index 715c8c0e37..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--2007 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) @@ -33,14 +33,12 @@ 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,7 +275,7 @@ 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)) @@ -284,18 +283,17 @@ returns the program of the instrument ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; -(define-public (write-performances-midis performances basename) - (let - loop - ((perfs performances) - (count 0)) - - - (if (pair? perfs) - (begin - (ly:performance-write - (car perfs) - (if (> count 0) - (format #f "~a-~a.midi" basename count) - (format #f "~a.midi" basename))) - (loop (cdr perfs) (1+ count)))))) +(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)))))))