-
Notifications
You must be signed in to change notification settings - Fork 6
/
fingerings.py
197 lines (170 loc) · 5.98 KB
/
fingerings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/env python
# Copyright (c) 2017 Xulio Coira <xulioc@gmail.com>. All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# OPENPIPE FINGERINGS
# This script creates <fingerings.h> for use in OpenPipe based on
# fingering tables defined here in human readable form
# FINGER POSITION DEFINED BY A STRING LIKE "XX XXX XXXX"
# BLANKS ARE MANDATORY
# WHERE X IS:
# C: FINGER IS CLOSED
# O: FINGER IS OPEN
# -: FINGER DOES NOT CARE
# FINGERS FROM LEFT TO RIGHT IN THE STRING (UP TO DOWN IN THE CHANTER):
# LEFT THUMB TOP
# LEFT THUMB BOTTOM
# LEFT INDEX
# LEFT MIDDLE
# LEFT RING
# RIGH INDEX
# RIGHT MIDDLE
# RIGHT RING
# RIGHT LITTLE
#http://www.phys.unsw.edu.au/jw/notes.html
#GAITA GALEGA
galician_mastergaita=(
("GAITA GALEGA"), #FINGERING NAME
(71), #BASE MIDI NOTE (THE LOWEST IN THE TABLE)
(72), #TONIC MIDI NOTE
(48), #DRONE MIDI NOTES
#FINGERINGS (SEMITONES FROM BASE NOTE, (FINGERINGS,))
(0,("-C CCC CCCC",)), # B3
(1,("-C CCC CCCO",)), # C4
(2,("-C CCC CCOC",)), # C#4
(3,("-C CCC CCOO",)), # D4
(4,("-C CCC COCO",)), # Eb4
(5,("-C CCC COO-", "-C CCC COCC")), # E4
(6,("-C CCC O---", "-C CCC OCC-")), # F4
(7,("-C CCO C-OO", "-C CCO CCCC")), # F#4
(8,("-C CCO O---", "-C CCO CCCO")), # G4
(9,("-C COC ----",)), # Ab4
(10,("-C COO ----",)), # A4
(11,("-C OCO ----",)), # Bb4
(12,("-C OOO ----", "-O CCC CCCC", "-C OCC CCCC")), # B4
(13,("-O OOO ----", "-O CCC CCCO", "-C OCC ---O")), # C5
(14,("-O CCC CCOC",)), # C#5
(15,("-O CCC CCOO",)), # D5
(16,("-O CCC COCO",)), # Eb5
(17,("-O CCC COO-", "-O CCC COCC")), # E5
(18,("-O CCC O---",)), # F5
(19,("-O CCO C-OO", "-O CCO CCCC")), # F#5
(20,("-O CCO O---", "-O CCO CCCO")), # G5
(21,("-O COC ----",)), # Ab5
(22,("-O COO ----",)), # A5
(23,("-O OCO ----",)), # Bb5
(24,("-O OCC CCCC",)), # B5
(25,("-O OCC CCCO",)), # C6
)
#GAITA ASTURIANA (thanks to Juan Pablo <gaiterujp@gmail.com>)
asturian_gaita=(
("GAITA ASTURIANA"), #FINGERING NAME
(71), #BASE MIDI NOTE (THE LOWEST IN THE TABLE)
(72), #TONIC MIDI NOTE
(48), #DRONE MIDI NOTES
#FINGERINGS (SEMITONES FROM BASE NOTE, (FINGERINGS,))
(0,("-C CCC CCCC",)), # B3
(1,("-C CCC CCCO",)), # C4
(2,("-C CCC CCOC",)), # C#4
(3,("-C CCC CCOO",)), # D4
(4,("-C CCC COOO",)), # Eb4
(5,("-C CCC COCO",)), # E4
(6,("-C CCC OCCO",)), # F4
(7,("-C CCC OCCC",)), # F#4
(8,("-C CCO CCCO", "-C CCO COCO", "-C CCO OCCO")), # G4
(9,("-C COO OCCO",)), # Ab4
(10,("-C COO CCCO", "-C COO CCCC")), # A4
(11,("-C OOO CCCO",)), # Bb4
(12,("-O COO CCCO", "-C OCC CCCC", "-O CCC CCCC")), # B4
(13,("-O CCC CCCO", "-C OCC CCCO")), # C5
(14,("-O OCC OCCO",)), # C#5
(15,("-O CCC CCOO", "-C OCC CCOO")), # D5
(16,("-O CCC COOO",)), # Eb5
(17,("-O CCC COCO",)), # E5
(18,("-O CCC OCCO",)), # F5
)
# GREAT HIGHLAND BAGPIPE
#http://www.bagpipejourney.com/articles/finger_positions.shtml
great_highland_bagpipe=(
("GREAT HIGHLAND BAGPIPE"), #FINGERING NAME
(67), #BASE MIDI NOTE (THE LOWEST IN THE TABLE) G4
(69), #TONIC MIDI NOTE A4
(57), #DRONE MIDI NOTE
#FINGERINGS (SEMITONES FROM BASE NOTE, (FINGERINGS,))
(0,("-C CCC CCCC",)), # LOW G (G4)
(2,("-C CCC CCCO",)), # LOW A (A4)
(4,("-C CCC CCOO",)), # B (B4)
(5,("-C CCC COOC", "-C CCC CO--")), # C (C5)
(7,("-C CCC OOOC", "-C CCC OO--")), # D (D5)
(9,("-C CCO CCCO", "-C CCO ----")), # E (E5)
(10,("-C COO CCCO", "-C COO ----")), # F (F5)
(12,("-C OOO CCCO", "-C OOO ----")), # HIGH G (G5)
(14,("-O OOO CCCO", "-O OOO ----")), # HIGH A (A5)
)
# ADD YOUR FINGERING TABLE HERE
fingerings=[]
fingerings.append(galician_mastergaita)
fingerings.append(asturian_gaita)
fingerings.append(great_highland_bagpipe)
output="""
// OPENPIPE FINGERING TABLES
// FILE AUTOMATICALLY GENERATED USING fingerings.py
// DO NOT EDIT BY HAND
"""
for index, fingering in enumerate(fingerings):
output+="""
// %s
const char fingering_name_%i[]={"%s"};
const unsigned long fingering_table_%i[]={
""" % (fingering[0], index, fingering[0], index)
output+= "\t"
output+= "%s," % fingering[1] # BASE NOTE
output+= "%s," % fingering[2] # TONIC NOTE
output+= "%s," % fingering[3] # DRONE NOTE
output+= "\r\n\t"
for item in fingering[4:]:
for fingers in item[1]:
#"-C CCC CCCC -"
f=0x0 # FINGER VALUE
m=0xFFFF # MASK VALUE
for i,pos in enumerate((10,9,8,7,5,4,3,1,0)):
if fingers[pos]=='C':
f+=2**i
if fingers[pos]=='-':
m-=2**i
value=(1<<31)+(f<<16)+m
output+= "0x%08X, " % value
value=int(item[0])<<24
output+= "0x%08X," % value
output+= "\r\n\t"
output+= "0xFFFFFFFF\r\n};" #TABLE END
output+= "\r\n\r\n"
for i in range(len(fingerings)):
output+="#define FINGERING_%s %i" %(fingerings[i][0].replace (" ", "_"), i)
output+= "\r\n"
output+="""
typedef struct{
char* name;
unsigned long* table;
}fingering_t;
#define TOTAL_FINGERINGS %i
const fingering_t fingerings[TOTAL_FINGERINGS]={
""" % (len(fingerings))
for i in range(len(fingerings)):
output+="\t{(char*)fingering_name_%i, (unsigned long*)fingering_table_%i},\r\n" % (i,i)
output+="};\r\n"
print output
f = open('fingerings.h', 'w')
f.write(output)
f.close