예제 #1
0
    def testKeySignature(self):
        time            = 0
        track           = 0
        accidentals     = 3
        accidental_type = MINOR
        mode            = MAJOR

        MyMIDI = MIDIFile(1)
        MyMIDI.addKeySignature(track, time, accidentals, accidental_type, mode)
        MyMIDI.close()

        data = Decoder(MyMIDI.tracks[1].MIDIdata)

        self.assertEqual(MyMIDI.tracks[1].MIDIEventList[0].evtname, 'KeySignature')

        self.assertEqual(data.unpack_into_byte(0), 0x00) # time
        self.assertEqual(data.unpack_into_byte(1), 0xFF) # Code
        self.assertEqual(data.unpack_into_byte(2), 0x59) # subcode
        self.assertEqual(data.unpack_into_byte(3), 0x02) # Event subtype
        self.assertEqual(data.unpack_into_byte(4), accidentals * accidental_type)
        self.assertEqual(data.unpack_into_byte(5), mode)
예제 #2
0
def start_midifile(track, time, fname_no_ext, channel, volume, bpm):
    mf = MIDIFile(1)
    mf.addTrackName(track, time, fname_no_ext)
    mf.addTempo(track, time, bpm)
    mf.addKeySignature(track, time, 0, SHARPS, MAJOR)
    return mf