General
Can't get arraytostring() to work as advertised...
Started by TheBayer on .
Sign in or create an account to join the conversation.
Does anyone know what I'm doing wrong here? the output seems to only be the first element of the array and not a concatenation of all the elements. I'm sure it's something stupidly simple, but I just am not seeing the problem.
Thanks,
-Eric
MIDI2Str(val):
decl num_strs = { '-2', '-1', '0', '1', '2', '3', '4', '5', '6', '7', '8' };
decl key_strs = { 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B' };
decl rval = { key_strs[val%12], num_strs[floor(val/12)] };
arraytostring( rval );
return rval;
Thanks,
-Eric
MIDI2Str(val):
decl num_strs = { '-2', '-1', '0', '1', '2', '3', '4', '5', '6', '7', '8' };
decl key_strs = { 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B' };
decl rval = { key_strs[val%12], num_strs[floor(val/12)] };
arraytostring( rval );
return rval;
arraytostr only works with hexadecimal values like 0x30
ask for ascii code in google and you will find how to convert them.
and there is this alternative:
http://liine.net/forum/viewtopic.php?f=25&t=1096
ask for ascii code in google and you will find how to convert them.
and there is this alternative:
http://liine.net/forum/viewtopic.php?f=25&t=1096
Hi
thought I'd answered this previously, . . .
arraytostring converts decimal as well hexidecimal, not sure about octal . . .
But you don't need to do that because they are already strings.
Also in your script the arraytostring(rval) seems to do nothing - you may need to re-assign ie rval =arraytostring(rval)
But then you would need to build your arrays as ascii numbers for arraytostring to work . .
Using your function as is or with that line commented out should work in a Monitor
But it does seem to truncate using set attribute ?? not sure what is going on there
Hope that helps
MM
thought I'd answered this previously, . . .
arraytostring converts decimal as well hexidecimal, not sure about octal . . .
But you don't need to do that because they are already strings.
Also in your script the arraytostring(rval) seems to do nothing - you may need to re-assign ie rval =arraytostring(rval)
But then you would need to build your arrays as ascii numbers for arraytostring to work . .
Using your function as is or with that line commented out should work in a Monitor
But it does seem to truncate using set attribute ?? not sure what is going on there
Hope that helps
MM
Working function:
MIDI2Str(val):
MIDI2Str(val):
decl key_strs1 = { 0x43, 0x43, 0x44, 0x44, 0x45, 0x46, 0x46, 0x47, 0x47, 0x41, 0x41, 0x42 };
decl key_strs2 = { 0x20, 0x23, 0x20, 0x23, 0x20, 0x20, 0x23, 0x20, 0x23, 0x20, 0x23, 0x20 };
decl num_strs1 = { 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
decl num_strs2 = { 0x32, 0x31, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38 };
decl rval_hex = { key_strs1[floor(val%12)], key_strs2[floor(val%12)], num_strs1[floor(val/12)], num_strs2[floor(val/12)] };
return arraytostring( rval_hex );