]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/customize-drumpitchnames,-drumstyletable-and-drumpitchtable-in-layout-and-midi.ly
Merge branch 'master' of /home/jcharles/GIT/Lily/. into translation
[lilypond.git] / Documentation / snippets / customize-drumpitchnames,-drumstyletable-and-drumpitchtable-in-layout-and-midi.ly
1 %% DO NOT EDIT this file manually; it is automatically
2 %% generated from LSR http://lsr.di.unimi.it
3 %% Make any changes in LSR itself, or in Documentation/snippets/new/ ,
4 %% and then run scripts/auxiliar/makelsr.py
5 %%
6 %% This file is in the public domain.
7 \version "2.18.0"
8
9 \header {
10   lsrtags = "midi, percussion, pitches, specific-notation"
11
12   texidoc = "
13 If you want to use customized drum-pitch-names for an own drum-style
14 with proper output for layout and midi, follow the steps as
15 demonstrated in the code below. In short:
16
17 * define the names * define the appearence * tell LilyPond to use it
18 for layout * assign pitches to the names * tell LilyPond to use them
19 for midi
20
21 "
22   doctitle = "Customize drumPitchNames drumStyleTable and drumPitchTable in layout and midi"
23 } % begin verbatim
24
25 %% This snippet tries to amend
26 %% NR 2.5.1 Common notation for percussion - Custom percussion staves
27 %% http://lilypond.org/doc/v2.18/Documentation/notation/common-notation-for-percussion#custom-percussion-staves
28
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 %%
31 %% To use custom drum-pitch-names for your score and midi you need to follow
32 %% this route:
33 %%
34 %%%%%%%%%%%%
35 %% LAYOUT:
36 %%%%%%%%%%%%
37 %%
38 %% (1) Define a name and put it in `drumPitchNames'
39 %%     This can be done at toplevel with
40 %%         drumPitchNames #'my-name  = #'my-name
41 %%     or shorter:
42 %%         drumPitchNames.my-name  = #'my-name
43 %%     It's possible to add an alias as well.
44 %% (2) Define how it should be printed
45 %%     Therefore put them into a toplevel-list, where each entry should look:
46 %%         (my-name
47 %%           note-head-style-or-default
48 %%             articulation-string-or-#f
49 %%               staff-position)
50 %%     Example:
51 %%         #(define my-style
52 %%           '(
53 %%             (my-name default "tenuto" -1)
54 %%             ; ...
55 %%             ))
56 %% (3) Tell LilyPond to use this custom-definitions, with
57 %%         drumStyleTable = #(alist->hash-table my-style)
58 %%     in a \layout or \with
59 %%
60 %%     Now we're done for layout, here a short, but complete example:
61 %%         \new DrumStaff
62 %%           \with { drumStyleTable = #(alist->hash-table my-style) }
63 %%           \drummode { my-name }
64 %%
65 %%%%%%%%%%%%
66 %% MIDI:
67 %%%%%%%%%%%%
68 %%
69 %% (1) Again at toplvel, assign a pitch to your custom-note-name
70 %%         midiDrumPitches #'my-name = #(ly:make-pitch -1 4 FLAT)
71 %%     or shorter:
72 %%         midiDrumPitches.my-name = ges
73 %%     Note that you have to use the name, which is in drumPitchNames, no alias
74 %% (2) Tell LilyPond to use this pitch(es), with
75 %%         drumPitchTable = #(alist->hash-table midiDrumPitches)
76 %%
77 %%     Example:
78 %%         \score {
79 %%            \new DrumStaff
80 %%             \with {
81 %%               drumStyleTable = #(alist->hash-table my-style)
82 %%               drumPitchTable = #(alist->hash-table midiDrumPitches)
83 %%             }
84 %%             \drummode { my-name4 }
85 %%           \layout {}
86 %%           \midi {}
87 %%         }
88 %%
89 %%%%%%%%%%%%
90 %% TESTING
91 %%%%%%%%%%%%
92 %%
93 %% To test whether all is fine, run the following sequence in terminal:
94 %%         lilypond my-file.ly
95 %%         midi2ly my-file.midi
96 %%         gedit my-file-midi.ly
97 %%
98 %% Which will do:
99 %% 1. create pdf and midi
100 %% 2. transform the midi back to a .ly-file
101 %%    (note: midi2ly is not always good in correctly identifying enharmonic pitches)
102 %% 3. open this file in gedit (or use another editor)
103 %% Now watch what you've got.
104 %%
105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106
107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108 %% FULL EXAMPLE
109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110
111 drumPitchNames.dbass      = #'dbass
112 drumPitchNames.dba        = #'dbass  % 'db is in use already
113 drumPitchNames.dbassmute  = #'dbassmute
114 drumPitchNames.dbm        = #'dbassmute
115 drumPitchNames.do         = #'dopen
116 drumPitchNames.dopenmute  = #'dopenmute
117 drumPitchNames.dom        = #'dopenmute
118 drumPitchNames.dslap      = #'dslap
119 drumPitchNames.ds         = #'dslap
120 drumPitchNames.dslapmute  = #'dslapmute
121 drumPitchNames.dsm        = #'dslapmute
122
123 #(define djembe
124   '((dbass      default  #f         -2)
125     (dbassmute  default  "stopped"  -2)
126     (dopen      default  #f          0)
127     (dopenmute  default  "stopped"   0)
128     (dslap      default  #f          2)
129     (dslapmute  default  "stopped"   2)))
130
131 midiDrumPitches.dbass = g
132 midiDrumPitches.dbassmute = fis
133 midiDrumPitches.dopen =  a
134 midiDrumPitches.dopenmute = gis
135 midiDrumPitches.dslap =  b
136 midiDrumPitches.dslapmute = ais
137
138 one = \drummode { r4 dba4 do ds r dbm dom dsm }
139
140 \score {
141    \new DrumStaff
142     \with {
143       \override StaffSymbol.line-count =  #3
144       instrumentName = #"Djembe "
145       drumStyleTable = #(alist->hash-table djembe)
146       drumPitchTable = #(alist->hash-table midiDrumPitches)
147     }
148     \one
149   \layout {}
150   \midi {}
151 }