- commit
- 4b2ce16ce4b281c4f9c86bc83f2862539a2e7e7a
- parent
- 2212b6af11098bba9f5a1d9d725c8ef07275e3e1
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-09-18 15:00
style: basic formatting
Diffstat
| M | iparser.py | 13 | +++++-------- |
| M | midi.py | 8 | ++++---- |
| M | xi2.py | 7 | ++----- |
3 files changed, 11 insertions, 17 deletions
diff --git a/iparser.py b/iparser.py
@@ -1,15 +1,11 @@1 -1 #!/usr/bin/env python2 -13 1 from midi import * 4 25 -1 """6 -1 The tricky part here is the time conversion.7 -1 and noteOff events8 -1 """-1 3 # The tricky part here is the time conversion. -1 4 # and noteOff events -1 5 9 6 10 7 class IParser:11 -1 # creates midi events from intermediate code12 -1 # and than uses midi to create midi bytecode-1 8 """Convert intermediate code to MIDI bytecode.""" 13 9 14 10 def __init__(self, seq, ch=0, offset=60): 15 11 self.midi = Midi() @@ -91,6 +87,7 @@ class IParser: 91 87 else: 92 88 raise Exception("Unexpected object on stack: " + e) 93 89 -1 90 94 91 if __name__ == '__main__': 95 92 a = [(('0', '1'), '2'), '4', '5', '-', '', ['0', '4', '7'], '', '', '0', ['3', '-']] 96 93
diff --git a/midi.py b/midi.py
@@ -1,11 +1,10 @@1 -1 #!/usr/bin/env python2 -13 1 # http://www.sonicspot.com/guide/midifiles.html 4 2 5 3 timeDevision = 0x00c0 # two bytes 6 4 -1 5 7 6 class Midi:8 -1 # creates midi bytecode from midi events-1 7 """Create MIDI bytecode from MIDI events.""" 9 8 10 9 def __init__(self): 11 10 self._buf = '' @@ -83,8 +82,8 @@ class Midi: 83 82 def setVol(self, dt, ch, vol=1): 84 83 self.ctrlEvent(dt, ch, 0x07, int(vol * 0x7f)) 85 8486 -1 class MidiFile(Midi):87 85 -1 86 class MidiFile(Midi): 88 87 def __init__(self): 89 88 Midi.__init__(self) 90 89 self._tracks = [] @@ -107,6 +106,7 @@ class MidiFile(Midi): 107 106 if update: 108 107 self.update() 109 108 -1 109 110 110 if __name__ == '__main__': 111 111 # Example: 112 112 f = MidiFile()
diff --git a/xi2.py b/xi2.py
@@ -1,12 +1,9 @@1 -1 #!/usr/bin/env python2 -1-1 1 import argparse 3 2 import re 4 3 from iparser import IParser 5 4 from midi import Midi, MidiFile6 -1 import argparse7 58 -1 # creates indermediate code from xi2 code9 -1 # and than uses iparser to create midi bytecode-1 6 """Parse xi2 code and convert to MIDI.""" 10 7 11 8 parser = argparse.ArgumentParser() 12 9 parser.add_argument('-t', '--tempo', help="tempo in bpm", default=120, type=int)