benbravo Posted December 30, 2019 Share Posted December 30, 2019 Hi, I have a midi button that sends two CC values on press. CC78 = 63 followed by CC77 = some value Another button sends CC78 = 127 followed by CC77 = some value I would like to process CC77 a certain way if it is following CC78 of value 63 and another if it’s 127. Is there a way to achieve this ?? Thanks Quote Link to comment Share on other sites More sharing options...
Atlas007 Posted December 30, 2019 Share Posted December 30, 2019 I'd say that is something that could be done with a Transformer object... Quote Link to comment Share on other sites More sharing options...
benbravo Posted December 30, 2019 Author Share Posted December 30, 2019 thanks, but this seems to be very specific to Logic... I am working in MainStage, and I need a way to do it with a script, or some midi plugin or some workaround of some sort. any ideas? Quote Link to comment Share on other sites More sharing options...
Atlas007 Posted December 30, 2019 Share Posted December 30, 2019 Have you explored the possibilities with the Modifier MIDI plugin? Quote Link to comment Share on other sites More sharing options...
benbravo Posted December 30, 2019 Author Share Posted December 30, 2019 yes, i don't see any way to achieve this with the modifier. what I need is a conditional statement, saying to modify cc77 in some way IF it is following directly a cc78 of 127. has to be time related somehow... my little programming skill is overwhelmed. Quote Link to comment Share on other sites More sharing options...
Atlas007 Posted December 30, 2019 Share Posted December 30, 2019 Then scripter could be the solution. I'm not savvy enough to tell you how, but enough to affirm that it's feasible with it. Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted December 30, 2019 Share Posted December 30, 2019 Try this to get started... var lastEvent = new Event; function HandleMIDI(event) { if(event instanceof ControlChange && event.number == 77 && lastEvent instanceof ControlChange && lastEvent.number == 78) { handleCC(event); } else { event.send(); } lastEvent = event; } function handleCC(event) { if(lastEvent.value == 63) { //======================== // DO ACTION HERE //======================== } else if(lastEvent.value == 127) { //======================== // DO OTHER ACTION HERE //======================== } } Quote Link to comment Share on other sites More sharing options...
benbravo Posted December 30, 2019 Author Share Posted December 30, 2019 Thanks Dewdman, working perfectly! In the meantime I had solved it this way, any reason to prefer your code? var i; function HandleMIDI(event){ if(event instanceof ControlChange && event.number == 78 && event.value == 127){ i = 1; } else if(event instanceof ControlChange && event.number == 78 && event.value == 63){ i = 2; } else if(event instanceof ControlChange && event.number == 77 && i == 1){ // ACTION HERE // i = 0; } else if(event instanceof ControlChange && event.number == 77 && i == 2){ // OTHER ACTION HERE // i = 0; } else { event.send(); i = 0; } } Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted December 30, 2019 Share Posted December 30, 2019 either way should work, but the main difference I see is that in your case, the 77 and 78 CC's don't have to be right in a row...there could be other events in between them and it should still work...my method actually only works if they are exactly in a row. But its always possible a noteOn event or something could be sandwiched in between the 77 and 78, so I prefer your approach actually or a slight tweak to mine. I don't think it matters either way in terms of performance, if it works, then good job figuring it out! Quote Link to comment Share on other sites More sharing options...
benbravo Posted December 30, 2019 Author Share Posted December 30, 2019 alright. thanks for your insight! I did learn something today Cheers Quote Link to comment Share on other sites More sharing options...
Atlas007 Posted December 31, 2019 Share Posted December 31, 2019 So do I... Thanx for posting! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.