LEFT | RIGHT |
(no file at all) | |
1 #!@TARGET_PYTHON@ | 1 #!@TARGET_PYTHON@ |
2 | 2 |
3 # This file is part of LilyPond, the GNU music typesetter. | 3 # This file is part of LilyPond, the GNU music typesetter. |
4 # | 4 # |
5 # LilyPond is free software: you can redistribute it and/or modify | 5 # LilyPond is free software: you can redistribute it and/or modify |
6 # it under the terms of the GNU General Public License as published by | 6 # it under the terms of the GNU General Public License as published by |
7 # the Free Software Foundation, either version 3 of the License, or | 7 # the Free Software Foundation, either version 3 of the License, or |
8 # (at your option) any later version. | 8 # (at your option) any later version. |
9 # | 9 # |
10 # LilyPond is distributed in the hope that it will be useful, | 10 # LilyPond is distributed in the hope that it will be useful, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 if bank_number == 1: | 128 if bank_number == 1: |
129 # minor scale | 129 # minor scale |
130 p = transpose (p, (5, 0)) | 130 p = transpose (p, (5, 0)) |
131 p = (p[0] % 7, p[1]) | 131 p = (p[0] % 7, p[1]) |
132 | 132 |
133 return KeySignature (p, bank_number) | 133 return KeySignature (p, bank_number) |
134 | 134 |
135 # should cache this. | 135 # should cache this. |
136 def find_scale (keysig): | 136 def find_scale (keysig): |
137 cscale = map (lambda x: (x,0), range (0,7)) | 137 cscale = [(x,0) for x in range (0,7)] |
138 # print "cscale: ", cscale | 138 # print "cscale: ", cscale |
139 ascale = map (lambda x: (x,0), range (-2,5)) | 139 ascale = [(x,0) for x in range (-2,5)] |
140 # print "ascale: ", ascale | 140 # print "ascale: ", ascale |
141 transposition = keysig.pitch | 141 transposition = keysig.pitch |
142 if keysig.sig_type == 1: | 142 if keysig.sig_type == 1: |
143 transposition = transpose(transposition, (2, -1)) | 143 transposition = transpose(transposition, (2, -1)) |
144 transposition = (transposition[0] % 7, transposition[1]) | 144 transposition = (transposition[0] % 7, transposition[1]) |
145 trscale = map(lambda x, k=transposition: transpose(x, k), ascale) | 145 trscale = list(map(lambda x, k=transposition: transpose(x, k), ascale)) |
146 else: | 146 else: |
147 trscale = map(lambda x, k=transposition: transpose(x, k), cscale) | 147 trscale = list(map(lambda x, k=transposition: transpose(x, k), cscale)) |
148 # print "trscale: ", trscale | 148 # print "trscale: ", trscale |
149 return trscale | 149 return trscale |
150 | 150 |
151 def EDU_to_duration (edu): | 151 def EDU_to_duration (edu): |
152 log = 1 | 152 log = 1 |
153 d = 4096 | 153 d = 4096 |
154 while d > edu: | 154 while d > edu: |
155 d = d >> 1 | 155 d = d >> 1 |
156 log = log << 1 | 156 log = log << 1 |
157 | 157 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 c = startch | 255 c = startch |
256 while c and edu_left: | 256 while c and edu_left: |
257 c.tuplet = self | 257 c.tuplet = self |
258 if c == startch: | 258 if c == startch: |
259 c.chord_prefix = self.dump_start () + c.chord_prefix· | 259 c.chord_prefix = self.dump_start () + c.chord_prefix· |
260 | 260 |
261 if not c.grace: | 261 if not c.grace: |
262 edu_left = edu_left - c.EDU_duration () | 262 edu_left = edu_left - c.EDU_duration () |
263 if edu_left == 0: | 263 if edu_left == 0: |
264 c.chord_suffix = c.chord_suffix+ self.dump_end () | 264 c.chord_suffix = c.chord_suffix+ self.dump_end () |
265 c = c.next | 265 c = c.__next__ |
266 | 266 |
267 if edu_left: | 267 if edu_left: |
268 sys.stderr.write ("\nHuh? Tuplet starting at entry %d was too short.
" % self.start_note) | 268 sys.stderr.write ("\nHuh? Tuplet starting at entry %d was too short.
" % self.start_note) |
269 ········ | 269 ········ |
270 class Slur: | 270 class Slur: |
271 def __init__ (self, number, params): | 271 def __init__ (self, number, params): |
272 self.number = number | 272 self.number = number |
273 self.finale = params | 273 self.finale = params |
274 | 274 |
275 def append_entry (self, finale_e): | 275 def append_entry (self, finale_e): |
(...skipping 21 matching lines...) Expand all Loading... |
297 self.timesig = '' | 297 self.timesig = '' |
298 self.number = number | 298 self.number = number |
299 self.key_signature = None | 299 self.key_signature = None |
300 self.scale = None | 300 self.scale = None |
301 self.force_break = 0 | 301 self.force_break = 0 |
302 ········ | 302 ········ |
303 self.repeats = [] | 303 self.repeats = [] |
304 self.finale = [] | 304 self.finale = [] |
305 | 305 |
306 def __str__ (self): | 306 def __str__ (self): |
307 return `self.finale ` | 307 return repr(self.finale) |
308 ···· | 308 ···· |
309 def set_timesig (self, finale): | 309 def set_timesig (self, finale): |
310 (beats, fdur) = finale | 310 (beats, fdur) = finale |
311 (log, dots) = EDU_to_duration (fdur) | 311 (log, dots) = EDU_to_duration (fdur) |
312 | 312 |
313 if dots == 1: | 313 if dots == 1: |
314 beats = beats * 3 | 314 beats = beats * 3 |
315 log = log * 2 | 315 log = log * 2 |
316 dots = 0 | 316 dots = 0 |
317 | 317 |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 | 747 |
748 scale = meas.global_measure.scale· | 748 scale = meas.global_measure.scale· |
749 (sn, sa) =scale[rest % 7] | 749 (sn, sa) =scale[rest % 7] |
750 sn = sn + (rest - (rest%7)) + 7 | 750 sn = sn + (rest - (rest%7)) + 7 |
751 acc = sa + nib1 | 751 acc = sa + nib1 |
752 self.pitches.append ((sn, acc)) | 752 self.pitches.append ((sn, acc)) |
753 tiestart = tiestart or (flag & Chord.TIE_START_MASK) | 753 tiestart = tiestart or (flag & Chord.TIE_START_MASK) |
754 if tiestart : | 754 if tiestart : |
755 self.chord_suffix = self.chord_suffix + ' ~ ' | 755 self.chord_suffix = self.chord_suffix + ' ~ ' |
756 ········ | 756 ········ |
757 REST_MASK = 0x40000000L | 757 REST_MASK = 0x40000000 |
758 TIE_START_MASK = 0x40000000L | 758 TIE_START_MASK = 0x40000000 |
759 GRACE_MASK = 0x00800000L | 759 GRACE_MASK = 0x00800000 |
760 ···· | 760 ···· |
761 def ly_string (self): | 761 def ly_string (self): |
762 s = '' | 762 s = '' |
763 | 763 |
764 rest = '' | 764 rest = '' |
765 | 765 |
766 | 766 |
767 if not (self.finale[4] & Chord.REST_MASK): | 767 if not (self.finale[4] & Chord.REST_MASK): |
768 rest = 'r' | 768 rest = 'r' |
769 ········ | 769 ········ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 ···· | 821 ···· |
822 if str[0] == '$': | 822 if str[0] == '$': |
823 str = str [1:] | 823 str = str [1:] |
824 | 824 |
825 hex = '' | 825 hex = '' |
826 while str and str[0] in '0123456789ABCDEF': | 826 while str and str[0] in '0123456789ABCDEF': |
827 hex = hex + str[0] | 827 hex = hex + str[0] |
828 str = str[1:] | 828 str = str[1:] |
829 | 829 |
830 ········ | 830 ········ |
831 return (long (hex, 16), str) | 831 return (int (hex, 16), str) |
832 elif str[0] == '"': | 832 elif str[0] == '"': |
833 str = str[1:] | 833 str = str[1:] |
834 s = '' | 834 s = '' |
835 while str and str[0] != '"': | 835 while str and str[0] != '"': |
836 s = s + str[0] | 836 s = s + str[0] |
837 str = str[1:] | 837 str = str[1:] |
838 | 838 |
839 return (s,str) | 839 return (s,str) |
840 elif str[0] in '-0123456789': | 840 elif str[0] in '-0123456789': |
841 dec = '' | 841 dec = '' |
(...skipping 25 matching lines...) Expand all Loading... |
867 etf_file_dict = {} | 867 etf_file_dict = {} |
868 for k in tag_dict: | 868 for k in tag_dict: |
869 etf_file_dict[k] = {} | 869 etf_file_dict[k] = {} |
870 | 870 |
871 last_tag = None | 871 last_tag = None |
872 last_numbers = None | 872 last_numbers = None |
873 | 873 |
874 | 874 |
875 for l in ls: | 875 for l in ls: |
876 m = re.match ('^([a-zA-Z0-9&]+)\(([^)]+)\)', l) | 876 m = re.match ('^([a-zA-Z0-9&]+)\(([^)]+)\)', l) |
877 if m and tag_dict.has_key (m.group (1)): | 877 if m and m.group (1) in tag_dict: |
878 tag = m.group (1) | 878 tag = m.group (1) |
879 | 879 |
880 indices = tuple ([int (s) for s in m.group (2).split (',')]) | 880 indices = tuple ([int (s) for s in m.group (2).split (',')]) |
881 content = l[m.end (2)+1:] | 881 content = l[m.end (2)+1:] |
882 | 882 |
883 | 883 |
884 tdict = etf_file_dict[tag] | 884 tdict = etf_file_dict[tag] |
885 if not tdict.has_key (indices): | 885 if indices not in tdict: |
886 tdict[indices] = [] | 886 tdict[indices] = [] |
887 | 887 |
888 | 888 |
889 parsed = [] | 889 parsed = [] |
890 | 890 |
891 if tag == 'verse' or tag == 'block': | 891 if tag == 'verse' or tag == 'block': |
892 m2 = re.match ('(.*)\^end', content) | 892 m2 = re.match ('(.*)\^end', content) |
893 if m2: | 893 if m2: |
894 parsed = [m2.group (1)] | 894 parsed = [m2.group (1)] |
895 else: | 895 else: |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 'IM' : try_IM, | 1047 'IM' : try_IM, |
1048 'TP' : try_TP, | 1048 'TP' : try_TP, |
1049 'BC' : try_BC, | 1049 'BC' : try_BC, |
1050 'IS' : try_IS, | 1050 'IS' : try_IS, |
1051 } | 1051 } |
1052 ···· | 1052 ···· |
1053 def parse (self, etf_dict): | 1053 def parse (self, etf_dict): |
1054 sys.stderr.write ('reconstructing ...') | 1054 sys.stderr.write ('reconstructing ...') |
1055 sys.stderr.flush () | 1055 sys.stderr.flush () |
1056 | 1056 |
1057 for (tag,routine) in Etf_file.routine_dict.items (): | 1057 for (tag,routine) in list(Etf_file.routine_dict.items ()): |
1058 ks = etf_dict[tag].keys () | 1058 ks = list(etf_dict[tag].keys ()) |
1059 ks.sort () | 1059 ks.sort () |
1060 for k in ks: | 1060 for k in ks: |
1061 routine (self, k, etf_dict[tag][k]) | 1061 routine (self, k, etf_dict[tag][k]) |
1062 ············ | 1062 ············ |
1063 sys.stderr.write ('processing ...') | 1063 sys.stderr.write ('processing ...') |
1064 sys.stderr.flush () | 1064 sys.stderr.flush () |
1065 | 1065 |
1066 self.unthread_entries () | 1066 self.unthread_entries () |
1067 | 1067 |
1068 for st in self.staffs[1:]: | 1068 for st in self.staffs[1:]: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 try: | 1126 try: |
1127 c = self.chords[startno] | 1127 c = self.chords[startno] |
1128 except IndexError: | 1128 except IndexError: |
1129 sys.stderr.write ("Huh? Frame has invalid bounds (%d,%d)\n" % (start
no, endno)) | 1129 sys.stderr.write ("Huh? Frame has invalid bounds (%d,%d)\n" % (start
no, endno)) |
1130 return [] | 1130 return [] |
1131 | 1131 |
1132 ········ | 1132 ········ |
1133 while c and c.number != endno: | 1133 while c and c.number != endno: |
1134 d = c # hack to avoid problem with scripts/build/grand-replace.py | 1134 d = c # hack to avoid problem with scripts/build/grand-replace.py |
1135 thread.append (d) | 1135 thread.append (d) |
1136 c = c.next | 1136 c = c.__next__ |
1137 | 1137 |
1138 if c:· | 1138 if c:· |
1139 d = c # hack to avoid problem with scripts/build/grand-replace.py | 1139 d = c # hack to avoid problem with scripts/build/grand-replace.py |
1140 thread.append (d) | 1140 thread.append (d) |
1141 ········ | 1141 ········ |
1142 return thread | 1142 return thread |
1143 | 1143 |
1144 def dump (self): | 1144 def dump (self): |
1145 str = '' | 1145 str = '' |
1146 staffs = [] | 1146 staffs = [] |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 out_filename = os.path.basename (f + '.ly') | 1249 out_filename = os.path.basename (f + '.ly') |
1250 ········ | 1250 ········ |
1251 sys.stderr.write ('Writing `%s\'' % out_filename) | 1251 sys.stderr.write ('Writing `%s\'' % out_filename) |
1252 ly = e.dump() | 1252 ly = e.dump() |
1253 | 1253 |
1254 fo = open (out_filename, 'w') | 1254 fo = open (out_filename, 'w') |
1255 fo.write ('%% lily was here -- automatically converted by etf2ly from %s\n'
% f) | 1255 fo.write ('%% lily was here -- automatically converted by etf2ly from %s\n'
% f) |
1256 fo.write(ly) | 1256 fo.write(ly) |
1257 fo.close () | 1257 fo.close () |
1258 ···· | 1258 ···· |
LEFT | RIGHT |