MCPcopy Create free account
hub / github.com/bspaans/python-mingus / Diatonic

Class Diatonic

mingus/core/scales.py:152–181  ·  view source on GitHub ↗

The diatonic scale. Example: >>> print Diatonic('C', (3, 7)) Ascending: C D E F G A B C Descending: C B A G F E D C

Source from the content-addressed store, hash-verified

150
151
152class Diatonic(_Scale):
153
154 """The diatonic scale.
155
156 Example:
157 >>> print Diatonic('C', (3, 7))
158 Ascending: C D E F G A B C
159 Descending: C B A G F E D C
160 """
161
162 type = "diatonic"
163
164 def __init__(self, note, semitones, octaves=1):
165 """Create the diatonic scale starting on the chosen note.
166
167 The second parameter is a tuple representing the position of
168 semitones.
169 """
170 super(Diatonic, self).__init__(note, octaves)
171 self.semitones = semitones
172 self.name = "{0} diatonic, semitones in {1}".format(self.tonic, self.semitones)
173
174 def ascending(self):
175 notes = [self.tonic]
176 for n in range(1, 7):
177 if n in self.semitones:
178 notes.append(intervals.minor_second(notes[-1]))
179 else:
180 notes.append(intervals.major_second(notes[-1]))
181 return notes * self.octaves + [notes[0]]
182
183
184# Ancient scales

Callers 7

ascendingMethod · 0.85
ascendingMethod · 0.85
ascendingMethod · 0.85
ascendingMethod · 0.85
ascendingMethod · 0.85
ascendingMethod · 0.85
ascendingMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected