Midiout delay?
Midiout delay?
How can a midiout message be delayed in a script?
I guess the time function has to be used. Can someone please help me out this?
I guess the time function has to be used. Can someone please help me out this?
Re: Midiout delay?
Haven't play with that yet, but basically you need an OnFrame script, which is called about 60 times per second, but depends of the complexity of the project.
Then some variables (expression) to store the time you want the midi out and one to store the midi out message.
It can become a little tricky if you excpect more than one message to be delayed and at different time.
Then some variables (expression) to store the time you want the midi out and one to store the midi out message.
It can become a little tricky if you excpect more than one message to be delayed and at different time.
Re: Midiout delay?
I just want to delay the noteoff message that is attached to the noteon in a script.
In other words I want to define the hold/decay parameter of the note on. Still I can't see how I can use the frame function. It would have been a lot easier if there was a function to stall the script for a specific amount of time.
Maybe I should give a look at the sequencer examples. They surely use time functions.
In other words I want to define the hold/decay parameter of the note on. Still I can't see how I can use the frame function. It would have been a lot easier if there was a function to stall the script for a specific amount of time.
Maybe I should give a look at the sequencer examples. They surely use time functions.
-
- Newbie
- Posts: 18
- Joined: 08 Dec 2011 02:00
Re: Midiout delay?
You'll have to figure out the syntax, but you should be able to do something like this:
on a noteon event
...send a noteon
...oldTime = time
...trigger = true
if trigger == true and time-oldTime >= hold
...send a noteoff
...trigger = false
You probably can also do it with a multiball using its adsr.
Hope this helps.
on a noteon event
...send a noteon
...oldTime = time
...trigger = true
if trigger == true and time-oldTime >= hold
...send a noteoff
...trigger = false
You probably can also do it with a multiball using its adsr.
Hope this helps.
Last edited by armatronix on 18 Dec 2011 20:03, edited 1 time in total.
Re: Midiout delay?
Hi
Wouldn't it be better to use the time function which would allow you to set i more accurately?
MM
Wouldn't it be better to use the time function which would allow you to set i more accurately?
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: Midiout delay?
Thanks very nuch for the suggestions.
I'll try them and let you know about the results.
I'll try them and let you know about the results.
Re: Midiout delay?
Well I didn't actually try your suggestions.
I would like to decribe my situation a little bit more.
I am having a for loop sending out midiout sysex events in a script.
It's a button which scans a multislider's vector values and sends 16 different sysex messages. What I am asking is if it is possible to dealy the actual for loop. Instead of sending instantly all the 16 messages to pause for an amount of time inside the for loop.
Is it possible to di this with the time function.
Any ideas?
I am attatching this multislider.
Another problem I have is that I cannot send simultaneously more than fader because one variable inside the sysex message that corresponds to the midi channel gets stuck to the prevailing fader that moves.
I know I can setup 16 different messages and assign expicitly all the items of the vector but I don't want to do that.
I would like to decribe my situation a little bit more.
I am having a for loop sending out midiout sysex events in a script.
It's a button which scans a multislider's vector values and sends 16 different sysex messages. What I am asking is if it is possible to dealy the actual for loop. Instead of sending instantly all the 16 messages to pause for an amount of time inside the for loop.
Is it possible to di this with the time function.
Any ideas?
I am attatching this multislider.
Another problem I have is that I cannot send simultaneously more than fader because one variable inside the sysex message that corresponds to the midi channel gets stuck to the prevailing fader that moves.
I know I can setup 16 different messages and assign expicitly all the items of the vector but I don't want to do that.
- Attachments
-
- Multislider auto to sysex.zip
- (1.14 KiB) Downloaded 141 times
Re: Midiout delay?
AFAIK there is no sleep function in Lemur.
The only option I see as I stated before is to use an OnFrame script. You can use it together with the time function.
So instead of having your for loop, create a variable and set it to 16 when you need to send your sysex.
Decrease this value by one each time until it reaches 0.
Actually instaed of using the on expression trigger it's better to do everything in the on frame script taking care yourself of what has changed.
OnFrame
if( (time- prevtime) < delay) return;
d = A -x;
i = firstof(d);
if(i < sizeof(x))
{
//send your sysex for i;
A = x;
prevtime = time; // reset the timer
}
The only option I see as I stated before is to use an OnFrame script. You can use it together with the time function.
So instead of having your for loop, create a variable and set it to 16 when you need to send your sysex.
Decrease this value by one each time until it reaches 0.
Actually instaed of using the on expression trigger it's better to do everything in the on frame script taking care yourself of what has changed.
OnFrame
if( (time- prevtime) < delay) return;
d = A -x;
i = firstof(d);
if(i < sizeof(x))
{
//send your sysex for i;
A = x;
prevtime = time; // reset the timer
}
Re: Midiout delay?
Thanks man for the script.
I am getting into the time scripting idea slowly.
The script works overy well for delaying a message.
However it relys on the timing of Lemur.
To get more specific I am trying to build some pads that send continuus midi notes delayed according to a bpm setting and note value. Like mpc has the note repeat function.
Regarding timing and the delay method that you've kindly suggested it works fine but the problem is that I can't trigger the notes the time that I press the pad. THe notes get triggered according to the internal timimg of Lemur.
How could possibly trgger for eg a sequence of 16th midi notes from pad as long as the pad is being held. I guess I have to find out how the sequencer tempates work. I tried but I couldn't make it.
Any help would be highly appreciated.
I am getting into the time scripting idea slowly.
The script works overy well for delaying a message.
However it relys on the timing of Lemur.
To get more specific I am trying to build some pads that send continuus midi notes delayed according to a bpm setting and note value. Like mpc has the note repeat function.
Regarding timing and the delay method that you've kindly suggested it works fine but the problem is that I can't trigger the notes the time that I press the pad. THe notes get triggered according to the internal timimg of Lemur.
How could possibly trgger for eg a sequence of 16th midi notes from pad as long as the pad is being held. I guess I have to find out how the sequencer tempates work. I tried but I couldn't make it.
Any help would be highly appreciated.
Re: Midiout delay?
The idea is the same, if you have a tempo of 100 bpm this means that a beat is played every 0.6 sec (60/100) and as a 1/16 is a quarter of a beat your delay is then 0.15 sec.
The other option is to sync to an external midi clock, in this case you need to watch incoming midi clock values. I made a small template that shows how it works somewhere in this forum. As there are 24 midi ticks per beat, trigger a note every 6 ticks for 1/16 th. Note that this method is not very good due to midi jitter, normally a sequencer will use it's internal clock and adjust smoothly to the incomming midi clocks.
To trigger notes only when you press a button, in the on frame script check the state of your button, if it's value is one then send the note(s), otherwise just leave the procedure. But don't forget to send note off or you may have hanging notes.
The other option is to sync to an external midi clock, in this case you need to watch incoming midi clock values. I made a small template that shows how it works somewhere in this forum. As there are 24 midi ticks per beat, trigger a note every 6 ticks for 1/16 th. Note that this method is not very good due to midi jitter, normally a sequencer will use it's internal clock and adjust smoothly to the incomming midi clocks.
To trigger notes only when you press a button, in the on frame script check the state of your button, if it's value is one then send the note(s), otherwise just leave the procedure. But don't forget to send note off or you may have hanging notes.