Csound Csound-dev Csound-tekno Search About

[Csnd] conditional

Date2019-10-11 09:09
Fromfra
Subject[Csnd] conditional
Hi all,
i have a UDO (if i am correct from Heinz) that using csound from git 
(yesterday)
give me error in this:

     kTimer = kTrig == 1 ? 0 : kTimer

(complete UDO at the end)

i have try this as solution

     if kTrig==1 then
         kTimer = 0
     endif

and seem to work but i would like to ask if i'm correct.

Thanks,
ciao,
francesco.



opcode Trigger, kk, ai

ainput, iTimeWait xin
iThresh = 0.1
iWait = kr*iTimeWait
kTimer init (kr*iTimeWait) + 1
kRms rms ainput, 20
iSampTim = 0.01
kRmsPrev delayk kRms, iSampTim
kChange = kRms - kRmsPrev

if(kTimer>iWait) then
     if kChange > iThresh then
         kTrig = 1
         gkNoteNumber += 1
     else
         kTrig = 0
     endif
     kTimer = (kTrig == 1 ? 0 : kTimer)
else
     kTimer += 1
     kTrig = 0
endif
xout kTrig, gkNoteNumber
endop

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

Date2019-10-11 11:31
FromTarmo Johannes
SubjectRe: [Csnd] conditional
Hi,

Check the parenthesis, try
kTimer = (kTrig == 1)? 0 : kTimer

Tarmo


R, 11. oktoober 2019 11:09 fra <francescoarmandoporta@gmail.com> kirjutas:
Hi all,
i have a UDO (if i am correct from Heinz) that using csound from git
(yesterday)
give me error in this:

     kTimer = kTrig == 1 ? 0 : kTimer

(complete UDO at the end)

i have try this as solution

     if kTrig==1 then
         kTimer = 0
     endif

and seem to work but i would like to ask if i'm correct.

Thanks,
ciao,
francesco.



opcode Trigger, kk, ai

ainput, iTimeWait xin
iThresh = 0.1
iWait = kr*iTimeWait
kTimer init (kr*iTimeWait) + 1
kRms rms ainput, 20
iSampTim = 0.01
kRmsPrev delayk kRms, iSampTim
kChange = kRms - kRmsPrev

if(kTimer>iWait) then
     if kChange > iThresh then
         kTrig = 1
         gkNoteNumber += 1
     else
         kTrig = 0
     endif
     kTimer = (kTrig == 1 ? 0 : kTimer)
else
     kTimer += 1
     kTrig = 0
endif
xout kTrig, gkNoteNumber
endop

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
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

Date2019-10-11 14:57
FromArthur Hunkins <000001e1d761dea2-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] conditional
I use:
kTimer = (kTrig == 1? 0 : kTimer)

On Fri, Oct 11, 2019 at 6:31 AM Tarmo Johannes <trmjhnns@gmail.com> wrote:
Hi,

Check the parenthesis, try
kTimer = (kTrig == 1)? 0 : kTimer

Tarmo


R, 11. oktoober 2019 11:09 fra <francescoarmandoporta@gmail.com> kirjutas:
Hi all,
i have a UDO (if i am correct from Heinz) that using csound from git
(yesterday)
give me error in this:

     kTimer = kTrig == 1 ? 0 : kTimer

(complete UDO at the end)

i have try this as solution

     if kTrig==1 then
         kTimer = 0
     endif

and seem to work but i would like to ask if i'm correct.

Thanks,
ciao,
francesco.



opcode Trigger, kk, ai

ainput, iTimeWait xin
iThresh = 0.1
iWait = kr*iTimeWait
kTimer init (kr*iTimeWait) + 1
kRms rms ainput, 20
iSampTim = 0.01
kRmsPrev delayk kRms, iSampTim
kChange = kRms - kRmsPrev

if(kTimer>iWait) then
     if kChange > iThresh then
         kTrig = 1
         gkNoteNumber += 1
     else
         kTrig = 0
     endif
     kTimer = (kTrig == 1 ? 0 : kTimer)
else
     kTimer += 1
     kTrig = 0
endif
xout kTrig, gkNoteNumber
endop

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
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
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

Date2019-10-12 07:59
Fromfra
SubjectRe: [Csnd] conditional
Thanks Tarmo and Arthur,

but both give me this error:

error:  condition expression types do not match
 from file cond_test.csd (1)

thanks,

ciao,

francesco.

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

Date2019-10-12 15:04
FromJohn ff
SubjectRe: [Csnd] conditional
Are you using a recent version? This sounds like a problem with the new code.  Can you send me a csd which gives the error so I can look?

Sent from TypeApp
On 12 Oct 2019, at 08:00, fra <francescoarmandoporta@gmail.com> wrote:
Thanks Tarmo and Arthur,

but both give me this error:

error:  condition expression types do not match
from file cond_test.csd (1)

thanks,

ciao,

francesco.

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

Date2019-10-12 17:04
Fromfra
SubjectRe: [Csnd] conditional
yes, from git yesterday (on Ubuntu 16.06).

Thanks.

here is my csd:



-odac -iadc -+rtaudio=jack -m0 -d
-B 4096 -b 2048


sr = 44100
ksmps = 16
nchnls = 2
0dbfs  = 1

gaudio init 0
gkNoteNumber init 0
giNoteDur init 1.5

opcode Trigger, kk, ai
ainput, iTimeWait xin
iThresh = 0.1
iWait = kr*iTimeWait
kTimer init iWait + 1
kRms rms ainput, 20
iSampTim = 0.01
kRmsPrev delayk kRms, iSampTim
kChange = kRms - kRmsPrev

if(kTimer>iWait) then
     if kChange > iThresh then
         kTrig = 1
         gkNoteNumber += 1
     else
         kTrig = 0
     endif

     kTimer = kTrig == 1 ? 0 : kTimer

else
     kTimer += 1
     kTrig = 0
endif
xout kTrig, gkNoteNumber
endop

instr 1

audio diskin2 "samples/guitar_C.wav", p4
gaudio += audio
endin

schedule(1, 1, 4, 1)

instr 11

ktrig, knote Trigger gaudio, giNoteDur
schedkwhen ktrig, 0, 0, 12, 0, 1, knote
endin

instr 12

iNoteNum = p4
print iNoteNum
endin




i11 0 10




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

Date2019-10-12 18:00
FromJohn ff
SubjectRe: [Csnd] conditional
Think it is fixed in GitHub as of an hour or so.  Try it.

==John ff

⁣Sent from TypeApp ​

On Oct 12, 2019, 17:05, at 17:05, fra  wrote:
>yes, from git yesterday (on Ubuntu 16.06).
>
>Thanks.
>
>here is my csd:
>
>
>
>-odac -iadc -+rtaudio=jack -m0 -d
>-B 4096 -b 2048
>
>
>sr = 44100
>ksmps = 16
>nchnls = 2
>0dbfs  = 1
>
>gaudio init 0
>gkNoteNumber init 0
>giNoteDur init 1.5
>
>opcode Trigger, kk, ai
>ainput, iTimeWait xin
>iThresh = 0.1
>iWait = kr*iTimeWait
>kTimer init iWait + 1
>kRms rms ainput, 20
>iSampTim = 0.01
>kRmsPrev delayk kRms, iSampTim
>kChange = kRms - kRmsPrev
>
>if(kTimer>iWait) then
>     if kChange > iThresh then
>         kTrig = 1
>         gkNoteNumber += 1
>     else
>         kTrig = 0
>     endif
>
>     kTimer = kTrig == 1 ? 0 : kTimer
>
>else
>     kTimer += 1
>     kTrig = 0
>endif
>xout kTrig, gkNoteNumber
>endop
>
>instr 1
>
>audio diskin2 "samples/guitar_C.wav", p4
>gaudio += audio
>endin
>
>schedule(1, 1, 4, 1)
>
>instr 11
>
>ktrig, knote Trigger gaudio, giNoteDur
>schedkwhen ktrig, 0, 0, 12, 0, 1, knote
>endin
>
>instr 12
>
>iNoteNum = p4
>print iNoteNum
>endin
>
>
>
>
>i11 0 10
>
>
>
>
>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

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

Date2019-10-13 08:20
Fromfra
SubjectRe: [Csnd] conditional
Hello John,

with latest csound git (today) i get this:

error:  Unable to find opcode entry for '=' with matching argument types:
Found: i = k
        #i6 = kTimer ...
Line: 0
Parsing failed due to syntax errors
Stopping on parser failure

Can you test with my csd?

Maybe i'm wronging something ...

Thanks,

ciao,

francesco.




-odac -iadc -+rtaudio=jack -m0 -d
-B 4096 -b 2048


sr = 44100
ksmps = 16
nchnls = 2
0dbfs  = 1

; GLOBALI
gaudio init 0
gkNoteNumber init 0
giNoteDur init 1.5

; intervallo tra i triggers di almeno giNoteDur sec.
opcode Trigger, kk, ai
ainput, iTimeWait xin
iThresh = 0.1
iWait = kr*iTimeWait
kTimer init iWait + 1
kRms rms ainput, 20
iSampTim = 0.01
kRmsPrev delayk kRms, iSampTim
kChange = kRms - kRmsPrev

if(kTimer>iWait) then
     if kChange > iThresh then
         kTrig = 1
         gkNoteNumber += 1
     else
         kTrig = 0
     endif

     kTimer = kTrig == 1 ? 0 : kTimer

else
     kTimer += 1
     kTrig = 0
endif
xout kTrig, gkNoteNumber
endop

instr 1

audio diskin2 "samples/guitar_C.wav", p4
gaudio += audio
endin

schedule(1, 1, 4, 1)

instr 11

ktrig, knote Trigger gaudio, giNoteDur
schedkwhen ktrig, 0, 0, 12, 0, 1, knote
endin

instr 12

iNoteNum = p4
print iNoteNum
endin




i11 0 10




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

Date2019-10-13 14:57
Fromjohn
SubjectRe: [Csnd] conditional
Found something.  Version in github works for me.  a nasty fix but I think 
I can improve it a bit

==John ff



On Sun, 13 Oct 2019, fra wrote:

> Hello John,
>
> with latest csound git (today) i get this:
>
> error:  Unable to find opcode entry for '=' with matching argument types:
> Found: i = k
>        #i6 = kTimer ...
> Line: 0
> Parsing failed due to syntax errors
> Stopping on parser failure
>
> Can you test with my csd?
>
> Maybe i'm wronging something ...
>
> Thanks,
>
> ciao,
>
> francesco.
>
>
> 
> 
> -odac -iadc -+rtaudio=jack -m0 -d
> -B 4096 -b 2048
> 
> 
> sr = 44100
> ksmps = 16
> nchnls = 2
> 0dbfs  = 1
>
> ; GLOBALI
> gaudio init 0
> gkNoteNumber init 0
> giNoteDur init 1.5
>
> ; intervallo tra i triggers di almeno giNoteDur sec.
> opcode Trigger, kk, ai
> ainput, iTimeWait xin
> iThresh = 0.1
> iWait = kr*iTimeWait
> kTimer init iWait + 1
> kRms rms ainput, 20
> iSampTim = 0.01
> kRmsPrev delayk kRms, iSampTim
> kChange = kRms - kRmsPrev
>
> if(kTimer>iWait) then
>     if kChange > iThresh then
>         kTrig = 1
>         gkNoteNumber += 1
>     else
>         kTrig = 0
>     endif
>
>     kTimer = kTrig == 1 ? 0 : kTimer
>
> else
>     kTimer += 1
>     kTrig = 0
> endif
> xout kTrig, gkNoteNumber
> endop
>
> instr 1
>
> audio diskin2 "samples/guitar_C.wav", p4
> gaudio += audio
> endin
>
> schedule(1, 1, 4, 1)
>
> instr 11
>
> ktrig, knote Trigger gaudio, giNoteDur
> schedkwhen ktrig, 0, 0, 12, 0, 1, knote
> endin
>
> instr 12
>
> iNoteNum = p4
> print iNoteNum
> endin
>
> 
> 
>
> i11 0 10
>
> 
> 
>
> 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
>

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

Date2019-10-14 10:54
Fromfra
SubjectRe: [Csnd] conditional
Thanks John,

it is working again.

Many thanks,

ciao,

francesco.

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