Spaces:
Sleeping
Sleeping
Update app.py and hexachords.py
Browse files- app.py +1 -1
- hexachords.py +5 -5
app.py
CHANGED
|
@@ -35,7 +35,7 @@ def create_midi(chords):
|
|
| 35 |
mid = MidiFile()
|
| 36 |
track = MidiTrack()
|
| 37 |
mid.tracks.append(track)
|
| 38 |
-
delta_time = 480 *
|
| 39 |
for i_chord, chord in enumerate(chords):
|
| 40 |
for i, note in enumerate(chord):
|
| 41 |
if i == 0 and i_chord != 0:
|
|
|
|
| 35 |
mid = MidiFile()
|
| 36 |
track = MidiTrack()
|
| 37 |
mid.tracks.append(track)
|
| 38 |
+
delta_time = 480 * 4
|
| 39 |
for i_chord, chord in enumerate(chords):
|
| 40 |
for i, note in enumerate(chord):
|
| 41 |
if i == 0 and i_chord != 0:
|
hexachords.py
CHANGED
|
@@ -6,9 +6,8 @@ class Hexachord:
|
|
| 6 |
def generate_chord_sequence_from_midi_pitches(self, list_of_mp, intrvl="P5"):
|
| 7 |
return self.generate_chord_sequence([note.Note(mp).nameWithOctave for mp in list_of_mp], intrvl=intrvl)
|
| 8 |
|
| 9 |
-
def generate_chord_sequence(self,
|
| 10 |
|
| 11 |
-
hexachord = list_of_notes
|
| 12 |
fifth = interval.Interval(intrvl) # Perfect fifth
|
| 13 |
all_pc = [n.pitch.pitchClass for n in hexachord]
|
| 14 |
all_chords = []
|
|
@@ -18,8 +17,7 @@ class Hexachord:
|
|
| 18 |
while len(ch) < 6:
|
| 19 |
current_note = fifth.transposeNote(current_note)
|
| 20 |
if current_note.pitch.pitchClass in all_pc and current_note not in ch:
|
| 21 |
-
|
| 22 |
-
while interval.Interval(noteStart=ch[-1], noteEnd=current_note).semitones > 12:
|
| 23 |
current_note = current_note.transpose(-12)
|
| 24 |
ch.add(current_note)
|
| 25 |
all_chords.append(ch)
|
|
@@ -106,7 +104,9 @@ class Hexachord:
|
|
| 106 |
|
| 107 |
if __name__ == '__main__':
|
| 108 |
hexa = Hexachord()
|
| 109 |
-
|
|
|
|
|
|
|
| 110 |
# cs1 = generate_chord_sequence(["E3", "G3", "Ab3", "B3", "C4", "Eb4"])
|
| 111 |
# cs2 = generate_chord_sequence(["C3", "F3", "F#3", "A3", "B4", "E4"])
|
| 112 |
# alternation = alternate_chords(cs1, cs2)
|
|
|
|
| 6 |
def generate_chord_sequence_from_midi_pitches(self, list_of_mp, intrvl="P5"):
|
| 7 |
return self.generate_chord_sequence([note.Note(mp).nameWithOctave for mp in list_of_mp], intrvl=intrvl)
|
| 8 |
|
| 9 |
+
def generate_chord_sequence(self, hexachord, intrvl="P5"):
|
| 10 |
|
|
|
|
| 11 |
fifth = interval.Interval(intrvl) # Perfect fifth
|
| 12 |
all_pc = [n.pitch.pitchClass for n in hexachord]
|
| 13 |
all_chords = []
|
|
|
|
| 17 |
while len(ch) < 6:
|
| 18 |
current_note = fifth.transposeNote(current_note)
|
| 19 |
if current_note.pitch.pitchClass in all_pc and current_note not in ch:
|
| 20 |
+
while interval.Interval(noteStart=ch[-1], noteEnd=current_note).semitones > (12 + 7):
|
|
|
|
| 21 |
current_note = current_note.transpose(-12)
|
| 22 |
ch.add(current_note)
|
| 23 |
all_chords.append(ch)
|
|
|
|
| 104 |
|
| 105 |
if __name__ == '__main__':
|
| 106 |
hexa = Hexachord()
|
| 107 |
+
note_names = ["C3", "Eb3", "E3", "F#3", "G3", "Bb3"]
|
| 108 |
+
notes = [note.Note(n) for n in note_names]
|
| 109 |
+
cs1 = hexa.generate_chord_sequence(notes, intrvl="P4")
|
| 110 |
# cs1 = generate_chord_sequence(["E3", "G3", "Ab3", "B3", "C4", "Eb4"])
|
| 111 |
# cs2 = generate_chord_sequence(["C3", "F3", "F#3", "A3", "B4", "E4"])
|
| 112 |
# alternation = alternate_chords(cs1, cs2)
|