[Csnd] Toggle UDO?
Date | 2020-07-31 10:44 |
From | "Dr. Richard Boulanger" |
Subject | [Csnd] Toggle UDO? |
Does anyone have a toggle UDO that they might be able to share?
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Are there examples that you might point me to in Floss or in CsoundQt? Thanks. What my students are trying to do is press a single button (on a Bela or Arduino) or play a single MIDI note on a controller keyboard and have it turn on an effect, and then press the same button again and have it turn off the effect. Or, like in Ableton Live - start playing a sample and then press again to stop playing the sample. a "toggle" John and I have worked on a new "counter" opcode that will work in these situations, but it won't be released until 6.15. I will be working and searching and sharing later today, but if any of you have one already, or might point me to some solutions - that would be a huge help and head-start. (In CsoundQt, the button widget has a "latch" mode, which is perfect, but I need this to work in Csound without a widget or front-end) Thanks -dB Dr. Richard Boulanger Professor of Electronic Production and Design Berklee College of Music Professional Writing and Technology Division skype: radiobaton facebook: https://www.facebook.com/richard.boulanger.58 about: http://www.boulangerlabs.com/#about about: http://www.csounds.com/community/developers/dr-richard-boulanger/ music: http://www.csounds.com/community/developers/dr-richard-boulanger/dr-richard-boulanger-music/ Boulanger Labs - http://boulangerlabs.com The Csound Book - http://mitpress.mit.edu/books/csound-book The Audio Programming Book - http://mitpress.mit.edu/books/audio-programming-book |
Date | 2020-07-31 11:07 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Toggle UDO? |
Do you mean this? opcode Toggle,k,0 kstate init 0 kstate = kstate == 0? 0 : 1 xout kstate endop ======================== Prof. Victor Lazzarini Maynooth University Ireland > On 31 Jul 2020, at 10:44, Dr. Richard Boulanger |
Date | 2020-07-31 11:08 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Toggle UDO? |
actually the other way round opcode Toggle,k,0 kstate init 0 kstate = kstate == 0? 1 : 0 xout kstate endop ======================== Prof. Victor Lazzarini Maynooth University Ireland > On 31 Jul 2020, at 11:07, Victor Lazzarini |
Date | 2020-07-31 11:37 |
From | "Jeanette C." |
Subject | Re: [Csnd] Toggle UDO? |
Hello Dr. B. Jul 31 2020, Dr. Richard Boulanger has written: ... > What my students are trying to do is press a single button (on a Bela or > Arduino) or play a single MIDI note on a controller keyboard and have it > turn on an effect, and then press the same button again and have it turn > off the effect. ... Could this be done with channels? Have a UDO to create a channel with a predefined state: opcode make_toggle, 0, Si Sname, iStartValue xin ... ; possibly concat a name like toggle.Sname chn_k SchannelName, 3 chnset iStartValue, SchannelName endop And then have a toggle opcode to check a control signal with changed2 or compare to fixed values - in the case of MIDI notes, always setting the channel to 0 or 1. opcode toggle_run, k, Sk Sname, kControl xin ... kCurrentValue chnget SchannelName if changed2(kControl) == 1 then if kcurrentValue == 0 then kCurrentValue = 1 else kCurrentValue = 0 endif chnset kCurrentValue, SchannelName endif xout kCurrentValue endop That way, I think, you could use this in several places in the orchestra and still have a central state. HTH. Best wishes, Jeanette -- * Website: http://juliencoder.de - for summer is a state of sound * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g * SoundCloud: https://soundcloud.com/jeanette_c * Twitter: https://twitter.com/jeanette_c_s * Audiobombs: https://www.audiobombs.com/users/jeanette_c * GitHub: https://github.com/jeanette-c Don't care about money It doesn't give me half the thrill <3 (Britney Spears) Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2020-07-31 12:17 |
From | thorin kerr |
Subject | Re: [Csnd] Toggle UDO? |
Would i-rate code do?
I have a counter which could be used as a toggle.
This is similar to Jeanette's solution. You need to give it a string, which is used as a state-saving channel. opcode counterChan, i, Spoo ;;; state saving counter. ;;; usage ival counterChan "id" [, iincrement, imodulo, ilower]
icurrent chnget Schan if (imodulo != 0) then icurrent = wrap(icurrent, ilower, imodulo) inewval = wrap((icurrent + iincrement), ilower, imodulo) else inewval = icurrent + iincrement endif chnset inewval, Schan xout icurrent endop ;;;Example (toggle) usage ibutton1 counterChan "button1", 1, 2, 0 ibutton2 counterChan "button2", 1, 2, 0
ibutton3 counterChan "button3", 1, 2, 0
Thorin On Fri, Jul 31, 2020 at 7:44 PM Dr. Richard Boulanger <rboulanger@berklee.edu> wrote:
|
Date | 2020-07-31 12:26 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] Toggle UDO? |
Victor, Jeanette and Thorin, These are all super inspiring and helpful! Today is going to be toggle day at Boulanger Labs! I will get my students to explore and apply these for sure, and any other suggestions and approaches that others might share too. Super helpful and most appreciated. -dB Dr. Richard Boulanger Professor Electronic Production and Design Berklee College of Music On Jul 31, 2020, at 7:18 AM, thorin kerr <thorin.kerr@gmail.com> wrote:
|
Date | 2020-07-31 14:48 |
From | Joseph Hughes |
Subject | Re: [Csnd] Toggle UDO? |
Hi Richard, This matches the use case you're describing pretty closely. It's not an opcode, it's an instrument that turns a delay effect on and off: https://github.com/riffquantum/static_brothers_see_cound/blob/master/songs/sbDrumKit/instruments/midiRouter/noteInstruments/PadC4.orc On Fri, Jul 31, 2020 at 7:26 AM Dr. Richard Boulanger <rboulanger@berklee.edu> wrote:
|
Date | 2020-07-31 15:46 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] Toggle UDO? |
Thanks, Joseph, I will try it too and pass that along to the students as well. Much appreciated Dr. Richard Boulanger Professor of Electronic Production and Design Berklee College of Music On Fri, Jul 31, 2020 at 9:48 AM Joseph Hughes <joehughesmail@gmail.com> wrote:
|
Date | 2020-07-31 15:50 |
From | Joseph Hughes |
Subject | Re: [Csnd] Toggle UDO? |
As a UDO I guess the concept would look like this: opcode instrumentToggle 0, iooooooo iInstrumentNumber, iP4, iP5, iP6, iP7, iP8, iP9, iP10 xin iInstrumentIsActive active iInstrumentNumber if iInstrumentIsActive > 0 then turnoff2 iInstrumentNumber, 8, 1 else event_i "i", iInstrumentNumber, 0, -1, iP4, iP5, iP6, iP7, iP8, iP9, iP10 endif endop On Fri, Jul 31, 2020 at 10:46 AM Dr. Richard Boulanger <rboulanger@berklee.edu> wrote:
|
Date | 2020-07-31 15:55 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] Toggle UDO? |
Thanks! I think that the students (and me too) are looking for both a UDO or a nice MIDI instrument model of this. - it's all pretty easy in Pd or MaxMSP (and this is the experience that they all bring to Csound) -dB On Fri, Jul 31, 2020 at 10:50 AM Joseph Hughes <joehughesmail@gmail.com> wrote:
|
Date | 2020-07-31 16:03 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Toggle UDO? |
Well it’s even easier in Csound giSw[] init 127 instr 1 ikey notnum giSw[ikey] = giSw[ikey] == 0 ? 1 : 0 endin ======================== Prof. Victor Lazzarini Maynooth University Ireland > On 31 Jul 2020, at 15:55, Dr. Richard Boulanger |
Date | 2020-07-31 16:55 |
From | Justin Smith |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Toggle UDO? |
as a style concern (clearly the examples so far are correct) I'm fond of: x = 1 - x (this breaks if anybody sets x to a value other than 0 or 1, but ruling that out it has a nice clarity) On Fri, Jul 31, 2020 at 8:03 AM Victor Lazzarini |
Date | 2020-10-06 00:08 |
From | Kevin Welsh |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Toggle UDO? |
Hello everyone! I needed a toggle in csound/cabbage to have one button or channel that can toggle any number of other channels. Nothing I saw quite filled my needs, so I wrote these and figured I'd share in case it's useful to anyone else. There are two versions, both take two arguments and have no outputs. The first argument is a trigger, and be either a channel name or a k-rate variable. The second argument is an array of all channels to toggle when triggered. You can use it like this with a channel name: ToggleChans "toggle-mute", fillarray("left-mute","right-mute") Or like this with a k-rate variable: kToggle chnget "toggle-mute" ToggleChans kToggle, fillarray("left-mute","right-mute") ; opcode to toggle a list of channels ; one version takes in a channel name to watch for triggers to toggle ; the other version takes in a krate signal to trigger toggle ; both versions take in an array of channel names to toggle when triggered opcode ToggleChans,0,SS[] SToggleChan, SChanList[] xin kToggle chnget SToggleChan if (changed(kToggle)==1 && kToggle==1) then kCount=0 LoopLbl: chnset 1-chnget:k(SChanList[kCount]), SChanList[kCount] loop_le kCount, 1, lenarray(SChanList)-1, LoopLbl endif endop opcode ToggleChans,0,kS[] kToggle, SChanList[] xin if (changed(kToggle)==1 && kToggle==1) then kCount=0 LoopLbl: chnset 1-chnget:k(SChanList[kCount]), SChanList[kCount] loop_le kCount, 1, lenarray(SChanList)-1, LoopLbl endif endop On Fri, Jul 31, 2020 at 11:55 AM Justin Smith <noisesmith@gmail.com> wrote: as a style concern (clearly the examples so far are correct) I'm fond of: |
Date | 2020-10-06 03:47 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Toggle UDO? |
Thanks Kevin - very helpful and very useful. Dr. Richard Boulanger On Mon, Oct 5, 2020 at 7:09 PM Kevin Welsh <tgrey1@gmail.com> wrote:
|