mirror of
https://github.com/janishutz/midi-micro-bit_sound-converter.git
synced 2025-11-25 13:54:26 +00:00
Bugfix: Note_off instruction was ignored and interpreted as a note_on instruction. Now is fixed and as such the sound should be improved
This commit is contained in:
@@ -28,35 +28,56 @@ class MidiManagement:
|
|||||||
for self.msg in self.midi_imp.tracks[self.trackn]:
|
for self.msg in self.midi_imp.tracks[self.trackn]:
|
||||||
self.ext = str(self.msg)
|
self.ext = str(self.msg)
|
||||||
self.note = self.ext[23:25]
|
self.note = self.ext[23:25]
|
||||||
try:
|
print(self.ext[0:8])
|
||||||
self.note_height = int(self.note)
|
if self.ext[0:8] == "note_on ":
|
||||||
self.note_decod_oct = self.note_height // 12
|
try:
|
||||||
self.note_decode_tone = self.note_height % 12
|
self.note_height = int(self.note)
|
||||||
if self.note_decode_tone == 1:
|
self.note_decod_oct = self.note_height // 12
|
||||||
self.note_ext = "C"
|
self.note_decode_tone = self.note_height % 12
|
||||||
elif self.note_decode_tone == 2:
|
if self.note_decode_tone == 1:
|
||||||
self.note_ext = "C#"
|
self.note_ext = "C"
|
||||||
elif self.note_decode_tone == 3:
|
elif self.note_decode_tone == 2:
|
||||||
self.note_ext = "D"
|
self.note_ext = "C#"
|
||||||
elif self.note_decode_tone == 4:
|
elif self.note_decode_tone == 3:
|
||||||
self.note_ext = "D#"
|
self.note_ext = "D"
|
||||||
elif self.note_decode_tone == 5:
|
elif self.note_decode_tone == 4:
|
||||||
self.note_ext = "E"
|
self.note_ext = "D#"
|
||||||
elif self.note_decode_tone == 6:
|
elif self.note_decode_tone == 5:
|
||||||
self.note_ext = "F"
|
self.note_ext = "E"
|
||||||
elif self.note_decode_tone == 7:
|
elif self.note_decode_tone == 6:
|
||||||
self.note_ext = "F#"
|
self.note_ext = "F"
|
||||||
elif self.note_decode_tone == 8:
|
elif self.note_decode_tone == 7:
|
||||||
self.note_ext = "G"
|
self.note_ext = "F#"
|
||||||
elif self.note_decode_tone == 9:
|
elif self.note_decode_tone == 8:
|
||||||
self.note_ext = "G#"
|
self.note_ext = "G"
|
||||||
elif self.note_decode_tone == 10:
|
elif self.note_decode_tone == 9:
|
||||||
self.note_ext = "A"
|
self.note_ext = "G#"
|
||||||
elif self.note_decode_tone == 11:
|
elif self.note_decode_tone == 10:
|
||||||
self.note_ext = "A#"
|
self.note_ext = "A"
|
||||||
elif self.note_decode_tone == 12:
|
elif self.note_decode_tone == 11:
|
||||||
self.note_ext = "H"
|
self.note_ext = "A#"
|
||||||
|
elif self.note_decode_tone == 12:
|
||||||
|
self.note_ext = "H"
|
||||||
|
|
||||||
|
self.ext_shortened = self.ext[40:]
|
||||||
|
self.pos = 0
|
||||||
|
for buchstabe in self.ext_shortened:
|
||||||
|
if buchstabe == "=":
|
||||||
|
self.pos += 1
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
self.pos += 1
|
||||||
|
|
||||||
|
self.timing_exp = self.ext_shortened[self.pos:]
|
||||||
|
self.__output = self.note_ext
|
||||||
|
self.__output += str(self.note_decod_oct)
|
||||||
|
self.__output += f":{self.timing_exp}"
|
||||||
|
self.__output_list.append(str(self.__output))
|
||||||
|
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
elif self.ext[0:8] == "note_off":
|
||||||
|
print("ok")
|
||||||
self.ext_shortened = self.ext[40:]
|
self.ext_shortened = self.ext[40:]
|
||||||
self.pos = 0
|
self.pos = 0
|
||||||
for buchstabe in self.ext_shortened:
|
for buchstabe in self.ext_shortened:
|
||||||
@@ -65,17 +86,13 @@ class MidiManagement:
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.pos += 1
|
self.pos += 1
|
||||||
|
self.__output = "R"
|
||||||
|
self.__output += f":{self.pos}"
|
||||||
|
|
||||||
self.timing_exp = self.ext_shortened[self.pos:]
|
self.timing_exp = self.ext_shortened[self.pos:]
|
||||||
self.__output = self.note_ext
|
self.__output_list.append(self.__output)
|
||||||
self.__output += str(self.note_decod_oct)
|
else:
|
||||||
self.__output += f":{self.timing_exp}"
|
print("error \n")
|
||||||
self.__output_list.append(str(self.__output))
|
|
||||||
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
self.addToClipboard(str(self.__output_list))
|
self.addToClipboard(str(self.__output_list))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user