[Csnd] [csound4android] behavior of "buttX"
Date | 2024-01-07 08:24 |
From | '2+ |
Subject | [Csnd] [csound4android] behavior of "buttX" |
hi :)
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
wrote the following code to test the behavior of "buttX" it seems like i can set the default value to that ain't 0.0 nor 1.0 but once i touch the button it goes back to off=0.0 on=1.0 is there any way to set on and off to arbitural value? in someone's example i saw something like gkslider1 chnget "slider1" chnset (6-1)/(8-1),"slider1" is this "(6-1)/(8-1)" just a math or a special way to set something special? ----- 8< ----- <CsoundSynthesizer> <CsLicense> </CsLicense> <CsOptions> -odac -dm3 </CsOptions> <CsInstruments> sr = 48000 ksmps = 48 nchnls = 2 0dbfs = 1 giftc ftgen 0, 0, 131072, 10, 1 alwayson "gui" alwayson "sound" instr gui gkb01 chnget "butt1" chnset 0.5,"butt1" endin instr sound kfrq = 110.0 + 110.0 * gkb01 kenv1 oscil 0.9, 0.1 + 9.9 * gkb01, giftc, 0 asigc oscil 0.1 + kenv1, kfrq, giftc, 0 outs asigc, asigc endin </CsInstruments> <CsScore> </CsScore> </CsoundSynthesizer> |
Date | 2024-01-07 09:05 |
From | ST Music |
Subject | Re: [Csnd] [csound4android] behavior of "buttX" |
In that example the chnset line is used to send the button's k-rate values to a global channel. It essentially serves the same purpose as your gkb01 so isn't really necessary unless you want to learn to use channels. What do you want the button to do - what behavior? Yes, you can set default values for on/off or even multiple presses (ex. initialize at 0, press once = .5, press again = .9, press 3rd time = back to 0). Here's an example that allows to button to be used as a toggle switch instead of the default (momentary): instr 1 kamp init 0 kamp chnget "butt1" kOnOff init 0 ktrig trigger kamp, .5, 0 if ktrig == 1 then kOnOff += 1 endif if kOnOff == 1 then kamp =.3 else kamp = 0 kOnOff = 0 endif printk2 kOnOff asig lfo port(kamp, .005), 400 out asig endin In this case the init value is 0 (no sound), when pressed once the value is .3, press again and the value is back to 0. It helps to use the port opcode when applying the value to avoid clicking. HTH, Scott On Sun, Jan 7, 2024, 3:24 a.m. '2+ <electriclightheads@gmail.com> wrote:
|
Date | 2024-01-07 15:19 |
From | '2+ |
Subject | Re: [Csnd] [csound4android] behavior of "buttX" |
great! thanx! this gave me an idea to play programed melody with just one "buttX" port and trigger are cool glad to be back to this mailinglist ;) On Sun, Jan 7, 2024, 18:05 ST Music <stunes6556@gmail.com> wrote:
|
Date | 2024-01-08 08:56 |
From | '2+ |
Subject | Re: [Csnd] [csound4android] behavior of "buttX" |
now it looks something like this it seems like working <CsoundSynthesizer> <CsLicense> </CsLicense> <CsOptions> -odac -dm3 </CsOptions> <CsInstruments> sr = 48000 ksmps = 48 nchnls = 2 0dbfs = 1 giftc ftgen 0,0,131072,10,1 alwayson "gui" alwayson "sound" instr gui gkb01 init 0 gkb01 chnget "butt1" chnset 0.5,"butt1" endin instr sound kMelo init 0 ktrig trigger gkb01,0.99,0 if ktrig == 1 then kMelo += 1 endif if kMelo == 7 then kMelo = 0 endif if kMelo == 0 then kfrq = 110.0 endif if kMelo == 1 then kfrq = 133.0 endif if kMelo == 2 then kfrq = 104.0 endif if kMelo == 3 then kfrq = 157.0 endif if kMelo == 4 then kfrq = 222.0 endif if kMelo == 5 then kfrq = 210.0 endif if kMelo == 6 then kfrq = 191.0 endif kenv1 oscil 0.7,0.1+9.9*port(kfrq/230.0,.0 05),giftc,0 asigc oscil 0.3+kenv1,port(kfrq,.005),giftc,0 outs asigc,asigc endin </CsInstruments> <CsScore> </CsScore> </CsoundSynthesizer> On Mon, Jan 8, 2024, 00:19 '2+ <electriclightheads@gmail.com> wrote:
|
Date | 2024-01-08 11:22 |
From | ST Music |
Subject | Re: [Csnd] [csound4android] behavior of "buttX" |
Glad to see that it works ok for you. A few small ideas. For one you don't need the chnset line, in this case it serves no purpose. Perhaps you could consider using an array for the frequencies, then you don't need as many if statements. Also, you can see in the below code that the array length can be used to cycle kMelo back to 0, so you can add or delete as many frequencies as you like without altering the rest of the code. It also makes the code a little easier to read and possibly more efficient. Just a thought, of course it depends on what you're more comfortable with. instr gui gkb01 init 0 gkb01 chnget "butt1" endin instr sound kMelo init 0 ktrig trigger gkb01,0.99,0 kFreq[] fillarray 110, 133, 104, 157, 222, 210, 191 iLen lenarray kFreq if ktrig == 1 then kMelo += 1 endif if kMelo == iLen then kMelo = 0 endif kenv1 poscil 0.7,0.1+9.9*port(kFreq[kMelo]/230.0,.005),giftc,0 asigc poscil 0.3+kenv1,port(kFreq[kMelo],.005),giftc,0 outs asigc,asigc endin On Mon, Jan 8, 2024, 3:56 a.m. '2+ <electriclightheads@gmail.com> wrote:
|
Date | 2024-01-17 00:56 |
From | '2+ |
Subject | Re: [Csnd] [csound4android] behavior of "buttX" |
thanks to this thread my current.csd looks like this: the image of what it's doing is like this: have to dig into it to make it look cleaner and sound more complicated ;D coded and runs on my super old umidigi power(4GBRAM,android9) sometimes runs on oukitel wp15(8GBRAM,android11) never runs on unihertz jellystar(8GBRAM,android13) all apps says code=30, lib=6160 maybe have to post it to dev-list thanks again! On Mon, Jan 8, 2024, 20:22 ST Music <stunes6556@gmail.com> wrote:
|