General
Convert hex to ascii?
Started by iPad_User on .
Sign in or create an account to join the conversation.
Hey people,
for my actual lemur template I'd like to convert a sysex string to a ascii text.
When searching the forum I found two code examples that might help on this:
This first one converts a sysex array to hex numbers:
I now have an OnMidi script on a monitor object which contains:
Could anybody help me with the next step?
Thanks,
Chris
for my actual lemur template I'd like to convert a sysex string to a ascii text.
When searching the forum I found two code examples that might help on this:
This first one converts a sysex array to hex numbers:
decl a, b, c , i;
c = sizeof(array)*3-1;
if(c>255) return({0x00}); // array size limit
a = fill(1,0x20,c);
// break up each number into two nibbles of 4 bits each.
// If the nibble is 9 or less, it's a number and add 30h to it.
// ASCII '0' is 0x30
// If the nibble is greater than 9, add 0x37 to it.
// ASCII 'a' is
for(i = 0; i < c; i++)
{
b = array[i] >> 4;
a[i*3] = b > 9 ? b+55 : b+48;
b = array[i] & 0xF;
a[i*3+1] = b > 9 ? b+55 : b+48;
}
return arraytostring(a);
And this one should do a conversion of hex to ascii:decl val=car;
if(car == '0') val = 0x30;
if(car == 0) val = 0x30;
else if(car == '\') val = 0x5C;
else if(car == '/') val = 0x2F;
else if(car == '1') val = 0x31;
else if(car == '2') val = 0x32;
else if(car == '3') val = 0x33;
else if(car == '4') val = 0x34;
else if(car == '5') val = 0x35;
else if(car == '6') val = 0x36;
else if(car == '7') val = 0x37;
else if(car == '8') val = 0x38;
else if(car == '9') val = 0x39;
else if(car == 1) val = 0x31;
else if(car == 2) val = 0x32;
else if(car == 3) val = 0x33;
else if(car == 4) val = 0x34;
else if(car == 5) val = 0x35;
else if(car == 6) val = 0x36;
else if(car == 7) val = 0x37;
else if(car == 8) val = 0x38;
else if(car == 9) val = 0x39;
else if(car == 'a') val = 0x61;
else if(car == 'b') val = 0x62;
else if(car == 'c') val = 0x63;
else if(car == 'd') val = 0x64;
else if(car == 'e') val = 0x65;
else if(car == 'f') val = 0x66;
else if(car == 'g') val = 0x67;
else if(car == 'h') val = 0x68;
else if(car == 'i') val = 0x69;
else if(car == 'j') val = 0x6A;
else if(car == 'k') val = 0x6B;
else if(car == 'l') val = 0x6C;
else if(car == 'm') val = 0x6D;
else if(car == 'n') val = 0x6E;
else if(car == 'o') val = 0x6F;
else if(car == 'p') val = 0x70;
else if(car == 'q') val = 0x71;
else if(car == 'r') val = 0x72;
else if(car == 's') val = 0x73;
else if(car == 't') val = 0x74;
else if(car == 'u') val = 0x75;
else if(car == 'v') val = 0x76;
else if(car == 'w') val = 0x77;
else if(car == 'x') val = 0x78;
else if(car == 'y') val = 0x79;
else if(car == 'z') val = 0x7A;
else if(car == 'A') val = 0x41;
else if(car == 'B') val = 0x42;
else if(car == 'C') val = 0x43;
else if(car == 'D') val = 0x44;
else if(car == 'E') val = 0x45;
else if(car == 'F') val = 0x46;
else if(car == 'G') val = 0x47;
else if(car == 'H') val = 0x48;
else if(car == 'I') val = 0x49;
else if(car == 'J') val = 0x4A;
else if(car == 'K') val = 0x4B;
else if(car == 'L') val = 0x4C;
else if(car == 'M') val = 0x4D;
else if(car == 'N') val = 0x4E;
else if(car == 'O') val = 0x4F;
else if(car == 'P') val = 0x50;
else if(car == 'Q') val = 0x51;
else if(car == 'R') val = 0x52;
else if(car == 'S') val = 0x53;
else if(car == 'T') val = 0x54;
else if(car == 'U') val = 0x55;
else if(car == 'V') val = 0x56;
else if(car == 'W') val = 0x57;
else if(car == 'X') val = 0x58;
else if(car == 'Y') val = 0x59;
else if(car == 'Z') val = 0x5A;
return val;
But I now don't know how to bring both codes together, so that I can send a sysex string like F0 48 61 6c 6c 6f (which is just F0 for sysex and the word "Hello" as hex) to lemur and it prints Hello on a monitor-object (or text-object).I now have an OnMidi script on a monitor object which contains:
Monitor.value=arraytohex(MIDI_ARGS);
This works fine. Could anybody help me with the next step?
Thanks,
Chris
Has no one an idea how to convert a sysEx string to readable informations?
f.e. with this message
Any help?
f.e. with this message
F0 00 00 66 10 12 00 48 65 6C 6C 6F F7
I'm able to print "Hello" onto a surfaceLCD. But the surfaceLCD is limited in numbers of characters and also the width is fixed. That's why I want to use a text- or a monitor-object. So I'd need something, that converts 48 65 6C 6C 6F to chars...Any help?
I think Macciza did something like that with his custom display and his AlphaTrack template. But I'm not sure, because that was the point where I couldn't follow anymore.