Double click code

Image_Engine

2008-06-08 08:45:05

Hi All
Just finishing the last item for version 1 of my rig:
I have footswitch 10 on the FCB footboard as a dedicated tap/stop switch. I want quick taps to send note on #10 (remote tap temp button in Live) but if I hold for longer than 2 secs then I want it to wait for the pedal up to send note #0 (stop). I have been wrestling for a couple of hours now and I should have posted earlier so that the gurus might spend 30 secs :)
Cheers
Mark

Tuur

2008-06-08 22:14:08

I suppose the quick tap part works?

Is it a problem when you also send out that tap tempo note once when you want to stop? AFAIK it's no problem in Live right?

If so, try something like this (replace the incoming and outgoing midi messages with your own):

Code: Select all

Translator 1: Pedal down
Options: stop=false
Incoming: Tap pedal
Rules: 
  g1=0
Outgoing: One-shot timer "HoldDelay": 2000 ms delay

Translator 2: Stop check
Options: stop=false
Incoming: On timer "HoldDelay"
Rules: 
  g1=1
Outgoing: (none)

Translator 3: Stop
Options: stop=false
Incoming: Release pedal
Rules: 
  if g1!=1 then exit rules, skip Outgoing Action
Outgoing: Stop message

Image_Engine

2008-06-09 03:42:22

Hi Tuur
Didnt really work :(
1. If the pedal up occurs within say 30ms then I know Im doing a tap; send NoteNum10
2. If not then run an infinite loop that checks for pedal up. When pedal up is detected then send NN#0
Its actually pretty tricky for such a simple thing; in my mind anyway
Regs
Mark

Tuur

2008-06-09 08:50:52

What part doesn't work (I assumed you already had the translator for the tap tempo)? Do you only want to send midi on pedal up (nothing on down)?

I did think of one possible problem when I was in bed; but it depends on how the timers work. To be save, you should also kill the timer on a pedal up I guess.

I'll look at it tonight... If you post your midi codes (in + out) I'll put 'm in too.

Image_Engine

2008-06-09 10:08:33

Hi Tuur
This is actually the requirement
1. If the pedal up occurs within say 10ms then I know Im doing a tap; send NoteNum10
2. If not then run an infinite loop that checks for pedal up. When pedal up is detected then send NN#0
I got it working with an infinite timer looking for the pedal up. ie once the pedal was held down, I wanted to use the actual pedal up to stop on the dot. I have abandoned it because the closest time I could get to check the quick pedal was about 30ms, which, whilst short, faulted the timing. The main prob is the timing loop checking for the 'quick' pedal up. If it detects a pedal up with 30ms it kills the long pause timer and sends note #10 (tap). If held longer, it kicks in a new timer that waits for a pedal to send note #0.

Code: Select all


Translator 1: Timer_Stop
Options: stop=false
Incoming: MIDI 9C 0A 40 
Rules: 
  ge=0
Outgoing: Timer 30 times "DC": 10 ms (initial delay: 250 ms)

Translator 2: ClickUp
Options: stop=false
Incoming: MIDI 9C 0A 00 
Rules: 
  ge=1
Outgoing: (none)

Translator 3: CheckTime
Options: stop=false
Incoming: On timer "DC"
Rules: 
  if ge!=0 then exit rules, execute Outgoing Action
  if ge==0 then exit rules, skip Outgoing Action
Outgoing: MIDI 9C 0A 40 

Translator 4: CheckTime
Options: stop=true
Incoming: On timer "DC"
Rules: 
  if ge!=0 then exit rules, execute Outgoing Action
  if ge==0 then exit rules, skip Outgoing Action
Outgoing: Kill timer "DC"

Translator 5: CheckTime
Options: stop=false
Incoming: On timer "DC"
Rules: 
  if ge!=0 then exit rules, execute Outgoing Action
  if ge==0 then exit rules, skip Outgoing Action
Outgoing: Periodic timer "LongStopPause": 10 ms (initial delay: 0 ms)

Translator 7: ClickUp
Options: stop=false
Incoming: On timer "LongStopPause"
Rules: 
  if ge!=0 then exit rules, execute Outgoing Action
  if ge==0 then exit rules, skip Outgoing Action
Outgoing: MIDI 9C 00 40 

Translator 8: ClickUp
Options: stop=false
Incoming: On timer "LongStopPause"
Rules: 
  if ge!=0 then exit rules, execute Outgoing Action
  if ge==0 then exit rules, skip Outgoing Action
Outgoing: Kill timer "LongStopPause"
Im not sure if that was the working version but you get the idea.
CHeers
Mark

BTW It would have been nice to get it going though!

Tuur

2008-06-09 11:32:13

It's clear now.

My general idea is this:

1. on pedal down start (2 sec) timer and reset global (set g1=0)
2. on timer set global (set g1=1)
3. on up kill timer
4. on up check global for tap (g1=0?)
5. on up check global for stop (g1=1?)

In short, I think you should be able to do it with 5 translators (my old code above + 2 extra).

I'll post the thing later today...

Tuur

2008-06-09 17:15:21

Try this...

Code: Select all

Translator 1: Pedal down
Options: stop=false
Incoming: MIDI 9C 0A 40 
Rules: 
  g1=0
Outgoing: One-shot timer "DownTime": 2000 ms delay

Translator 2: Time is up
Options: stop=false
Incoming: On timer "DownTime"
Rules: 
  g1=1
Outgoing: (none)

Translator 3: Pedal up
Options: stop=false
Incoming: MIDI 9C 0A 00 
Outgoing: Kill timer "DownTime"

Translator 4: Pedal up - tap
Options: stop=false
Incoming: MIDI 9C 0A 00 
Rules: 
  if g1!=0 then exit rules, skip Outgoing Action
Outgoing: MIDI 9C 0A 40 

Translator 5: Pedal up - stop
Options: stop=false
Incoming: MIDI 9C 0A 00 
Rules: 
  if g1!=1 then exit rules, skip Outgoing Action
Outgoing: MIDI 9C 0A 00 
I assumed 9C 0A 00 to be both pedal up and your stop mapping in Live and 9C 0A 40 for pedal down and tap.

For what it's worth, I think you could also use the pedal down for tapping if you would like that better. It would also mean one translator less. ;)

Image_Engine

2008-06-09 23:00:24

Hi Tuur
Thanks so much. Will try it out. Actually, would it be too much bother to put the pedal down version on here? It gives me a reference too! ie helps me learn. If the pedal down works for the tap and a long hold/pedal sends the stop then that would be the most ideal.
Cheers for your help
Mark

Tuur

2008-06-10 01:04:24

I've just noticed you'll need another translator anyway. But since it's 1:04 and it's been a long day I'll be back...

Need to get some sleep.

3-0!

Note to self: I need more friends who don't like beer.

Image_Engine

2008-06-10 01:40:15

Hi Tuur
It seems to still send a note on#10 regardless. At first I thought this would bother Live and when using purely midi, it doesnt. However, once you have a couple of audio clips going, a single tap note sends a glitch through the system (albeit only for an instant but not very good nonetheless).
Thats why I was testing pedal up occuring within 30 or so ms, because It would only send the #10 if the up occured within that time frame. If it where longer than 30ms then it would wait for the pedal up to send the #0.
Besides this, there is only one prob; the live clip recording is done by 2 pedal moving track prev/next. Then I simply send an enter keystroke, which if its an empty slot, initiates record. However, when a new scene is fired, the slot selection doesnt follow. Any ideas? I though Live should track the slot selection to follow the scene as well as the track which it currently does. I select a track and the selection follows/ select a scene and it remains static.
Thats it though...enough for v1.0 and then I practise with it and use it. Ive been on this for four days now...enough.
Kind regards
Mark

It might be time to search for a Spirit of a different kind, you will get more sleep:-)

Tuur

2008-06-10 09:09:32

I'll be back. It's another beautiful day over here so I'm out.

And I get enough sleep, don't worry. ;)

But hey, 3-0... What do you expect? :P

Tuur

2008-06-11 13:55:47

Image_Engine wrote:It seems to still send a note on#10 regardless.
Be sure to double check your 'midi thru' settings, because the code doesn't send one.

To be save I would recommend using other mappings in Live (other channel or note values).
However, once you have a couple of audio clips going, a single tap note sends a glitch through the system (albeit only for an instant but not very good nonetheless).
Why is that? What sort of glitch do you mean? One single tap doesn't do a thing in Live AFAIK.
Besides this, there is only one prob; the live clip recording is done by 2 pedal moving track prev/next.
Just to be sure: you mean track left/right (not scene up/down)?
However, when a new scene is fired, the slot selection doesnt follow. Any ideas?
Do you mean you also want to start recording when you fire a scene?

Tuur

2008-06-11 14:11:36

And here's the down=tap version. While it will send out a 'tap' on every down it shouldn't be a problem as Live needs multiple taps for tempo detection. It's only a problem if you want to stop right after you've tapped a new tempo...

Just to be safe, I've upped the stop timer to 2.5 seconds as Live will abandon the tempo detection process after 2 seconds.

Code: Select all

Translator 1: Pedal down
Options: stop=false
Incoming: MIDI 9C 0A 40 
Rules: 
  g1=0
Outgoing: One-shot timer "DownTime": 2500 ms delay

Translator 2: Pedal down - tap
Options: stop=false
Incoming: MIDI 9C 0A 40 
Outgoing: MIDI 9C 0A 40 

Translator 3: Time is up
Options: stop=false
Incoming: On timer "DownTime"
Rules: 
  g1=1
Outgoing: (none)

Translator 4: Pedal up
Options: stop=false
Incoming: MIDI 9C 0A 00 
Outgoing: Kill timer "DownTime"

Translator 5: Pedal up - stop
Options: stop=false
Incoming: MIDI 9C 0A 00 
Rules: 
  if g1!=1 then exit rules, skip Outgoing Action
Outgoing: MIDI 9C 0A 00 

Image_Engine

2008-06-11 14:34:50

Hi Tuur
Hope your outing was good!
Ok I will check the code again. It a bit hard to explain but I adapted the youtube live setup posted in the forum. It relies on a slot being selected and simply using enter to start rec on a blank slot or play current slot and backspace to delete slot. What happens is;

Bank 00 (on the FCB) has fswitch 1-8 selects scenes ie 1=verse1, 2=verse2 etc and fs selects a scene called 'Selah' which is usually pretty much empty. fs 10 is always a dedicated stop with the functionality we are discussing and solving here.

Bank 01 is now the editor for this selah scene (or for any of the scenes but most appropriate here). FS 1-8 select the track. A short click sends 'Enter', a medium click stops the clip and a long click sends 'backspace'.

I use an index so that when Bank 00 Preset 1 is selected, it triggers a preset which will remap the bank 01 fs's appropriately. That seems to work ok. The problem is that for this to work properly, the selection needs to follow the scene as well. I sort of have this working but the deactivate preset seems to write the globals after the newly selected code has already executed;

Code: Select all

IN : MIDI 9C 0D 40
assignment: (hf=3) = 3
IN : MIDI 9C 0D 40
OUT: activate only preset "00.03_Edit"
Deactivated preset: 00.02_Edit
IN : deactivate this preset
assignment: (he=2) = 2
Activated preset: 00.03_Edit
IN : activate this preset
assignment: (h0=72+10) = 82
assignment: (hi=hf-he) = 1
IN : activate this preset
assignment: (hi=hf-he) = 1
condition satisfied: if hi>0 then Goto "NoInvert"
assignment: (pp=hi+0) = 1
exit rules, execute Outgoing Action
OUT: Timer pp times "Repeat": 10 ms (initial delay: 500 ms)
IN : On timer "Repeat"
condition satisfied: if hi>0 then exit rules, execute Outgoing Action
OUT: Keystroke: ] 
IN : MIDI 9C 0C 40
assignment: (hf=2) = 2
IN : MIDI 9C 0C 40
OUT: activate only preset "00.02_Edit"
Activated preset: 00.02_Edit
IN : activate this preset
assignment: (h0=72+10) = 82
assignment: (hi=hf-he) = 0
IN : activate this preset
assignment: (hi=hf-he) = 0
assignment: (pp=hi*-1) = 0
exit rules, execute Outgoing Action
Deactivated preset: 00.03_Edit
IN : deactivate this preset
assignment: (he=3) = 3
OUT: Timer pp times "Repeat": 10 ms (initial delay: 500 ms)
See in the first 2 clicks Im going up the presets and it works fine but coming back down the presets the deactivation occurs much later in the processing of the code.

So basically a new scene selection should also up/down the scene ie relative mappings, so that the selection will be focused on the right track/scene slot.

I have wasted so much time I would actually be happy to pay you to do some work if you are interested. You have already sacrificed your time so much (of which Im greatful).
Now I have had a bit of time to devise what I would like I could probably give you a brief (which is probably what I should have done to start but I couldnt resist!)

Regs
Mark

BTW
I dont want Live to rec after a new scene fire. Live definitely glitches with a single tempo key...esp if the tempo is already a little different from the orig recording.

Tuur

2008-06-11 16:51:05

Image_Engine wrote:Hope your outing was good!
A couple of hours at the beach (when it's not busy) always is. Thanks. :)
See in the first 2 clicks Im going up the presets and it works fine but coming back down the presets the deactivation occurs much later in the processing of the code.
You can probably fix this by making another preset which controls the two here or changing the activation / deactivation of presets some other way.
So basically a new scene selection should also up/down the scene ie relative mappings, so that the selection will be focused on the right track/scene slot.
I do this by using an absolute mapping in Live (a dummy CC instead of up or down keystrokes!). That's the only way you can be sure where you are and it has some other advantages in my case.
You have already sacrificed your time so much (of which Im greatful).
No prob. These translators only take a couple of minutes. The hardest part is imagining what you want to do!
Now I have had a bit of time to devise what I would like I could probably give you a brief (which is probably what I should have done to start but I couldnt resist!)
You could start with a link to the movie. ;)
Live definitely glitches with a single tempo key...esp if the tempo is already a little different from the orig recording.
Please explain...

Image_Engine

2008-06-11 23:35:27

Hi Tuur
Do you have Excel on your machine? I could send you the spreadsheet with all the mapping etc and a brief ie it has comments and should be a reasonable explanation.
Cheers

Mark

Image_Engine

2008-06-12 05:15:22

Hi Tuur
Actually the design has drifted from the youtube example too much and will probably confuse the issue. I have created a mapping and brief. I have it in xl as well which has commenting in the cells and would be more informative but see if this makes sense. I can PM you if you want, either html, pdf or xl.

Here is the description

Scenario;
Clicking 00.01 (Bank 00 Footswitch 1) will fire scene 1(Intro) in Live, 00.02 will fire scene 2 (Verse 1) and so on.
Now, selecting Bank 01 should trigger a new preset in MT which will now transpose the Bank 01 footswitch note numbers (of each footswitch) using this formula;
(FootSwitchNote# - 20+ SceneNum*10). This will allow direct select of any track (1-9) and the slot will be relative to the last selected scene
ie If scene 1 was fired and then you selected bank 01, then the first fs (01.01) would send #11 (FootSwitchNote# =21, SceneNum=1, therefore 01.01 would send 21-20+1*10 = 11) . If you were on bank 00 and you selected scene 3 and chose bank 01, then fs1 would send #33 etc (each scene activates a preset which assigns its SceneNum to a global ie ha etc) A bit of an array ie tens=SceneNum and units equal tracknum.
These notes will then be mapped direct to the slots of the current scene. It will also map the Pedal A from a fixed CC7 ch13 using a simliar formula
pp = (FootSwitchNote# - 20 ): output will be ContorlChange pp oo on channel 14
The Start/Rec/Del noted in the grey presets ie 01.01-01.00 operate in this way;
A quick click (<250ms) will rec in the currently selected slot (if empty) or fire the clip in it. If the pedal is held up to 1200ms then it sends keystroke to stop the selected clip. If pedal is held longer than 2.5 secs then send backspace to delete current clip.
Stomp shift on 02.08 and 03.08 is a toggle to turn on an MT preset to turn the A pedal a into an expressio pedal for the particular patch ie from CC7 on Ch13 to CC7 on ch12/ cc6 on ch14 respectively.
My guitar synth is merged with the FCB so it probably needs to have the notenum on ch1 farmed out to another midi output to feed into Live as a track input; does the beta allow multi midi out?


If you check the mapping Im sure it (might:-) make sense. Let me know and also what it would cost etc although free would be good but I think it might take a bit of time and I dont want to be unfair.
The setup sounds complex but once its in place its fairly easy and gives me a lot of scope. Once in a scene I can direct select the slot from the same bank of fs.
Cheers
M

BTW Whereabouts in the world are you...ie the time zone cuts us off a bit. Im guessing Euro somewhere. Im in Sydney Australia.

Tuur

2008-06-14 12:16:57

Image_Engine wrote:BTW Whereabouts in the world are you...ie the time zone cuts us off a bit. Im guessing Euro somewhere. Im in Sydney Australia.
You're right. One more hint: 4-1 :mrgreen:

I'm a bit busy right now, I'll come back to you tomorrow...

Image_Engine

2008-06-15 02:45:50

Hi Tuur
Not sure about the hint!!! After having a look at the brief I had a go again myself and all is well. Patching bits of what you showed me etc I was able to get it all going and without changing presets. I program parametrics for a living; it was just very hard getting my hear around mt because of the previous way of thinking. I think my lack of inital understanding about Live was the main prob (and the nature of MT)
Very happy with the result though. I suppose Ill have to fork out the dollars now for MT pro but having the multi port version would really help (testing wise). Im having a look at midiox though because it has very good (and much more familiar) script based transforms and I dont really use any keystrokes now (which was originally why I went MT).
Just have to try the WM thing now. I do music for worship. It involves a couple of songs with a lot of spontaneous in between. The song lyrics need to display so hopefully that will sync up ok.
Getting multiple behaviours from 1 footswitch was the main prob, otherwise it would be tap dancing ie stepping through banks etc. The track behaviour turned out well; quick click = trigger/record, slightly held = stop clip and hold it down and it deletes the track etc.
Getting MT to sort the merged data to multi outs is the final development I suppose.
I wouldnt mind if you could have a quick look at the translators to see if there is any bloat that could be removed perhaps.
There is no midi filtering tool in Live as opposed to SX which is comprehensive to say the least.
Thanks again for all your help.
Cheers
Mark

Tuur

2008-06-15 19:44:31

Good to hear that!

I have Excel but you could also send the project file and I can take a look at it, but there are many ways to skin a cat. :)

Oh, and if you click on the hint you'll get it. ;)

Image_Engine

2008-06-18 02:38:33

Hi Tuur
Everything is happening but I think I need a bit of help to add an extra feature. Currently I have the following setup for track control and it seems to work well (although I did an edit this morning so I hope I didnt break anything);

Code: Select all

Translator 1: Stop Trans if not valid (notes 21-29)
Options: stop=true
Incoming: Transpose Notes and pass original for track selection
Rules: 
  if oo<21 then exit rules, execute Outgoing Action
  if oo>29 then exit rules, execute Outgoing Action
Outgoing: (none)

Translator 3: Transpose Notes (notes 21-29)
Options: stop=false
Incoming: Transpose Notes and pass original for track selection
Rules: 
  ha=oo
  oo=oo-20
  ss=ga*10
  g0=ss+oo
  gd=0
  hx=70+oo !hx and hy are globals that route to expression pedals on FCB
Outgoing: (none)

Translator 4: CheckQuickClick<300ms
Options: stop=false
Incoming: MIDI 9C oo 40 
Outgoing: One-shot timer "Timer_QuickClip": 300 ms delay

Translator 5: CheckMedClick<600ms
Options: stop=false
Incoming: MIDI 9C oo 40 
Outgoing: One-shot timer "Timer_StopClip": 600 ms delay

Translator 6: CheckHeld - Delete
Options: stop=false
Incoming: MIDI 9C oo 40 
Outgoing: One-shot timer "Timer_DeleteClip": 1500 ms delay

Translator 7: Pedal Up - Quick
Options: stop=false
Incoming: Sets pedalup flag for QuickClip
Rules: 
  gd=-1
Outgoing: (none)

Translator 8: TimeIsUp - Quick
Options: stop=true
Incoming: On timer "Timer_QuickClip"
Rules: 
  if gd>=0 then exit rules, skip Outgoing Action
Outgoing: MIDI 9D g0 40 

Translator 9: TimeIsUp - Med
Options: stop=false
Incoming: On timer "Timer_StopClip"
Rules: 
  ge=1
Outgoing: (none)

Translator 10: TimeIsUp - Held
Options: stop=false
Incoming: On timer "Timer_DeleteClip"
Rules: 
  ge=2
Outgoing: Keystroke: Backspace 

Translator 11: Pedal Up
Options: stop=false
Incoming: MIDI 9C oo 00 
Outgoing: Kill timer "Timer_StopClip"

Translator 12: Pedal Up
Options: stop=false
Incoming: MIDI 9C oo 00 
Outgoing: Kill timer "Timer_DeleteClip"

Translator 13: Pedal Up - Pass Oringinal FCB note
Options: stop=false
Incoming: Selects Track and Arm
Rules: 
  if ge!=1 then exit rules, skip Outgoing Action
Outgoing: MIDI 9E ha 40 
A quick click triggers rec in a slot if empty, launches it if clip available. A longer click will simply stop the track. A click held for more than 1500ms will delete the current clip. All good. However now I want to add a double click behaviour so that a double click will cycle a global flag between 0 and 2. Any ideas? I got through this 'base' stuff ok but I think I really need your guru help on this one; Cheers

Mark

Tuur

2008-06-18 13:38:30

Something like this?

Define a double click in terms of time (e.g. 2 clicks < .5 sec) and start a timer like with the stop function.

New translators:

1. on click: start timer with .5 delay and add 1 to global1

2. on timer: check global1 (>1?) and when true cycle through your global2 values (0-1-2) by adding and resetting when needed

3. on timer: reset global1 (=0)

2 and 3 can be combined but this is easier to read. The 3rd translator has to be beneath #2 in this case though (checking order)!

I can't test it right now, but it should work IMO.

Image_Engine

2008-06-19 00:55:32

Works great but I need a different message to be sent if I hold the pedal down longer than the double click time ie 500ms and if I keep it held down longer than 1.2secs then it needs to send 'backspace' to delete the track? ie so it integrates with the current behaviour as described.
Cheers
Mark

Tuur

2008-06-19 09:22:12

Ahh, you mean you don't want the double click to send out any 'default' trigger messages?

That's not really possible, unless you want to delay your original trigger signal 'till after the double click detection time...

Image_Engine

2008-06-19 10:50:32

I think Ive got it. Yeah, the delay is inevitable but its not a timing critical procedure. the ^ seems to do the toggling invert ok so Ill stick with that.
Cheers
Mark

Tuur

2008-06-19 10:57:21

Good! :)

Image_Engine

2008-06-29 14:04:24

Hi Tuur
One other thing; I need to mod the behaviour for one bank.
1) Single click behaviour
2) Double click behaviour (as per the above eg 350ms timer)
3) If its a single click but the pedal hasnt come up yet, wait until the pedal up and then send the required message on pedal up.
Im having trouble with 3; any ideas? (maybe Im too tired when I start or something :-)
Cheers
Mark