- commit
- 2bfbd59bf73e68b300174495f2c0589ad485f83a
- parent
- 322a09be2976cdf60a89616840d85875f580d0c9
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-09-18 15:39
style: spaces around operators
Diffstat
| M | iparser.py | 6 | +++--- |
| M | midi.py | 8 | ++++---- |
2 files changed, 7 insertions, 7 deletions
diff --git a/iparser.py b/iparser.py
@@ -24,7 +24,7 @@ class IParser: 24 24 25 25 def parse_el(self, e): 26 26 if e.isdigit(): # note27 -1 self.midi.note_on(self.dt, self.ch, self.offset+int(e), 1)-1 27 self.midi.note_on(self.dt, self.ch, self.offset + int(e), 1) 28 28 self.dt = self.dt_step() 29 29 elif e == '-': # continue 30 30 self.dt += self.dt_step() @@ -74,7 +74,7 @@ class IParser: 74 74 elif e == '': 75 75 pass # already stopped 76 76 elif e.isdigit():77 -1 self.midi.note_off(self.dt, self.ch, self.offset+int(e), 1)-1 77 self.midi.note_off(self.dt, self.ch, self.offset + int(e), 1) 78 78 self.dt = 0 79 79 else: 80 80 pass @@ -85,7 +85,7 @@ class IParser: 85 85 # we already checked the validity of the set when parsing. 86 86 # we only need to check if this is a note, lyrics or '-' 87 87 if ee.isdigit():88 -1 self.midi.note_off(self.dt, self.ch, self.offset+int(ee), 1)-1 88 self.midi.note_off(self.dt, self.ch, self.offset + int(ee), 1) 89 89 self.dt = 0 90 90 else: 91 91 raise Exception("Unexpected object on stack: " + e)
diff --git a/midi.py b/midi.py
@@ -24,10 +24,10 @@ class Midi: 24 24 25 25 def write_fixed(self, n, k): 26 26 if type(n) == type(''):27 -1 self._buf += (' '*k + n)[-k:]-1 27 self._buf += (' ' * k + n)[-k:] 28 28 else: 29 29 if k != 0:30 -1 self.write_fixed(n / 0x100, k-1)-1 30 self.write_fixed(n / 0x100, k - 1) 31 31 self._buf += chr(n % 0x100) 32 32 33 33 def write_variable(self, n, _rec=False): @@ -62,7 +62,7 @@ class Midi: 62 62 63 63 def set_tempo(self, bpm): 64 64 # midi uses microsec/quarter note65 -1 msqn = 60000000/bpm-1 65 msqn = 60000000 // bpm 66 66 self.meta_event(0, 0x51, 3, msqn) 67 67 68 68 def note_on(self, dt, ch, key, vol=1): @@ -98,7 +98,7 @@ class MidiFile(Midi): 98 98 self.write_fixed(TIME_DEVISION, 2) # time devision 99 99 for track in self._tracks: 100 100 self.write_fixed(0x4D54726B, 4) # chunk ID "MTtr"101 -1 self.write_fixed(len(track._buf)+4, 4) # chunk size-1 101 self.write_fixed(len(track._buf) + 4, 4) # chunk size 102 102 self._buf += track._buf 103 103 self.meta_event(0, 0x2f, 0, '') # end_track event 104 104