예제 #1
0
    def testTuning(self):
        MyMIDI = MIDIFile(1)
        MyMIDI.changeNoteTuning(0, [(1, 440), (2, 880)])
        MyMIDI.close()

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

        self.assertEqual(MyMIDI.tracks[1].MIDIEventList[0].type,
                         'UniversalSysEx')

        self.assertEqual(data.unpack_into_byte(0), 0x00)
        self.assertEqual(data.unpack_into_byte(1), 0xf0)
        self.assertEqual(data.unpack_into_byte(2), 15)
        self.assertEqual(data.unpack_into_byte(3), 0x7F)
        self.assertEqual(data.unpack_into_byte(4), 0x7F)
        self.assertEqual(data.unpack_into_byte(5), 0x08)
        self.assertEqual(data.unpack_into_byte(6), 0x02)
        self.assertEqual(data.unpack_into_byte(7), 0x00)
        self.assertEqual(data.unpack_into_byte(8), 0x2)
        self.assertEqual(data.unpack_into_byte(9), 0x1)
        self.assertEqual(data.unpack_into_byte(10), 69)
        self.assertEqual(data.unpack_into_byte(11), 0)
        self.assertEqual(data.unpack_into_byte(12), 0)
        self.assertEqual(data.unpack_into_byte(13), 0x2)
        self.assertEqual(data.unpack_into_byte(14), 81)
        self.assertEqual(data.unpack_into_byte(15), 0)
        self.assertEqual(data.unpack_into_byte(16), 0)
        self.assertEqual(data.unpack_into_byte(17), 0xf7)
예제 #2
0
 def testTuning(self):
     MyMIDI = MIDIFile(1)
     MyMIDI.changeNoteTuning(0, [(1, 440), (2, 880)])
     MyMIDI.close()
     self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].type,
                       'UniversalSysEx')
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[0])[0], 0x00)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[1])[0], 0xf0)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[2])[0], 15)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[3])[0], 0x7E)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[4])[0], 0x7F)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[5])[0], 0x08)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[6])[0], 0x02)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[7])[0], 0x00)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[8])[0], 0x2)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[9])[0], 0x1)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[10])[0], 69)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[11])[0], 0)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[12])[0], 0)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[13])[0], 0x2)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[14])[0], 81)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[15])[0], 0)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[16])[0], 0)
     self.assertEquals(
         struct.unpack('>B', MyMIDI.tracks[0].MIDIdata[17])[0], 0xf7)
예제 #3
0
 def testTuning(self):
     MyMIDI = MIDIFile(1)
     MyMIDI.changeNoteTuning(0, [(1, 440), (2, 880)])
     MyMIDI.close()
     self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].type, "UniversalSysEx")
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[0])[0], 0x00)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[1])[0], 0xF0)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[2])[0], 15)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[3])[0], 0x7E)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[4])[0], 0x7F)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[5])[0], 0x08)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[6])[0], 0x02)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[7])[0], 0x00)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[8])[0], 0x2)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[9])[0], 0x1)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[10])[0], 69)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[11])[0], 0)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[12])[0], 0)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[13])[0], 0x2)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[14])[0], 81)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[15])[0], 0)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[16])[0], 0)
     self.assertEquals(struct.unpack(">B", MyMIDI.tracks[0].MIDIdata[17])[0], 0xF7)
예제 #4
0
#!/usr/bin/python
from midiutil.MidiFile import MIDIFile, frequencyTransform
MyMIDI = MIDIFile(1)
tuning = [(63, 320.24370022528126), (70, 479.82340237271336)]

print(320.24370022528126, frequencyTransform(320.24370022528126))
print(479.82340237271336, frequencyTransform(479.82340237271336))
print(362.93866150753314, frequencyTransform(362.93866150753314))

MyMIDI.changeNoteTuning(0, tuning)
MyMIDI.addNote(0, 0, 60, 0, 1, 100)
MyMIDI.addNote(0, 0, 62, 1, 1, 100)
MyMIDI.addNote(0, 0, 63, 2, 1, 100)
MyMIDI.addNote(0, 0, 65, 3, 1, 100)
MyMIDI.addNote(0, 0, 67, 4, 1, 100)
MyMIDI.addNote(0, 0, 69, 5, 1, 100)
MyMIDI.addNote(0, 0, 70, 6, 1, 100)
MyMIDI.addNote(0, 0, 72, 7, 1, 100)
with open("mymidifile.mid", 'wb') as output_file:
    MyMIDI.writeFile(output_file)