xi2

a plain text language that compiles to MIDI
git clone https://git.ce9e.org/xi2.git

commit
6ab94169b644700cf4c10e8d01ecbe2b21c934cc
parent
b7838fd6c2307e0a7d0cce2e725a0c45a9250bf8
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-09-18 22:06
pass midi to IParser

Diffstat

M iparser.py 9 +++++----
M xi2.py 3 +--

2 files changed, 6 insertions, 6 deletions


diff --git a/iparser.py b/iparser.py

@@ -7,8 +7,8 @@ import midi
    7     7 class IParser:
    8     8     """Convert intermediate code to MIDI bytecode."""
    9     9 
   10    -1     def __init__(self, seq, ch=0, offset=60):
   11    -1         self.midi = midi.Midi()
   -1    10     def __init__(self, midi, seq, ch=0, offset=60):
   -1    11         self.midi = midi
   12    12         self.ch = ch
   13    13         self.offset = offset
   14    14         self.dt = 0
@@ -93,7 +93,8 @@ class IParser:
   93    93 
   94    94 if __name__ == '__main__':
   95    95     a = [(('0', '1'), '2'), '4', '5', '-', '', ['0', '4', '7'], '', '', '0', ['3', '-']]
   96    -1     ip = IParser(a, 0, 60)
   -1    96     t = midi.Midi()
   -1    97     ip = IParser(a, t, 0, 60)
   97    98 
   98    99     with open('test.mid', 'wb') as fh:
   99    -1         midi.write_file(fh, [ip.midi])
   -1   100         midi.write_file(fh, [t])

diff --git a/xi2.py b/xi2.py

@@ -119,8 +119,7 @@ for name, track in tracks.items():
  119   119         prog = 0
  120   120     m.prog_ch(0, ch, prog)
  121   121     # write data
  122    -1     ip = IParser(track, ch=ch, offset=args.offset)
  123    -1     m += ip.midi
   -1   122     IParser(m, track, ch=ch, offset=args.offset)
  124   123     # write
  125   124     midi_tracks.append(m)
  126   125     ch += 1