Hi,
Is there a way to make a [bng] visually "flash" (the same it does when you click it or send it a bang) WITHOUT making it output/send a bang?
I think there isn't, but maybe I just haven't found it.
I often use gui objects as both control and display elements. For example, when I have a slider that controls a volume, you can touch the slider to manually change the volume, but if the volume is changed from some other "source", the slider moves to reflect this change. Same with numbers, radios, symbols, toggles, etc. This can be easily achieved by using [set ...( messages, that change the displayed value of the gui object without triggering its output.
So it would be great to be able to do the same with a [bng], but I miss a "set" (or analoguous) message for this object.
It's not that I can't figure out a way to achieve a bang that can be used as a control and display at the same time (you click it: it does the action; the action is triggered by something else: the bang flashes), but it would be much more "tricky" and doesn't lend itself (as far as I can figure out) to elegant and general solutions as it happens with other gui objects. Or perhaps it's just a matter of writing a more complex abstraction than the one I use for other controls.....
Now, just in case it may be useful to anybody, I thought I would share the solution I use for non-bng controls. I'm sure most of you already use something similar. Here's how it works.
First of all, every control (a volume, a pitch, a speed, anything) has a name, that is the name everybody sends values to when they want to change that parameter. This means that somewhere there is a [r <name>] that actually does something with those values. So, I create an abstraction called [control_element], which in its most simplified form is like this:
--------------------control_element.pd------------------ [r $1-if-send] | [s $1]
[r $1] | [set $1( | [s $1-if-receive]
its creation argument $1 is the name of the control.
So, for any control called "xxx" that needs to have a control/display gui element, you place one (and only one) instance of [control_element xxx].
Now, any gui object (slider, number box, symbol box, toggle, etc) that is meant to work as a control/display for control xxx, simply needs to have its send and receive symbols set to "xxx-if-send" and "xxx-if-receive" respectively.
Note that you can place multiple interface elements for the same control. For example, you can place a number box and a slider associated to xxx. When you move the slider, the number moves; when you move the number, the slider moves: and when anybody else in the patch sends a value to xxx (and he doesn't need to know anything about the existence of control_element and gui objects), both the number and the slider are updated.
The same abstraction works for both numbers and symbols.
There is a redundant loop (not an infinite loop) when you manually move the gui element: the gui element sends out the value and immediately receives a [set( message that sets it to the same value; but that's harmless afaics.
It would be fine to do something similar that could work with bangs...
Hi Matteo, I wanted the same once, here's what I came up with.
Cheers Luke
On Tue, Mar 18, 2008 at 3:53 AM, matteo sisti sette matteosistisette@gmail.com wrote:
Hi,
Is there a way to make a [bng] visually "flash" (the same it does when you click it or send it a bang) WITHOUT making it output/send a bang?
I think there isn't, but maybe I just haven't found it.
I often use gui objects as both control and display elements. For example, when I have a slider that controls a volume, you can touch the slider to manually change the volume, but if the volume is changed from some other "source", the slider moves to reflect this change. Same with numbers, radios, symbols, toggles, etc. This can be easily achieved by using [set ...( messages, that change the displayed value of the gui object without triggering its output.
So it would be great to be able to do the same with a [bng], but I miss a "set" (or analoguous) message for this object.
It's not that I can't figure out a way to achieve a bang that can be used as a control and display at the same time (you click it: it does the action; the action is triggered by something else: the bang flashes), but it would be much more "tricky" and doesn't lend itself (as far as I can figure out) to elegant and general solutions as it happens with other gui objects. Or perhaps it's just a matter of writing a more complex abstraction than the one I use for other controls.....
Now, just in case it may be useful to anybody, I thought I would share the solution I use for non-bng controls. I'm sure most of you already use something similar. Here's how it works.
First of all, every control (a volume, a pitch, a speed, anything) has a name, that is the name everybody sends values to when they want to change that parameter. This means that somewhere there is a [r <name>] that actually does something with those values. So, I create an abstraction called [control_element], which in its most simplified form is like this:
--------------------control_element.pd------------------ [r $1-if-send] | [s $1]
[r $1] | [set $1( | [s $1-if-receive]
its creation argument $1 is the name of the control.
So, for any control called "xxx" that needs to have a control/display gui element, you place one (and only one) instance of [control_element xxx].
Now, any gui object (slider, number box, symbol box, toggle, etc) that is meant to work as a control/display for control xxx, simply needs to have its send and receive symbols set to "xxx-if-send" and "xxx-if-receive" respectively.
Note that you can place multiple interface elements for the same control. For example, you can place a number box and a slider associated to xxx. When you move the slider, the number moves; when you move the number, the slider moves: and when anybody else in the patch sends a value to xxx (and he doesn't need to know anything about the existence of control_element and gui objects), both the number and the slider are updated.
The same abstraction works for both numbers and symbols.
There is a redundant loop (not an infinite loop) when you manually move the gui element: the gui element sends out the value and immediately receives a [set( message that sets it to the same value; but that's harmless afaics.
It would be fine to do something similar that could work with bangs...
-- Matteo Sisti Sette matteosistisette@gmail.com http://www.matteosistisette.com
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
I'm not sure I understood Steffen's proposed solution, and I'm not sure whether I explained clearly what was my goal.
However, I've come up with an interesting solution (attached), which satisfies my requirements except one that is however sacrifiable.
Here's what I needed.
playing a sound 2) The name "xxx" is "publicly known", that is, wherever I need to play that sound under any circumstances in any part of my patch, I can trust that I can send a bang to "xxx" -- e.g. [; xxx bang( -- and that will result in the sound being played once. 3) Somewhere in the patch I want to place ONE OR MORE [bng] objects, with their "send symbol" and "receive symbol" (in the bng properties) set to "xxx-if-send" and "xxx-if-receive" respectively (or any other convention such that the send and received symbols can be deduced from the control name "xxx") 4) Every time that you click _any_ of the [bng]s, one and only one bang is sent to "xxx". 5) Every time that a bang is sent to "xxx" from any source other than the gui [bng]s, _all_ the [bng]s flash 6) Every time that you click any of the [bng]s, all other [bng]s visually flash as well. 7) Somewhere there's an instance (or as many instances as needed, depending on how it works) of an abstraction with "xxx" as an argument, that make everything work as described. b) Obviously, you can repeat all this with any other control name.
Now, the attached example works as described except for point (6): when you click one bng, the message is sent to the target but the other bngs don't flash; however I'm quite fine with that. When a bang is sent from an "external" source, the [bng]s do bang.
Look at the attached patch "example_control_bang.pd", which uses the [control_bang] abstraction.
Thanks for the suggestions.
Bye m.
2008/3/18, Steffen Leve Poulsen slagmark@worldonline.dk:
matteo sisti sette skrev:
Hi,
Is there a way to make a [bng] visually "flash" (the same it does when you click it or send it a bang) WITHOUT making it output/send a bang?
Hi, Mattteo
you can use:
[t a b] | | | [visual bang here] [route bang]
mvh/ slp
matteo sisti sette skrev:
- Every time that you click any of the [bng]s, all other [bng]s
visually flash as well.
Now, the attached example works as described except for point (6): when you click one bng, the message is sent to the target but the other bngs don't flash;
ok now I understand.
Here are two solutions,classic and not so classic. flashing the background color might be what you need. Then you can use a different color when you flash it from "outside".
mvh/slp
#N canvas 204 194 755 304 10; #X obj 167 79 bng 15 250 50 0 empty $0-bang empty 17 7 0 10 -262144 -66577 -261689; #X obj 167 112 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X msg 244 135 color $1 2 3; #X obj 244 87 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; #X obj 166 44 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 244 164 s $0-bang; #X obj 244 59 del 500; #X obj 244 110 * 16; #X obj 480 27 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 466 199 spigot; #X obj 480 55 t a b; #X obj 506 79 0; #X obj 466 81 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 466 237 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 448 145 1; #X obj 466 116 t b b; #X connect 0 0 1 0; #X connect 2 0 5 0; #X connect 3 0 7 0; #X connect 4 0 3 0; #X connect 4 0 6 0; #X connect 6 0 3 0; #X connect 7 0 2 0; #X connect 8 0 10 0; #X connect 9 0 13 0; #X connect 10 0 12 0; #X connect 10 1 11 0; #X connect 11 0 9 1; #X connect 12 0 15 0; #X connect 14 0 9 1; #X connect 15 0 14 0; #X connect 15 1 9 0;
flashing the background color might be what you need.
Oh yeah, great!
I needed a little bit of KISS-thinking :)
Then you can use a different color when you flash it from "outside".
I don't even need that.
So I could just implement my [control_bang] abstraction like this:
[r $1] | [pd generate_a_pair_of_color_messages] | [s $1-if-receive]
assuming that my [bng]s send directly to the target <name> and receive from <name>-if-receive
Steffen Leve Poulsen skrev:
matteo sisti sette skrev:
Hi,
Is there a way to make a [bng] visually "flash" (the same it does when you click it or send it a bang) WITHOUT making it output/send a bang?
Hi, Mattteo
you can use:
[t a b] | | | [visual bang here] [route bang]
see attached! slp
#N canvas 546 246 567 387 10; #X obj 74 71 t a b; #X obj 101 101 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 74 140 route bang; #X obj 74 194 outlet; #X obj 74 44 inlet; #X obj 131 195 outlet; #X connect 0 0 2 0; #X connect 0 1 1 0; #X connect 2 0 3 0; #X connect 2 1 5 0; #X connect 4 0 0 0; #X coords 0 -1 1 1 17 17 2 100 100;
#N canvas 511 246 466 316 10; #X obj 104 84 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X msg 126 83 set; #X obj 104 202 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X floatatom 157 81 5 0 0 0 - - -; #X msg 197 81 skudatest; #X msg 267 81 1 2 7; #X obj 149 200 print; #X floatatom 115 183 5 0 0 0 - - -; #X obj 189 158 bang-set; #X obj 104 152 bang-set; #X obj 219 158 bang-set; #X connect 0 0 9 0; #X connect 1 0 9 0; #X connect 3 0 9 0; #X connect 4 0 9 0; #X connect 5 0 9 0; #X connect 7 0 6 0; #X connect 9 0 2 0; #X connect 9 0 7 0; #X connect 9 1 6 0;