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;
Can't get arraytostring() to work as advertised...
Re: Can't get arraytostring() to work as advertised...
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
Re: Can't get arraytostring() to work as advertised...
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
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Re: Can't get arraytostring() to work as advertised...
Working function:
MIDI2Str(val):
MIDI2Str(val):
Code: Select all
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 );