示例#1
0
def generate_testtable():
    testtable = MidiTable(20, channel=1, track=1)
    # print(testtable.maxtime)
    testtable.TrackName('Song 1', track=0, channel=0)
    testtable.TempoSet(105)
    testtable.TimeSignature(4, 4)
    testtable.TrackName('Track 1')
    testtable.control('volume', 100)
    testtable.control('pan', 67)
    testtable.bend(0)
    testtable.Marker('A marker', time=240)
    testtable.Lyrics('Some words...', time=480)
    testtable.note_on(time=0, noteval=60, score_d=480)
    testtable.note_on(time=480, noteval=62, score_d=480)
    testtable.note_on(time=960, noteval=64, score_d=480)
    testtable.note_on(time=1280, noteval=65, score_d=480)

    testtable.cleanup()
    return testtable
示例#2
0
from kenmido import MidiTable, Sequencer, portopen, play
from kenmido.rows import Mtypes
from theorymuse import tprint, Printer

Printer.midi_mode()
a = MidiTable(20, channel=1, track=1)
a.TrackName('Song 1', track=0, channel=0)
a.TempoSet(105)
a.TimeSignature(4, 4)
a.TrackName('Track 1')
a.control('volume', 100)
a.control('pan', 67)
a.bend(0)
a.Marker('A marker', time=240)
a.Lyrics('Some words...', time=480)
a.note_on(time=0, noteval=60, score_d=480, midi_f=1)
a.note_on(time=480, noteval=62, score_d=480, midi_f=1)
a.note_on(time=960, noteval=64, score_d=480, midi_f=1)
a.note_on(time=960 + 240, noteval=65, score_d=240, midi_f=1)
a.fix_eots()
a.insert_note_offs()
a.remove_empty_rows()
a.sort()
a.encode_table()
a.abs_to_reltime()
print(a.maxtime)
tprint(a)
with portopen('loopMIDI'):
    play(a, noloops=3)