def test_triplet(self): self.assertEqual(value.triplet(1), 1.5) self.assertEqual(value.triplet(2), 3) self.assertEqual(value.triplet(4), 6) self.assertEqual(value.triplet(8), 12) self.assertEqual(value.triplet(16), 24) self.assertEqual(value.triplet(32), 48) self.assertEqual(value.triplet(64), 96) self.assertEqual(value.triplet(128), 192)
import os, subprocess import mingus, random import mingus.core.notes as notes import mingus.core.value as value from mingus.containers import Composition from mingus.containers import Track from mingus.containers import Bar from mingus.containers import Note, NoteContainer from mingus.midi import midi_file_out durations = [ value.whole, value.half, value.quarter, value.eighth, value.sixteenth, value.triplet(value.eighth), value.triplet(value.sixteenth) ] gypsy_scale = ["C", "C#", "E", "F", "G", "G#", "B", None, None] gypsy_track = Track() for note in gypsy_scale: gypsy_track.add_notes(note) # print(gypsy_track) # midi_file_out.write_Track("gypy_scale.mid", gypsy_track) drums = { "snare": Note("E", 2), "kick": Note("C", 2), "hightom": Note("B", 2),
from mingus.containers import Composition from mingus.containers import Track from mingus.containers import Bar from mingus.containers import Note, NoteContainer from mingus.midi import midi_file_out drum_scale = { "snare": Note("E", 2), "bass": Note("C", 2), "hightom": Note("B", 2), "midtom": Note("A", 2), "lowtom": Note("G", 2), "crash": Note("A", 3), "hatclosed": Note("G#", 2), "hatopen": Note("A#", 2), "ride": Note("B", 3), } values = [value.quarter, value.eighth, value.sixteenth, value.triplet(value.eighth), value.triplet(value.sixteenth)] #for i in range(0, 24): # bar = drum_track = Track() for note in drum_scale: drum_track.add_notes(drum_scale[note]) print(drum_track) midi_file_out.write_Track("drum_scale.mid", drum_track)