]> git.donarmstrong.com Git - lilypond.git/blob - scm/midi.scm
patch::: 1.3.143.jcn1
[lilypond.git] / scm / midi.scm
1 ;;; midi.scm -- scm midi variables and functions
2 ;;;
3 ;;;  source file of the GNU LilyPond music typesetter
4 ;;; 
5 ;;; (c) 2000--2001 Jan Nieuwenhuizen <janneke@gnu.org>
6
7
8 ;; define factor of total volume per dynamic marking
9 (define absolute-volume-alist '())
10 (set! absolute-volume-alist
11       (append 
12       '(
13         ("sf" . 1.00)
14         ("fffff" . 0.95)
15         ("ffff" . 0.91)
16         ("fff" . 0.81)
17         ("ff" . 0.71)
18         ("f" . 0.61)
19         ("mf" . 0.50)
20         ("mp" . 0.40)
21         ("p" . 0.30)
22         ("pp" . 0.20)
23         ("ppp" . 0.10)
24         ("pppp" . 0.08)
25         ("ppppp" . 0.05)
26         )
27       absolute-volume-alist))
28
29 (define (default-dynamic-absolute-volume s)
30   (let ((entry (assoc s absolute-volume-alist)))
31     (if entry
32         (cdr entry))))
33
34 ;; define factors of total volume of minimum and maximum volume
35 (define instrument-equaliser-alist '())
36 (set! instrument-equaliser-alist
37       (append 
38        '(
39          ("flute" . (0 . 0.7))
40          ("oboe" . (0 . 0.7))
41          ("clarinet" . (0 . 0.7))
42          ("bassoon" . (0 . 0.6))
43          ("french horn" . (0.1 . 0.7))
44          ("trumpet" . (0.1 . 0.8))
45          ("timpani" . (0.2 . 0.9))
46          ("violin" . (0.2 . 1.0))
47          ("viola" . (0.1 . 0.7))
48          ("cello" . (0.2 . 0.8))
49          ("contrabass" . (0.2 . 0.8))
50          )
51        instrument-equaliser-alist))
52
53 (define (default-instrument-equaliser s)
54   (let ((entry (assoc s instrument-equaliser-alist)))
55     (if entry
56         (cdr entry))))
57
58 ;; 90 == 90/127 == 0.71 is supposed to be the default value
59 ;; urg: we should set this at start of track
60 (define dynamic-default-volume 0.71)
61
62 ;; Count number of sharps minus number of flats
63 (define (accidentals-in-key pitch-list)
64   (apply + (map cdr pitch-list)))
65
66 ;; Characterise the key as major if the alteration of the 
67 ;; third scale note is the same as that of the main note
68 ;; Note: MIDI cannot handle other tonalities than major/minor.
69 (define (major-key pitch-list)
70   (eq? (cdr (list-ref pitch-list 4)) (cdr (list-ref pitch-list 6))))