示例#1
0
 def test_move_chord_over_scale(self):
     sc = Scale.from_library('C', 'ionian')
     ch = Chord.from_names('C E G B')
     chm = move_chord_over_scale(ch, sc, 8)
     self.assertEqual(chm, Chord.from_names('D F A C'))
     self.assertEqual(ch.midis, [60, 64, 67, 71])
     self.assertEqual(chm.midis, [74, 77, 81, 84])
示例#2
0
 def test_find_chords_in_scale(self):
     sc = Scale.from_library('E', 'aeolian')
     a = find_chords_in_scale(sc)
     gmaj6 = Chord.from_library('G', 'maj6')
     amin6 = Chord.from_library('A', 'min6')
     self.assertIsNone(a['C#'][0])
     self.assertTrue(gmaj6 in a)
     self.assertEqual(a[sc[3]][7], amin6)
示例#3
0
 def setUp(self):
     self.scale = Scale.from_library('C', 'ionian')
     self.gen = NoteGenerator(self.scale)
     self.indices = [0, 0, 1, 1, 3, 5, 12]
     self.contour = [0, 1, 1, -1, -1, 2, -1, -1]
示例#4
0
 def test_generate_subsets(self):
     """Find all three note combinations from notes in C ionian scale."""
     sc = Scale.from_library('C', 'ionian')
     subs = generate_subsets(sc, 3)
     self.assertEqual(subs['C'][0], Chord.from_intervals('C', '1 2 3'))
     self.assertEqual(subs['E'][2], Chord.from_intervals('E', '1 2b 5'))
示例#5
0
 def test_chord_extensions(
         self):  # Todo: make assertions for these three consecutive tests
     ch = Chord.from_library('C', 'major')
     chords = find_chord_extensions(ch)
     sc = Scale.from_library('C', 'ionian')
     chords = find_chord_extensions(ch, sc)
示例#6
0
 def test_find_scales_with_chord(self):
     ch = Chord.from_library('E', 'dom7')
     a = find_scales_with_chord(ch)
     self.assertEqual(a[ch[1]][0], Scale.from_library('Ab', 'locrian'))
示例#7
0
 def test_all_scales(self):
     a = ALL_SCALES
     self.assertEqual(a[1][3], Scale.from_library('C#', 'lydian'))
     self.assertEqual(a['E'][2], Scale.from_library('E', 'phrygian'))
示例#8
0
    NoteVelocity.set_amp_range(0.1, 1.0)
    rhythm = Durations('e e e e e e e e')

    accents = gen_ints(InfiniteGens.every(2))
    rests1 = InfiniteGens.atindices([3, 5, 7])
    rests2 = InfiniteGens.atindices([2, 4, 6])

    chords = [
        Chord.from_library('C', 'maj7'),
        Chord.from_library('A', 'sus2'),
        Chord.from_library('F', 'major'),
        Chord.from_library('F', 'minor')
    ]
    scales = [
        Scale.from_library('A', 'aolean'),
        Scale.from_library('F', 'lydian'),
        Scale.from_library('G', 'mixolydian'),
        Scale.from_library('F', 'minor pentatonic')
    ]

    header = NoteTable(1)
    header.TempoSet(70)
    sequencer = Sequencer(header=header,
                          rhythm=rhythm,
                          accent=accents,
                          rest=None,
                          loop=16)
    for chord, scale in zip(chords, scales):
        with sequencer.concurrent():
            sequencer.sequence(notes=chord, rest=rests1)
示例#9
0
        for meth_name, arg in chain:
            if meth_name == 'set_group':
                self.set_group(arg)
                continue
            args = arg if isinstance(arg, tuple) else ()
            kwargs = arg if isinstance(arg, dict) else {}
            method_f = getattr(self, meth_name)
            iters.append(method_f(*args, **kwargs))
        result = it.chain(*iters)
        if length:
            result = limititer(result, length)
        return result

if __name__ == '__main__':
    from theorymuse import Scale
    scale = Scale.from_library('C', 'dorian')
    noteseq = NoteGenerator(scale)
    idxs = [0, 3, 2, 4, 0]
    print(list(noteseq.indices(idxs)))
    contour = [0, 1, -1, -2, 4, -2, 0]
    print(list(noteseq.contour(contour, 0)))

    seq = noteseq.gen_chain((
        ('ascend', (0, 4)),
         ('ascend', (2, 4)),
         ('descend', (8, 4)),
        ('descend', (5, 4))
    ))
    print(list(seq))

    c1 = [1, 1, 1]