57f4c7e7b5beae40b8141ac7613f46d6e9f38610
1 # -*- coding: ISO-8859-1 -*-
3 from RawInstreamFile
import RawInstreamFile
4 from MidiFileParser
import MidiFileParser
11 Parses a midi file, and triggers the midi events on the outStream
14 Get example data from a minimal midi file, generated with cubase.
15 >>> test_file = 'C:/Documents and Settings/maxm/Desktop/temp/midi/src/midi/tests/midifiles/minimal-cubase-type0.mid'
17 Do parsing, and generate events with MidiToText,
18 so we can see what a minimal midi file contains
19 >>> from MidiToText import MidiToText
20 >>> midi_in = MidiInFile(MidiToText(), test_file)
22 format: 0, nTracks: 1, division: 480
23 ----------------------------------
28 time_signature: 4 2 24 8
29 note_on - ch:00, note:48, vel:64 time:0
30 note_off - ch:00, note:48, vel:40 time:480
38 def __init__(self
, outStream
, infile
):
39 # these could also have been mixins, would that be better? Nah!
40 self
.raw_in
= RawInstreamFile(infile
)
41 self
.parser
= MidiFileParser(self
.raw_in
, outStream
)
45 "Start parsing the file"
51 def setData(self
, data
=''):
52 "Sets the data from a plain string"
53 self
.raw_in
.setData(data
)