local function stringtosysex(text)
local event=remote.make_midi("f0 11 22 33 10")
start=6
stop=6+string.len(text)-1
for i=start,stop do
sourcePos=i-start+1
event[i] = string.byte(text,sourcePos)
end
event[stop+1] = 247 -- hex f7
Hi
My reading of it is that it is just sticking the chars into the correct positions in the sysex string . .
I would guess the string.byte() function is returning ascii codes for the letters . . .
So you could use the arraytostring() function in Lemur to convert it back to chars.
Do a quick test to confirm - name your Device as '1' which would give a sysex of "f0 11 22 33 10 49 247" - 49 is ascii for 1 -
So the MIDI_ARGS results would be 11 22 33 10 49 247 as it strips the inital f0
So with script executing on Midi -sysex , if the subarray of the first 4 bytes = 11 22 33 10 then grab the data up to 247 and arraytostring it
thx for the help. I was already trying to build ASCII tables and loop through it
There is one little Problem left. When i arraytostring the subarray with scope=artraytostring(MIDI_ARGS,4,length-5) and monitor scope, i get the name of the device correctly but in a monitor it is displayed in "" eg "Thor".
Now i want to use it to switch templates and need to ask eg if(scope=='Thor') but that doesnt work neither does if (scope=='"Thor"){}. I get weird results with the latter. Upon releasing the script it strips the if clause up to the ==, after reloading it accepts the same but blues out (?) the last '" so i assume that isnt conform with the syntax.
How do i go about using the arraytostring in if clauses?
Hi
I guess there are 2 ways to approach this - as ascii or text .. .
1. Work out the ASCII string involved using an ascii table or lemur module ie Thor is {84,104,111,114} - which is what should be returned by your subarray . . .
so if(MIDI_ARGS,4,length-5)=={84,104,111,114} then etc etc . . . Maybe put a comment reminding you what the array stands for . . .
2. Using arraytostring() and text - The "" denotes that it is a string being shown, but in scripts single quotes ' ' delineate strings from variables . . . from memory . .
so if(arraytostring(MIDI_ARGS,4,length-5))=='Thor' then etc etc should work . . .
If you assign the ascii to a var inside the script eg scope=(MIDI_ARGS,4,length-5) then it would be if(arraytostring(scope))=='Thor' etc
You could then do Monitor.value = arraytostring(scope) . . .
Hope this right - noy actually checked for typos or anything . . ..
MM
thx again, i just read the paragraph about strings as variables and constants in the manual and figured it is going to be a bit more complicated.
I will try your two variants and get this going. I hope i will end up with a really cool Reason template which i will present here shortly.
It was really hard to get the Reason Codec to send the Sysex but now that i have it i can do all sorts of neat stuff in Lemur.
Hi
The other option is to have one script to parse the sysex as an OnMIDI script and then call other scripts to deal with the data further
You will have possibly seen this approach in a number of more complex projects
You can separate things out according to a number of criteria this way
MM
Whenever i change a track in Reason, Lemur now pulls up the correct template. No searching for the right template anymore anything is extremely fluent now.
Next i will get the tracknames into Lemur to also have the channel strips for each synth at hand, then it is done.
Getting the tracknames now was easy. I also have codedin the connected Mixerchannel into the track names (first 2 numbers correspond to the Mixerchannel) and here i stumbled over the Problem how to convert a eg 14, which comes into Lemur as ['49','52'] to a usable number. But i found a formula (number=('49'-48*10)+('52'-48)) and now i receive everything i want whenever i switch a sequencer track in Reason (Instrument, Sequencer track name, connected SSL Mixer Channel) and i can start coding in some really cool workflow enhancements. Lemur and Reason work really nice together. I hope i can finnish my project soon and deliver something nice.