Exemple #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])
Exemple #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)
Exemple #3
0
 def test_closest_inversions(self):
     ch1 = Chord.from_library('C', 'major')
     ch2 = Chord.from_library('Db', 'dim')
     lower, upper = closest_inversions(ch1, ch2)
     self.assertEqual(upper, ch2)
     self.assertEqual(lower, ch2)
     self.assertEqual(ch1.midis, [60, 64, 67])
     self.assertEqual(upper.midis, [61, 64, 67])
     self.assertEqual(lower.midis, [55, 61, 64])
Exemple #4
0
 def setUp(self):
     self.combs = list(
         Combinations.generate_comb(['q', 'e', 'x'], [2, 3, 2]))
     self.Counter = CounterBases().Count
     ch1 = Chord.from_library('A', 'sus2').inversion(-3)
     ch2 = Chord.from_library('F', 'maj7').inversion(-2)
     ch3 = Chord.from_library('C', 'maj9').inversion(-4)
     ch4 = Chord.from_library('E', 'maj7').inversion(-2)
     self.arp = ChordProgArp(ChordProg([ch1, ch2, ch3, ch4]))
Exemple #5
0
 def test_match_scale_to_library(self):
     gr = Chord.from_intervals(
         'F', '1 3 4# 6'
     )  # Todo: how can I generate other chords in a scale with
     #    same interval structure ** Done! ==> move_chord_over_scale()
     scales = match_scale_to_library(gr)
     print(scales)
     print()
     scales = find_scales_with_chord(gr)
     print(scales)
Exemple #6
0
from theorymuse import Durations, Combinations, CounterBases
from theorymuse import Chord, ChordProgArp
from kenmido import NoteTable, play, portopen, export_midifile
from theorymuse import tprint, Printer
import itertools as it



# import os
# print(os.path.abspath(os.curdir))
# ch1v = Chord.from_library('A', 'minor')
# arpa = Arpeggiator(ch1v, 8)
# generatednotes = [str(note) for note in arpa.randgen()]
# print(generatednotes)

ch1 = Chord.from_library('D', 'sus2')
ch2 = Chord.from_names('Bb D A D E')
ch3 = Chord.from_library('C', 'add9')
ch4 = Chord.from_library('E', 'add9')
ch5 = Chord.from_library('Ab', 'major')
ch6 = Chord.from_library('G', 'major')
ch7 = Chord.from_library('F', 'major')
ch8 = Chord.from_library('C', 'add9')
arp = ChordProgArp([ch1, ch2, ch1, ch3, ch1, ch5, ch6, ch7], 5)

combs = list(Combinations.generate_comb(['q', 'e'], [3, 2]))
Counter = CounterBasis().tick
print(len(combs))
idx = 4
comb = combs[idx]
print(comb)
Exemple #7
0
 def test_all_chords_and_collection_indexing(self):
     a = ALL_CHORDS
     self.assertEqual(a[4][4], Chord.from_library('E', 'dom7'))
     self.assertEqual(a['C#'][3], Chord.from_library('C#', 'min7'))
     self.assertEqual(a[PC(38)][1], Chord.from_names('D F A'))
Exemple #8
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'))
Exemple #9
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)
Exemple #10
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'))
Exemple #11
0
        return notes

    def meloseq(scale):
        notegen = NoteGenerator(scale)
        notes = it.cycle(notegen.contour([1, 2, -1] * 2 + [-2, -2]))
        return notes

    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,