Buttons

TouchOSC Pushbutton Sample&Hold

gtoledo3's picture

I was making a grid of buttons with TouchOSC yesterday, and wanted to set it up so that each button had a value assigned to it, and when someone pushes the button for the value to stick until they push the next button. So, if button 1 is pressed, it delivers a 1, then if button 5 is pressed it delivers a 5, for example - with only one value allowed to be generated in the button grid.

When I was looking through the options, there are pushbutton types that generate a value only when your finger is on the button, and then toggle types that you push on, then off.

The "problem" for using the toggle type for me, was that you could have multiple buttons depressed, whereas I needed the grid of buttons to only be able to deliver one output value - the last pressed.

I started fiddling around with some math patches and sample&holds, and realized I'd started recreating a part of smokris's VCR composition.

The solution is pretty simple - use the pushbuttons, and multiple each button value by the ID # that the button is supposed to have. Then, sum them all. Connect the output of the summing to the value input on a Sample & Hold. That's it! :-) I'm attaching a picture to show the setup.

Button states in QC app — Best approach

usefuldesign.au's picture

I have an app i am building in QC that will have >20 buttons that need to be 'clickable'. They will mostly have on and off states showing an LED light or dark and a bit of glow around the LED on the panel artwork I guess.

I'm wondering if the best way to do the Artwork is to have two full screen images of the Front Panel as TIFF or PDF artwork — with all buttons in OFF state and another with all buttons (LEDs) in the ON state. Then use an Core Image Accumulator patch to mask/unmask the ON image in regions where particular buttons are ON.

The other way I'm considering is to maybe draw a single button and surround in an iterator and use a (x,y) co-ordinates structure to place all the instances of the ON / OFF image on the screen. Probably do the hit testing inside the iterator too in that case.

Are there any tried and true methodologies in QC?

I've seen the masking approach used in Mac app resources in the past I seem to remember.

Obviously Flash/HTML+JS approaches don't really apply with QC lacking a DOM but maybe there's some wisdom to be gleaned there too?