[Csnd] random walk without repetitions
Date | 2021-03-01 10:14 |
From | Stefan Thomas |
Subject | [Csnd] random walk without repetitions |
Dear community, I've written an udo for an random walk, inspired by https://flossmanual.csound.com/basics/random (example 9). I would like to modify the udo in that way that repetitions of the same index could be prevented, but I don't know how to do this. Does someone have a hint for me? That' my code: %%%%%%%%% SNIPPET%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% <CsoundSynthesizer> <CsOptions> -odac -m0d </CsOptions> ; ============================================== <CsInstruments> sr = 44100 ;ksmps = 100 nchnls = 2 0dbfs = 1 seed 0 ;iNumbers ftgen 0,0,16,-2,0,110,22 gihalbton[ ] fillarray 220.0, 233.08, 246.94, 261.63, 277.18, 293.66, 311.13, 329.63, 349.23, 369.99, 392.0, 415.3, 440.0, 466.16, 493.88, 523.25, 554.37, 587.33 opcode StefansRandomWalk,k,iiiii iLowestIndx,iHighestIndx,iStartIndx,indxDevRange,iDevDir xin kIndxDevRange init indxDevRange kDevDir init iDevDir kIndx init iStartIndx kLowIndxBound = kDevDir < 0 ? -kIndxDevRange+kDevDir : -kIndxDevRange kHighIndxBound = kDevDir > 0 ? kIndxDevRange+kDevDir : kIndxDevRange ;get random value in these boundaries ;add to current pitch kIndx += kIndxRnd ; ;change direction if maxima are crossed, and report if kIndx = iHighestIndx && kDevDir > 0 then kDevDir = -kDevDir elseif kIndx = iLowestIndx && kDevDir < 0 then kDevDir = -kDevDir endif kIndx limit kIndx,iLowestIndx,iHighestIndx xout kIndx endop instr 1 iLowestIndx = 0 ; xin iHighestIndx = lenarray(gihalbton)-1 iHighestIndx = 10 ; xin ;set pitch startpoint, deviation range and the first direction iStartIndx = 5 ; xin iIndxDev = 2 ;xin, random range for next pitch iIndxDir = 1 ;xin positive = upwards iwieoft = 3 kmetro metro iwieoft if kmetro ==1 then kIndx StefansRandomWalk iLowestIndx,iHighestIndx,iStartIndx,iIndxDev,iIndxDir ;kIndx = int(kIndx) kcps = gihalbton[kIndx] endif imintim = 0 ; wenn der Wert größer ist gibts pausen zwischen den Einsätzen imaxnum = 0 insnum = 2 iwhen = 0 kdur random 0.1,0.5 ;,iwieoft kamp random -6,-3 ;,8 ;,iwieoft schedkwhen kmetro, imintim, imaxnum, insnum, iwhen, kdur,kcps,kamp printk 1/iwieoft,kIndx ;printk 1/iwieoft,kamp endin instr 2 icps = p4 iamp = ampdb(p5); random 0.1,0.5 iein = 0.01 idur = p3-iein kenv linseg 0,iein,1,idur,0 asine poscil kenv*iamp,icps outs asine,asine endin </CsInstruments> ; ============================================== <CsScore> i1 0 60 </CsScore> </CsoundSynthesizer> %%%%%%%%%%%%%%%% SNIPPET END %%%%%%%%%%%%%%%%%%%%%% Thank You, Stefan |
Date | 2021-03-01 10:38 |
From | Stefan Thomas |
Subject | Re: [Csnd] random walk without repetitions |
Dear community, I've made a mistake with the opcode. My code is: opcode StefansRandomWalk,k,iiiii iLowestIndx,iHighestIndx,iStartIndx,indxDevRange,iDevDir xin kIndxDevRange init indxDevRange kDevDir init iDevDir kIndx init iStartIndx kLowIndxBound = kDevDir < 0 ? -kIndxDevRange+kDevDir : -kIndxDevRange kHighIndxBound = kDevDir > 0 ? kIndxDevRange+kDevDir : kIndxDevRange kIndxRnd random kLowIndxBound, kHighIndxBound kIndxRnd = int(kIndxRnd) ;add to current pitch kIndx += kIndxRnd ;change direction if maxima are crossed, and report if kIndx = iHighestIndx && kDevDir > 0 then kDevDir = -kDevDir elseif kIndx = iLowestIndx && kDevDir < 0 then kDevDir = -kDevDir endif kIndx limit kIndx,iLowestIndx,iHighestIndx xout kIndx endop Am Mo., 1. März 2021 um 11:14 Uhr schrieb Stefan Thomas <kontrapunktstefan@gmail.com>:
|
Date | 2021-05-21 20:06 |
From | Partev Sarkissian <0000060b2ef1338e-dmarc-request@LISTSERV.HEANET.IE> |
Subject | Re: [Csnd] random walk without repetitions |
Random walk,... hmmm. Few weeks back was dabbling with random walk within a Bayesian space in looking at storm tracking swath region. Ever thought about rendering audio using that within this, to add to it? Just thinking out loud. Enjoy the explorations. -PBS
=================================== -----Original Message-----
From: Stefan Thomas <kontrapunktstefan@GMAIL.COM> To: CSOUND@LISTSERV.HEANET.IE Sent: Mon, Mar 1, 2021 10:38 am Subject: Re: [Csnd] random walk without repetitions Dear community,
I've made a mistake with the opcode.
My code is:
opcode StefansRandomWalk,k,iiiii
iLowestIndx,iHighestIndx,iStartIndx,indxDevRange,iDevDir xin kIndxDevRange init indxDevRange kDevDir init iDevDir kIndx init iStartIndx kLowIndxBound = kDevDir < 0 ? -kIndxDevRange+kDevDir : -kIndxDevRange kHighIndxBound = kDevDir > 0 ? kIndxDevRange+kDevDir : kIndxDevRange kIndxRnd random kLowIndxBound, kHighIndxBound kIndxRnd = int(kIndxRnd) ;add to current pitch kIndx += kIndxRnd ;change direction if maxima are crossed, and report if kIndx = iHighestIndx && kDevDir > 0 then kDevDir = -kDevDir elseif kIndx = iLowestIndx && kDevDir < 0 then kDevDir = -kDevDir endif kIndx limit kIndx,iLowestIndx,iHighestIndx xout kIndx endop Am Mo., 1. März 2021 um 11:14 Uhr schrieb Stefan Thomas <kontrapunktstefan@gmail.com>:
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 | 2021-05-22 07:38 |
From | Stefan Thomas |
Subject | Re: [Csnd] random walk without repetitions |
Dear Partev, sorry, but I have know idea what You mean by "Bayesian space". Could You maybee give a short example? Best, Stefan Am Fr., 21. Mai 2021 um 21:06 Uhr schrieb Partev Sarkissian <0000060b2ef1338e-dmarc-request@listserv.heanet.ie>:
|
Date | 2021-05-22 19:45 |
From | Partev Sarkissian <0000060b2ef1338e-dmarc-request@LISTSERV.HEANET.IE> |
Subject | Re: [Csnd] random walk without repetitions |
Somewhat random distribution within a boundary such as a search grid area or storm track boundary edge. Have the random walk occur within that boundary,... back and forth from boundary edge to boundary edge. Like a pseudo random pendulum. Still new at this, was something I was musing over. Got me wondering about the possibility of applying that here. -Partev ===================================== -----Original Message-----
From: Stefan Thomas <kontrapunktstefan@GMAIL.COM> To: CSOUND@LISTSERV.HEANET.IE Sent: Sat, May 22, 2021 7:38 am Subject: Re: [Csnd] random walk without repetitions Dear Partev,
sorry, but I have know idea what You mean by "Bayesian space".
Could You maybee give a short example?
Best,
Stefan
Am Fr., 21. Mai 2021 um 21:06 Uhr schrieb Partev Sarkissian <0000060b2ef1338e-dmarc-request@listserv.heanet.ie>:
|
Date | 2021-05-24 12:55 |
From | Tetsuya Miwa |
Subject | Re: [Csnd] random walk without repetitions |
Hi Stefan, If you just want to avoid consecutive same value of kIndex, the updated instr1 below can do it. It calls StefansRandomWalk again when the created kIndex is equal to the last value of it. instr 1 iLowestIndx = 0 ; xin iHighestIndx = lenarray(gihalbton)-1 iHighestIndx = 10 ; xin ;set pitch startpoint, deviation range and the first direction iStartIndx = 5 ; xin iIndxDev = 2 ;xin, random range for next pitch iIndxDir = 1 ;xin positive = upwards iwieoft = 3 kIndx_last init 0 ;<====== added kmetro metro iwieoft if kmetro ==1 then getkindex: ;<====== added kIndx StefansRandomWalk iLowestIndx,iHighestIndx,iStartIndx,iIndxDev,iIndxDir ;kIndx = int(kIndx) ckgoto (kIndx == kIndx_last), getkindex ;<====== added kcps = gihalbton[kIndx] endif imintim = 0 ; wenn der Wert größer ist gibts pausen zwischen den Einsätzen imaxnum = 0 insnum = 2 iwhen = 0 kdur random 0.1,0.5 ;,iwieoft kamp random -6,-3 ;,8 ;,iwieoft schedkwhen kmetro, imintim, imaxnum, insnum, iwhen, kdur,kcps,kamp printk 1/iwieoft,kIndx ;printk 1/iwieoft,kamp kIndx_last = kIndx ;<====== added endin Best, Tetsuya > 2021/03/01 19:38、Stefan Thomas |
Date | 2021-05-24 19:14 |
From | Stefan Thomas |
Subject | Re: [Csnd] random walk without repetitions |
Dear Tetsua, thanks for Your help! I will try the code as soon as possible! Best, Stefan Am Mo., 24. Mai 2021 um 13:56 Uhr schrieb Tetsuya Miwa <izc07036@nifty.com>: Hi Stefan, |