We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › proCONTROLL - 2 buttons @ same time
Page Index Toggle Pages: 1
proCONTROLL - 2 buttons @ same time (Read 871 times)
proCONTROLL - 2 buttons @ same time
Dec 10th, 2008, 8:53am
 
Hi there, i was wondering if is it possible to trigger 2 or more buttons at the same time, using proCONTROLL.
I'm trying to use a gamepad to control midi signals and trigger sounds on reason, redrum samples for example.
I've managed to do this, but if i press 2 buttons at the same time, only one of them sounds. itd be cool to use them together, so you can trigger a bass drum and a crash cymbal simultaneously.

Any idea?

(maybe it has sth. to do with plug(), but as I'm a newie, I couldn't get it to work)

Thanks A LOT in advance,
Jon
Re: proCONTROLL - 2 buttons @ same time
Reply #1 - Dec 11th, 2008, 12:10am
 
hey Jon,
i think there is no direct way, to do it with the library.
but it isn't very difficult if your app doesn't need to distinguish between pushing one button while holding another or pushing the buttons exactly in the same moment.
one way to get it is to save in a global bool-array if the buttons are pressed or not. so just plug the buttons to set the right variable in the array true, and set them false if you release.
call a method from your draw() method, with an if-else cascade in it (or something more elegant).
if your pressing actions are more time critical maybe you can save not just booleans in the array but the times the buttons are pushed (frameCount). so if there are just a few frames between two presses, the app should know you meant a double-press.
cheers,
ramin      
Re: proCONTROLL - 2 buttons @ same time
Reply #2 - Dec 11th, 2008, 8:03pm
 
Thanks for answering!.. I tried with plug() and it worked fine, triggering multiple sounds simultaneously.
I tried with sth. like this, which i found on some examples... in this case, i was testing it with 3 buttons:
Code:

gamepad.plug(this, "handleButton1Press", ControllIO.ON_PRESS, 3);
gamepad.plug(this, "handleButton2Press", ControllIO.ON_PRESS, 4);
gamepad.plug(this, "handleButton3Press", ControllIO.ON_PRESS, 5);


this works ok, though there is some latency or delay sometimes.
I'll be testing it using some other MIDI libraries (used the midibus here) and some other virtual midi conection (used midi yoke).


about your idea, do you think that saving them in a global array can improve its speed or help to keep things organized
? i was thinking that it could work using nested for/ifs.

now i'd also like to try if there's a way to change the midi values you send when pressing a button, but when you're already running the app... like pressing some key and change a bank, or maybe put input form or button...


Re: proCONTROLL - 2 buttons @ same time
Reply #3 - Dec 14th, 2008, 12:27pm
 
hey,
one thing that can be cool for making it more complex by saving the button presses in variables is that if you can bring time to them you can think of dynamicly saving some patterns and replay those patterns with some little button combination.
also maybe if your program is going to trigger many different things in your music program. then you might think that your app has different states, and a button has different effects in these states. so this won't be easy with plugging i think. i think this iit will work good, if you want to change midi values, banks, ... with a few buttons in your hand.
so sing variables instead of plugging everything is maybe something like a design pattern to help you make it more flexible.
i haven't used to midibus & midi yoke and don't know very much about reason. i use live, and haven't any connection from an app to it(seems to have no osc or win midi synth), is it because there are only visible in live if i start the app with midibus or yoke ? Smiley
Re: proCONTROLL - 2 buttons @ same time
Reply #4 - Dec 14th, 2008, 11:37pm
 
hi there, yeah, sure it'd be cool, but plug is the only way i found for different triggers to sound simultaneously... didn't work for me with the "if(button.pressed)", thou i'm sure there should be a way... but i'm far from a good coder Tongue

i was thinking now about building a graphic interface, adding variables to the midi messages i use to send midi notes inside the plug methods. This way i can place for example, a couple buttons that load different pressets. or even put a know or something so you can select midi channel, pitch and velocity for each trigger button. I'll try this using NETbeans.
(i've already triggered buttons and both axis to handle filters or knobs in reason)

Quote:
i haven't used to midibus & midi yoke and don't know very much about reason. i use live, and haven't any connection from an app to it(seems to have no osc or win midi synth), is it because there are only visible in live if i start the app with midibus or yoke ?


once you've installed midi yoke (or other virtual midi like loopbe1 or maple) you have to set up the MIDI in/out on your sketch... you can first see what devices you have available with MidiBus.list(); then set the in/out (for example MIDI YOKE IN 2, and MIDI YOKE OUT 1 using  myBus = new MidiBus(this, 4, 30);

Then in Live, go to options, preferences, and inside de midi sync tab, activate the ins/outs, and set up a controller, for example a trigger finger; set the input (if you put midi yoke 1 as output in your sketch, then you have to put midi yoke 1 as input here), and output.
then, left click on a button or parameter, for example, the S (solo) button... clik edit midi map (ctrl+m) and with you scketch running, press the button you want to trigger.
exit the midi map edit view, and you got the S button mapped to a gamepad button.

cheers!
Re: proCONTROLL - 2 buttons @ same time
Reply #5 - Dec 20th, 2008, 1:23pm
 
hey. i found the midibus library by google. on the site its officialy called processing library but you can't find it on the library page here, and there is no other list. this seems to happen more often, i don't know why- (if someone hosting the page reads that, i ask myself why there is a page for hacks, which seem to have some random usefull code parts, but totally no activity, but no listed page, for any lib that people want to share). dunno- maybe both libs i found haven't send them to the pagehost.
anyway.
midi yoke works cool and easy.
i have done some similar recording and controlling stuff for the korg nano kontroll. look the price look what it has- its fantastic! Smiley but just without programming anything for music program control(it just works so), but for controlling visuals in processing.
some time ago i used my gamepad in processing and with some programming osc i got it into reaktor.
now i going to try using the oscillator lib to bring some automation with gui controll to live.
i think we can share our code and do mutual support.  
sorry for my bad english i hope my code would be more clear Smiley
Re: proCONTROLL - 2 buttons @ same time
Reply #6 - Dec 20th, 2008, 8:27pm
 
Hey Ramin, you can find The MidiBus library in the forum actually, in the "libraries, tool development" forum: http://processing.org/discourse/yabb_beta/YaBB.cgi?board=os_libraries_tools;action=display;num=1227841230"

I've found it very useful and easy to use.

nano Kontroll are cool,i'm using a KORG microKORG as main controller/synth at this time... so my idea is to use gamepads as samplers or loop trigger, like an mpc.

cheers
Page Index Toggle Pages: 1