]> git.donarmstrong.com Git - lilypond.git/commitdiff
midi2ly: replace unprintables with ~
authorDrTechDaddy <DrTechDaddy@gmail.com>
Mon, 16 Jan 2017 20:46:38 +0000 (15:46 -0500)
committerGraham Percival <graham@percival-music.ca>
Wed, 1 Feb 2017 17:19:48 +0000 (09:19 -0800)
scripts/midi2ly.py

index d1fd1ab916e11b762bdfea5fcdfd4e799054f0d2..9c490a5f2caf95bd737fee5046878054f69ab364 100644 (file)
@@ -386,10 +386,17 @@ class Text:
         'PROGRAM_NAME',
         'DEVICE_NAME', )
 
+    @staticmethod
+    def _text_only(chr):
+        if ((' ' <= chr <= '~') or chr in ['\n','\r']):
+            return chr
+        else: 
+            return '~'
+
     def __init__ (self, type, text):
         self.clocks = 0
         self.type = type
-        self.text = text
+        self.text =''.join(map(self._text_only, text))
 
     def dump (self):
         # urg, we should be sure that we're in a lyrics staff