Error: sysex contains bytes > 0x7f
Hi, I use ord(c) to convert names to integers and send them to Open Stage Control.
This works quite good but for some characters i get this error in CSS:
IndexError: Invalid MIDI message: Sysex messages should not contain bytes > 0x7f
Any tips how I could solve that error ? I’ve attached the CSS script file if that helps.
Regards, mj
0x7f == 127.
Data bytes have values from 0 to 127. Values from 128 to 255 are command bytes.
This link gives an overview of all unicode symbols at the available bytes from 0-127.
Additional links:
I’m no expert on the subject. I’ve been trying to get SysEx working for myself (with a Nektar Pacer) and I’ve run into the same problem before, with >0x7f.
I’ve searched around the web for a little bit, in regards to your question, but haven’t found any method on using the extended unicode symbols inside a SysEx message. I was thinking that maybe there are specialized message constructions for such occasions.
Using only the limited set of characters would be the easiest way to prevent such errors. You could set up a substitution dictionary or function for accented letters.
If your controller allows the symbols with a higher byte value inside its interface, you could try to set up a name that uses such symbols inside your controller device, then retrieve the SysEx message for that name to the log and analyze the SysEx message to see how your device constructs such names. I might try that later with the Nektar Pacer because I think it also uses symbols that aren’t found in the 0-127 range. I know there’s a _receive_midi function but I haven’t used it yet, so I don’t know how it can be used exactly.
According to your hint to limit the set of characters to ascii I tried using “string.encode(‘ascii’, ‘replace’)” instead of “ord(c)”.
To send parameter names I use:
——————
SYSEX_START = (240, 126, 2, loop_number)
parName = self.song().view.selected_track.view.selected_device.parameters[loop_number].name
string = tuple(parName.encode(‘ascii’, ‘replace’))
SYSEX_END = (247,)
sysexMsg = SYSEX_START + string + SYSEX_END
self._send_midi(sysexMsg)
——————-
I get no more errors in the Live log and characters outside of the standard ascii code will be replaced with a “?”.
So, that could be a simple method to at least avoid the error message in the log with the disadvantage of not be able to display a lot of characters…
And Open Stage Control seems to always display the correct characters with ord(c) (unicode). So, essentially it’s just the error reporting in Lives log-file that I would like to avoid.
Sign up
User registration is currently not allowed.
Hi Glenn, thank you for the hint and the useful links. Now, what would be the proper way to solve this ?
1. somehow limit the ascii code ?
2. substitute values bigger than 127 ?
3. using another conversion ? (something like “hex(ord(c)…)”)
4. or is there already a function inside ableton that could be imported and used ?
Regards, mj