Discussion:
Push a button add one...push the same button subtract one.
Clifford Dunn
2014-10-20 00:08:00 UTC
Permalink
I'm having a hell of a time with this. I want to push a momentary
push-button pedal that is sending MIDI to SC and have that alternate
between adding a number or subtracting a number. Basically I have
this:

if(num == 40, {~switch = ~switch +1});

And then if I hit it again I want a - 1 instead. Using %2 won't work
because I have other buttons that change the value of ~switch as well.
What I imagine would work is something like if(~switch == 0, {~switch
= ~switch +1}) if (~switch == 1, {~switch = ~switch - 1}). Which I
would then expand to all my values of switch. However, putting these
lines together won't work because when the pedal is hit, first it will
add and then immediately it will subtract. What sort of has success is
something like this: if(~switch ==0, {~switch = ~switch +1}, {~switch
= ~switch -1}). But I had some odd results. I feel like there must be
some operation or method I'm missing in order to alternate between +1
and -1.

Thanks!
Clifford Dunn
Flutist/Composer
http://www.ckdmusic.blogspot.com

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Sam Pluta
2014-10-20 00:42:44 UTC
Permalink
Hey Clifford,

You just need an else statement, right:

if(~switch == 0, {
~switch= ~switch +1
}, {
~switch = ~switch - 1
});

or maybe:

if(~switch == 0, {
~switch= 1
}, {
~switch = 0
});

Sam
Post by Clifford Dunn
I'm having a hell of a time with this. I want to push a momentary
push-button pedal that is sending MIDI to SC and have that alternate
between adding a number or subtracting a number. Basically I have
if(num == 40, {~switch = ~switch +1});
And then if I hit it again I want a - 1 instead. Using %2 won't work
because I have other buttons that change the value of ~switch as well.
What I imagine would work is something like if(~switch == 0, {~switch
= ~switch +1}) if (~switch == 1, {~switch = ~switch - 1}). Which I
would then expand to all my values of switch. However, putting these
lines together won't work because when the pedal is hit, first it will
add and then immediately it will subtract. What sort of has success is
something like this: if(~switch ==0, {~switch = ~switch +1}, {~switch
= ~switch -1}). But I had some odd results. I feel like there must be
some operation or method I'm missing in order to alternate between +1
and -1.
Thanks!
Clifford Dunn
Flutist/Composer
http://www.ckdmusic.blogspot.com
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Dan Zink
2014-10-20 01:20:35 UTC
Permalink
Or just initialize to 1 and then:

~switch = ~switch * -1;

FWIW, I use the ToggleFF UGen for this kind of thing; you send a trigger to
the synth and it flips between 1 and 0.
Post by Sam Pluta
Hey Clifford,
if(~switch == 0, {
~switch= ~switch +1
}, {
~switch = ~switch - 1
});
if(~switch == 0, {
~switch= 1
}, {
~switch = 0
});
Sam
Post by Clifford Dunn
I'm having a hell of a time with this. I want to push a momentary
push-button pedal that is sending MIDI to SC and have that alternate
between adding a number or subtracting a number. Basically I have
if(num == 40, {~switch = ~switch +1});
And then if I hit it again I want a - 1 instead. Using %2 won't work
because I have other buttons that change the value of ~switch as well.
What I imagine would work is something like if(~switch == 0, {~switch
= ~switch +1}) if (~switch == 1, {~switch = ~switch - 1}). Which I
would then expand to all my values of switch. However, putting these
lines together won't work because when the pedal is hit, first it will
add and then immediately it will subtract. What sort of has success is
something like this: if(~switch ==0, {~switch = ~switch +1}, {~switch
= ~switch -1}). But I had some odd results. I feel like there must be
some operation or method I'm missing in order to alternate between +1
and -1.
Thanks!
Clifford Dunn
Flutist/Composer
http://www.ckdmusic.blogspot.com
_______________________________________________
sc-users mailing list
http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
Post by Clifford Dunn
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
_______________________________________________
sc-users mailing list
http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Continue reading on narkive:
Loading...