]> git.donarmstrong.com Git - lilypond.git/blob - scm/midi.scm
patch::: 1.3.136.jcn2
[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         ("ffff" . 0.91)
15         ("fff" . 0.81)
16         ("ff" . 0.71)
17         ("f" . 0.61)
18         ("mf" . 0.50)
19         ("mp" . 0.40)
20         ("p" . 0.30)
21         ("pp" . 0.20)
22         ("ppp" . 0.10)
23         )
24       absolute-volume-alist))
25
26 (define (default-dynamic-absolute-volume s)
27   (let ((entry (assoc s absolute-volume-alist)))
28     (if entry
29         (cdr entry))))
30
31 ;; define factors of total volume of minimum and maximum volume
32 (define instrument-equaliser-alist '())
33 (set! instrument-equaliser-alist
34       (append 
35        '(
36          ("flute" . (0 . 0.7))
37          ("oboe" . (0 . 0.7))
38          ("clarinet" . (0 . 0.7))
39          ("bassoon" . (0 . 0.6))
40          ("french horn" . (0.1 . 0.7))
41          ("trumpet" . (0.1 . 0.8))
42          ("timpani" . (0.2 . 0.9))
43          ("violin" . (0.2 . 1.0))
44          ("viola" . (0.1 . 0.7))
45          ("cello" . (0.2 . 0.8))
46          ("contrabass" . (0.2 . 0.8))
47          )
48        instrument-equaliser-alist))
49
50 (define (default-instrument-equaliser s)
51   (let ((entry (assoc s instrument-equaliser-alist)))
52     (if entry
53         (cdr entry))))
54
55 ;; 90 == 90/127 == 0.71 is supposed to be the default value
56 ;; urg: we should set this at start of track
57 (define dynamic-default-volume 0.71)
58
59 ;; Count number of sharps minus number of flats
60 (define (accidentals-in-key pitch-list)
61   (apply + (map cdr pitch-list)))
62
63 ;; Characterise the key as major if the alteration of the 
64 ;; third scale note is the same as that of the main note
65 ;; Note: MIDI cannot handle other tonalities than major/minor.
66 (define (major-key pitch-list)
67   (eq? (cdr (list-ref pitch-list 4)) (cdr (list-ref pitch-list 6))))