Ejemplo n.º 1
0
   def make_mode(self, n, mode):
      '''Re-arranges the intervals of this scale into a new scale'''

      # get the key distance to adjust all others by
      key_dist = self.intervals[mode - 1].distance
      adj_dist = []

      # build a list of distances
      for i in range(len(self.intervals)):
         # find the interval index for this iteration with
         # respect to the requested mode
         step_idx = (i + (mode - 1)) % len(self.intervals)

         # pull out the distance for the interval and adjust
         # it by the distance of the mother-key's step
         step_dist = self.intervals[step_idx].distance - key_dist

         # constrain the distance to within the chromatic scale
         if step_dist < 0:
            step_dist += 12

         # get the interval and add it to the list
         adj_dist.append(Intervals.by_distance(step_dist))

      # create the scale and send it out
      return Scale(n, adj_dist)
Ejemplo n.º 2
0
from intervals import Intervals
from notes import Notes

# read intervals out for reference
peru = Intervals.by_distance(0)
min2 = Intervals.by_distance(1)
maj2 = Intervals.by_distance(2)
min3 = Intervals.by_distance(3)
maj3 = Intervals.by_distance(4)
per4 = Intervals.by_distance(5)
trit = Intervals.by_distance(6)
per5 = Intervals.by_distance(7)
min6 = Intervals.by_distance(8)
maj6 = Intervals.by_distance(9)
min7 = Intervals.by_distance(10)
maj7 = Intervals.by_distance(11)

class Scale(object):
   '''Defines a collection of intervals'''

   def __init__(self, n, inters):
      '''Creates a scale instance'''
      self.name = n
      self.intervals = inters

   def voice(self, key):
      '''Voices this scale in a particular key'''
      # get a chromatic list of notes
      chromatic = Scales.make_chromatic(key)
      steps = []