]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/new/replacing-default-midi-instrument-equalization.ly
Doc: NR section 3.5.x MIDI file creation tidy up
[lilypond.git] / Documentation / snippets / new / replacing-default-midi-instrument-equalization.ly
1 \version "2.18.0"
2
3 \header {
4
5   lsrtags = "scheme-language, midi"
6
7   texidoc = "The default MIDI instrument equalizer can be replaced by
8   setting the @code{instrumentEqualizer} property in the @code{Score}
9   context to a user-defined Scheme procedure that uses a MIDI instrument
10   name as its argument along with a pair of fractions indicating the
11   minimum and maximum volumes respectively to be applied to that
12   specific instrument.
13
14   The following example sets the minimum and maximum volumes for flute
15   and clarinet respectively."
16
17   doctitle = "Replacing default MIDI instrument equalization"
18 }
19
20 #(define my-instrument-equalizer-alist '())
21
22 #(set! my-instrument-equalizer-alist
23   (append
24     '(
25       ("flute" . (0.7 . 0.9))
26       ("clarinet" . (0.3 . 0.6)))
27     my-instrument-equalizer-alist))
28
29 #(define (my-instrument-equalizer s)
30   (let ((entry (assoc s my-instrument-equalizer-alist)))
31     (if entry
32       (cdr entry))))
33
34 \score {
35   <<
36     \new Staff {
37       \key g \major
38       \time 2/2
39       \set Score.instrumentEqualizer = #my-instrument-equalizer
40       \set Staff.midiInstrument = #"flute"
41       \new Voice \relative c''' {
42         r2 g\mp g fis~
43         4 g8 fis e2~
44         4 d8 cis d2
45       }
46     }
47     \new Staff {
48       \key g \major
49       \set Staff.midiInstrument = #"clarinet"
50       \new Voice \relative c'' {
51         b1\p a2. b8 a
52         g2. fis8 e
53         fis2 r
54       }
55     }
56   >>
57   \layout { }
58   \midi {  }
59 }