Page 1 of 1

'Keep Alive' clock

Posted: 31 May 2012 05:38
by DES
Continuing on my quest to control my light packs, I've found that they have an internal reset/shutoff feature. If they don't receive a note on command within 10 minutes they shut off. So, what I want to do is to be able to resend all of the current Note On settings or at least one per box. I found a few counter scripts in the forum and on the Jazz Mutant site, however I'm not quite sure how to get the Note On commands to re-transmit. I was thinking of including a variable called KA and have it get set to a '1' every 5 minutes or so and then multiply my individual channel volumes by that variable.

Code: Select all

x*master.x*127*Ygain.x*KA
Multiplying by a 1 shouldn't change anything. I suppose I could do a loop and reset it to something like .999999 and it shouldn't change the volume noticably...actually I just plugged the number in and it works fine... Maybe toggle back and forth between the two. I'm hoping that changing this value will cause Lemur to output the Note On commands everytime it changes. The other values in the expression are for a Master level and a channel gain.

So any ideas how I could script something that would generate this variable? I'm just getting started in C++ and scripting and I'm having a bit of a brain freeze figuring out where to start...

Also - one of the scripts I looked at had a variable called 'thetime' and it seemed to work. Is this the same variable as 'time' in the current Lemur internal commands?

Thanks!

Dave

Re: 'Keep Alive' clock

Posted: 31 May 2012 10:47
by Macciza
Hi
Check Chapter 13.3 in the manual

The 'time' function in Lemur returns millisecond values (at clock rate) since Lemur started and resets to zero every hour

So one solution for your 'running status' problem would be an 'OnFrame' script that checks if a set time variable is reached, if not exits
If the time is reached it sends your MIDI message then sets the next time set time variable

I find it more like C syntactically but with an 'objecty' layer involved . .

Cheers
MM

Re: 'Keep Alive' clock

Posted: 03 Jun 2012 01:10
by DES
Ok, so I'm not having a lot of luck with this... :( I was thinking of some possibly better ideas and I think it might be better to send one note - #127 - at a timed interval with a random note velocity. That particular note doesn't seem to cause the light boxes to go nuts and trigger built in patterns and such.

I've been working with the time feature and thought a script I called 'trigger' which is like this should work:

Code: Select all

if(time % 20 ==20)noteout(0,3,64,0);
The idea being to send every 20 seconds a note out on interface 0, note 3 (this is connected to a light so i can see if it is outputting data - the working version would use 127), velocity 64 and channel 1. Doesn't seem to be doing it though.

I also tried using the rand feature hoping to generate a random velocity between zero and 100 - but not sure if I was implementing it correctly:

Code: Select all

if(time % 20 ==20)noteout(0,3,(rand()*100),0);
Didn't work either. I've tried setting the execution to On Frame and On Expression - but still no joy.

Am I correct in that just having a script like this (but working) should be able to send a note every timed interval or does it have to be triggered by something else?

Thanks in advanced for any help!

Re: 'Keep Alive' clock

Posted: 03 Jun 2012 04:40
by Macciza
Hi
Have a look at the Resettable Counter and Pause Rest counter projects in the Liine Library
http://liine.net/en/community/user-library/view/81/ http://liine.net/en/community/user-library/view/72/
Use the backend of either and then just use or watch the counter .

Also I think %20 never actually reaches 20 - it would be better to test for 0 - when it rolls over .(or 1) . .
Cheers
MM

Re: 'Keep Alive' clock

Posted: 05 Jun 2012 03:54
by DES
Thanks for the info! I looked at them but wasn't seeing what I think you wanted me to see. I could get the counters working but for some reason the data wasn't being sent. I'm wondering if the data changes were happening too fast for them to be captured by the midi light boxes.

So, after more head scratching I approached this from a different angle and decided to use a Custom MIDI message. This is actually working now and is so much simpler then what I was initially trying to do. I'm including what I did so anyone looking to do something similar can see what is working for me.

I created a custom Midi message called KeepAlive. In the Mapping section at the top left under MIDI I set the target to Midi 0, Message to 90 - Note On. Pitch to 127 - I set it's triggering to none...wouldn't matter where it was at the pitch was not going to change. Velocity was set to:

Code: Select all

(rand()*50) 
and trigger set to none. This supposedly will give me random velocity levels up to 50 (could have used any value here) every time the Note On message was sent. Scale is unchecked, channel set to 1 and it's trigger I left on 'any' but it's not changing anyways. The time interval for the Note On message to be sent is done with Trigger, which I set to:

Code: Select all

floor(time%180)
The trigger is set to change from 0 up (up arrow). This gives me a 3 minute reset note on message.

Interestingly enough I could have just used the '(rand()*50)' in the velocity and set it's trigger to the up arrow change with nothing in the Trigger slot below. This was working but I felt it was going to fast and since I only needed it every couple of minutes, why make Lemur work so hard. Would be nice to have a rate adjustment for the 'rand' function...

Re: 'Keep Alive' clock

Posted: 05 Jun 2012 05:12
by Macciza
Hi
Well done - as the old adage go "There's more than one way to skin a Lemur . . . "
I have sometimes have to remember to set myself the task of doing something without scripting

With those counter scripts various options would be possible using the logic part
if counter =10 then noteout and reset_counter; type of thing- can't remember the actual variables . . .

Custom MIDI messages can be quite powerful with very little work.
The key here with your trigger is that it is transitioning through 0>1 every 180 seconds and triggering . . .
I guess it's really no different than watching for that in an OnFrame script and sending a noteout etc
Perhaps you can nut out the scripted solution now you've worked it out . . .

Cheers
MM

PS- I don't always just give the direct, full answer on the Forum preferring to lead others to their own discoveries . . .