- names = (0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6)
- alterations = (0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0)
- alteration_names = ('eses', 'es', '', 'is' , 'isis')
- def __init__ (self, clocks, pitch, velocity):
- self.pitch = pitch
- self.velocity = velocity
- # hmm
- self.clocks = clocks
- self.duration = Duration (clocks)
- (self.octave, self.notename, self.alteration) = self.o_n_a ()
-
- def o_n_a (self):
- # major scale: do-do
- # minor scale: la-la (= + 5) '''
-
- n = self.names[(self.pitch) % 12]
- a = self.alterations[(self.pitch) % 12]
-
- if a and key.flats:
- a = - self.alterations[(self.pitch) % 12]
- n = (n - a) % 7
-
- # By tradition, all scales now consist of a sequence
- # of 7 notes each with a distinct name, from amongst
- # a b c d e f g. But, minor scales have a wide
- # second interval at the top - the 'leading note' is
- # sharped. (Why? it just works that way! Anything
- # else doesn't sound as good and isn't as flexible at
- # saying things. In medieval times, scales only had 6
- # notes to avoid this problem - the hexachords.)
-
- # So, the d minor scale is d e f g a b-flat c-sharp d
- # - using d-flat for the leading note would skip the
- # name c and duplicate the name d. Why isn't c-sharp
- # put in the key signature? Tradition. (It's also
- # supposedly based on the Pythagorean theory of the
- # cycle of fifths, but that really only applies to
- # major scales...) Anyway, g minor is g a b-flat c d
- # e-flat f-sharp g, and all the other flat minor keys
- # end up with a natural leading note. And there you
- # have it.
-
- # John Sankey <bf250@freenet.carleton.ca>
- #
- # Let's also do a-minor: a b c d e f gis a
- #
- # --jcn
-
- o = self.pitch / 12 - 4
-
- if key.minor:
- # as -> gis
- if key.sharps == 0 and key.flats == 0 \
- and n == 5 and a == -1:
- n = 4; a = 1
- # des -> cis
- elif key.flats == 1 and n == 1 and a == -1:
- n = 0; a = 1
- # ges -> fis
- elif key.flats == 2 and n == 4 and a == -1:
- n = 3; a = 1
- # g -> fisis
- elif key.sharps == 5 and n == 4 and a == 0:
- n = 3; a = 2
- # d -> cisis
- elif key.sharps == 6 and n == 1 and a == 0:
- n = 0; a = 2
- # a -> gisis
- elif key.sharps == 7 and n == 5 and a == 0:
- n = 4; a = 2
-
- # b -> ces
- if key.flats >= 6 and n == 6 and a == 0:
- n = 0; a = -1; o = o + 1
- # e -> fes
- if key.flats >= 7 and n == 2 and a == 0:
- n = 3; a = -1
-
- # f -> eis
- if key.sharps >= 3 and n == 3 and a == 0:
- n = 2; a = 1
- # c -> bis
- if key.sharps >= 4 and n == 0 and a == 0:
- n = 6; a = 1; o = o - 1
-
- return (o, n, a)
-
- def __repr__ (self):
- s = chr ((self.notename + 2) % 7 + ord ('a'))
- return 'Note(%s %s)' % (s, self.duration.dump())
-
- def dump (self, dump_dur = 1):
- global reference_note
- s = chr ((self.notename + 2) % 7 + ord ('a'))
- s = s + self.alteration_names[self.alteration + 2]
- if absolute_p:
- commas = self.octave
- else:
- delta = self.pitch - reference_note.pitch
- commas = sign (delta) * (abs (delta) / 12)
- if ((sign (delta) \
- * (self.notename - reference_note.notename) + 7) \
- % 7 >= 4) \
- or ((self.notename == reference_note.notename) \
- and (abs (delta) > 4) and (abs (delta) < 12)):
- commas = commas + sign (delta)
-
- if commas > 0:
- s = s + "'" * commas
- elif commas < 0:
- s = s + "," * -commas
-
- ## FIXME: compile fix --jcn
- if dump_dur and (explicit_durations_p \
- or Duration.compare (self.duration,
- reference_note.duration)):
- s = s + self.duration.dump ()
-
- reference_note = self
-
- # TODO: move space
- return s + ' '
+ names = (0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6)
+ alterations = (0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0)
+ alteration_names = ('eses', 'es', '', 'is' , 'isis')
+ def __init__ (self, clocks, pitch, velocity):
+ self.pitch = pitch
+ self.velocity = velocity
+ # hmm
+ self.clocks = clocks
+ self.duration = Duration (clocks)
+ (self.octave, self.notename, self.alteration) = self.o_n_a ()
+
+ def o_n_a (self):
+ # major scale: do-do
+ # minor scale: la-la (= + 5) '''
+
+ n = self.names[(self.pitch) % 12]
+ a = self.alterations[(self.pitch) % 12]
+
+ if a and global_options.key.flats:
+ a = - self.alterations[(self.pitch) % 12]
+ n = (n - a) % 7
+
+ # By tradition, all scales now consist of a sequence
+ # of 7 notes each with a distinct name, from amongst
+ # a b c d e f g. But, minor scales have a wide
+ # second interval at the top - the 'leading note' is
+ # sharped. (Why? it just works that way! Anything
+ # else doesn't sound as good and isn't as flexible at
+ # saying things. In medieval times, scales only had 6
+ # notes to avoid this problem - the hexachords.)
+
+ # So, the d minor scale is d e f g a b-flat c-sharp d
+ # - using d-flat for the leading note would skip the
+ # name c and duplicate the name d. Why isn't c-sharp
+ # put in the key signature? Tradition. (It's also
+ # supposedly based on the Pythagorean theory of the
+ # cycle of fifths, but that really only applies to
+ # major scales...) Anyway, g minor is g a b-flat c d
+ # e-flat f-sharp g, and all the other flat minor keys
+ # end up with a natural leading note. And there you
+ # have it.
+
+ # John Sankey <bf250@freenet.carleton.ca>
+ #
+ # Let's also do a-minor: a b c d e f gis a
+ #
+ # --jcn
+
+ o = self.pitch / 12 - 4
+
+ key = global_options.key
+ if key.minor:
+ # as -> gis
+ if (key.sharps == 0 and key.flats == 0
+ and n == 5 and a == -1):
+ n = 4; a = 1
+ # des -> cis
+ elif key.flats == 1 and n == 1 and a == -1:
+ n = 0; a = 1
+ # ges -> fis
+ elif key.flats == 2 and n == 4 and a == -1:
+ n = 3; a = 1
+ # g -> fisis
+ elif key.sharps == 5 and n == 4 and a == 0:
+ n = 3; a = 2
+ # d -> cisis
+ elif key.sharps == 6 and n == 1 and a == 0:
+ n = 0; a = 2
+ # a -> gisis
+ elif key.sharps == 7 and n == 5 and a == 0:
+ n = 4; a = 2
+
+ # b -> ces
+ if key.flats >= 6 and n == 6 and a == 0:
+ n = 0; a = -1; o = o + 1
+ # e -> fes
+ if key.flats >= 7 and n == 2 and a == 0:
+ n = 3; a = -1
+
+ # f -> eis
+ if key.sharps >= 3 and n == 3 and a == 0:
+ n = 2; a = 1
+ # c -> bis
+ if key.sharps >= 4 and n == 0 and a == 0:
+ n = 6; a = 1; o = o - 1
+
+ return (o, n, a)
+
+ def __repr__ (self):
+ s = chr ((self.notename + 2) % 7 + ord ('a'))
+ return 'Note(%s %s)' % (s, self.duration.dump())
+
+ def dump (self, dump_dur = 1):
+ global reference_note
+ s = chr ((self.notename + 2) % 7 + ord ('a'))
+ s = s + self.alteration_names[self.alteration + 2]
+ if global_options.absolute_pitches:
+ commas = self.octave
+ else:
+ delta = self.pitch - reference_note.pitch
+ commas = sign (delta) * (abs (delta) / 12)
+ if ((sign (delta) \
+ * (self.notename - reference_note.notename) + 7) \
+ % 7 >= 4) \
+ or ((self.notename == reference_note.notename) \
+ and (abs (delta) > 4) and (abs (delta) < 12)):
+ commas = commas + sign (delta)
+
+ if commas > 0:
+ s = s + "'" * commas
+ elif commas < 0:
+ s = s + "," * -commas
+
+ ## FIXME: compile fix --jcn
+ if dump_dur and (global_options.explicit_durations \
+ or self.duration.compare (reference_note.duration)):
+ s = s + self.duration.dump ()
+
+ reference_note = self
+
+ # TODO: move space
+ return s + ' '