Csound Csound-dev Csound-tekno Search About

[Csnd] request for help: periodic event generation

Date2009-03-28 21:35
FromDave Seidel
Subject[Csnd] request for help: periodic event generation
Hi all,

I would like to write an instrument that generates events to execute 
another instrument.  The events would very in duration, driven by a 
linseg (or similar) envelope.

I've been trying different techniques, such as:
- using a timout/reinit loop that calls the event opcode
- driving the metro opcode with the envelope, and using the output of 
metro to trigger calls to schedulekwhen

But I have no experience with any of these idioms, and am having no 
success at all so far.

Can anyone suggest an approach I might try?

(I know I could achieve a similar effect using a program to generate 
score statements, and I've already done that, but in this case I need to 
get the event generation code into the orchestra.)

- Dave

-- 
~DaveSeidel = [
   http://mysterybear.net,
   http://daveseidel.tumblr.com,
   http://twitter.com/DaveSeidel
];


Date2009-03-28 21:58
FromRory Walsh
Subject[Csnd] Re: request for help: periodic event generation
Hi David. I'm not sure I understand the problem but I normally do this
by using a metro and an if statement. I've provided an example below.
One could easily add a linseg and use the threshold opcode to trigger
the second instrument. Thinking about this I guess I could have just
provided random start times to the event opcode, could be overkill on
my part to use the if statement.

Rory.




-odevaudio -b10 -idevaudio -m0d


sr = 44100
kr = 44100
ksmps = 1
nchnls = 1

instr 1
ktime init 0.5
k1 metro abs(ktime)+2
if(k1==1) then
       ktime rand 8        ;generate random freq for metro
       kdur  rand 5        ;random duration for instr 1
       kfreq rand 12       ;random freq for instr 2

       event "i", 2, 0, abs(kdur)+3, kfreq
endif
endin

instr 2
kenv expon 10000, p3, 0.01
a1 oscil kenv, cpspch(7+(abs(p4)/100)), 1
out a1
endin



f1 0 1024 10 1 0 1
i1 0 100



Date2009-03-28 23:31
FromDave Seidel
Subject[Csnd] Re: Re: request for help: periodic event generation
Thanks, Rory, that helped a lot!

- Dave

Rory Walsh wrote:
> Hi David. I'm not sure I understand the problem but I normally do this
> by using a metro and an if statement. I've provided an example below.
> One could easily add a linseg and use the threshold opcode to trigger
> the second instrument. Thinking about this I guess I could have just
> provided random start times to the event opcode, could be overkill on
> my part to use the if statement.
> 
> Rory.
> 
> 
> 
> 
> -odevaudio -b10 -idevaudio -m0d
> 
> 
> sr = 44100
> kr = 44100
> ksmps = 1
> nchnls = 1
> 
> instr 1
> ktime init 0.5
> k1 metro abs(ktime)+2
> if(k1==1) then
>        ktime rand 8        ;generate random freq for metro
>        kdur  rand 5        ;random duration for instr 1
>        kfreq rand 12       ;random freq for instr 2
> 
>        event "i", 2, 0, abs(kdur)+3, kfreq
> endif
> endin
> 
> instr 2
> kenv expon 10000, p3, 0.01
> a1 oscil kenv, cpspch(7+(abs(p4)/100)), 1
> out a1
> endin
> 
> 
> 
> f1 0 1024 10 1 0 1
> i1 0 100
> 
> 


Date2009-03-29 02:20
FromRory Walsh
Subject[Csnd] Re: Re: Re: request for help: periodic event generation
I was thinking about this again and made the following changes. The
values in the ftable are just random values I put in and don't make
much sense but it does create periodic rhythms from an envelope stored
in a table which might be closer to what you were originally looking
for. I'm sure however there is better ways of doing this!



-odevaudio -b10 -idevaudio -m0d


sr = 44100
kr = 44100
ksmps = 1
nchnls = 1

instr 1
kndx init 1
ktime init 1
k1 metro abs(ktime*2)+2
if(k1==1) then
       ktime tab kndx%8, p4
       event "i", 2, 0, 5, p5
       kndx = kndx+1
endif
endin

instr 2
kenv expon 10000, p3, 0.01
a1 oscil kenv, p4, 1
out a1
endin



f1 0 1024 10 1 0 1
f2 0 8 2 1    0.5 1  0.5   2 0.1 1 0.3
f3 0 4 2 0.5  2   1  0.25  1 1   1 1
f4 0 4 2 3  2   10  0.25  1 4   1 4
i1 0  100 2 160
i1 4 100 3 240
i1 8 100 4 100



2009/3/28 Dave Seidel :
> Thanks, Rory, that helped a lot!
>
> - Dave
>
> Rory Walsh wrote:
>>
>> Hi David. I'm not sure I understand the problem but I normally do this
>> by using a metro and an if statement. I've provided an example below.
>> One could easily add a linseg and use the threshold opcode to trigger
>> the second instrument. Thinking about this I guess I could have just
>> provided random start times to the event opcode, could be overkill on
>> my part to use the if statement.
>>
>> Rory.
>>
>>
>> 
>> 
>> -odevaudio -b10 -idevaudio -m0d
>> 
>> 
>> sr = 44100
>> kr = 44100
>> ksmps = 1
>> nchnls = 1
>>
>> instr 1
>> ktime init 0.5
>> k1 metro abs(ktime)+2
>> if(k1==1) then
>>       ktime rand 8        ;generate random freq for metro
>>       kdur  rand 5        ;random duration for instr 1
>>       kfreq rand 12       ;random freq for instr 2
>>
>>       event "i", 2, 0, abs(kdur)+3, kfreq
>> endif
>> endin
>>
>> instr 2
>> kenv expon 10000, p3, 0.01
>> a1 oscil kenv, cpspch(7+(abs(p4)/100)), 1
>> out a1
>> endin
>>
>> 
>> 
>> f1 0 1024 10 1 0 1
>> i1 0 100
>> 
>> 
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>


Date2009-03-29 03:35
FromDave Seidel
Subject[Csnd] Re: Re: Re: Re: request for help: periodic event generation
Very cool.  Here's how I'm doing it, using a linseg envelope (sorry it's 
not a complete example):

	instr 4
idur	= p3
ifreq	= p4
iamp	= p5
ipan	= p6
ibps	= p7
itail	= p8

kbps	linseg	0, idur-itail, ibps, itail, 0
k1	metro	kbps
if (k1 == 1) then
	event	"i", 1, 0, 3, ifreq, iamp, 0, ipan
endif
	endin

Rory Walsh wrote:
> I was thinking about this again and made the following changes. The
> values in the ftable are just random values I put in and don't make
> much sense but it does create periodic rhythms from an envelope stored
> in a table which might be closer to what you were originally looking
> for. I'm sure however there is better ways of doing this!
> 
> 
> 
> -odevaudio -b10 -idevaudio -m0d
> 
> 
> sr = 44100
> kr = 44100
> ksmps = 1
> nchnls = 1
> 
> instr 1
> kndx init 1
> ktime init 1
> k1 metro abs(ktime*2)+2
> if(k1==1) then
>        ktime tab kndx%8, p4
>        event "i", 2, 0, 5, p5
>        kndx = kndx+1
> endif
> endin
> 
> instr 2
> kenv expon 10000, p3, 0.01
> a1 oscil kenv, p4, 1
> out a1
> endin
> 
> 
> 
> f1 0 1024 10 1 0 1
> f2 0 8 2 1    0.5 1  0.5   2 0.1 1 0.3
> f3 0 4 2 0.5  2   1  0.25  1 1   1 1
> f4 0 4 2 3  2   10  0.25  1 4   1 4
> i1 0  100 2 160
> i1 4 100 3 240
> i1 8 100 4 100
> 
> 
> 
> 2009/3/28 Dave Seidel :
>> Thanks, Rory, that helped a lot!
>>
>> - Dave
>>
>> Rory Walsh wrote:
>>> Hi David. I'm not sure I understand the problem but I normally do this
>>> by using a metro and an if statement. I've provided an example below.
>>> One could easily add a linseg and use the threshold opcode to trigger
>>> the second instrument. Thinking about this I guess I could have just
>>> provided random start times to the event opcode, could be overkill on
>>> my part to use the if statement.
>>>
>>> Rory.
>>>
>>>
>>> 
>>> 
>>> -odevaudio -b10 -idevaudio -m0d
>>> 
>>> 
>>> sr = 44100
>>> kr = 44100
>>> ksmps = 1
>>> nchnls = 1
>>>
>>> instr 1
>>> ktime init 0.5
>>> k1 metro abs(ktime)+2
>>> if(k1==1) then
>>>       ktime rand 8        ;generate random freq for metro
>>>       kdur  rand 5        ;random duration for instr 1
>>>       kfreq rand 12       ;random freq for instr 2
>>>
>>>       event "i", 2, 0, abs(kdur)+3, kfreq
>>> endif
>>> endin
>>>
>>> instr 2
>>> kenv expon 10000, p3, 0.01
>>> a1 oscil kenv, cpspch(7+(abs(p4)/100)), 1
>>> out a1
>>> endin
>>>
>>> 
>>> 
>>> f1 0 1024 10 1 0 1
>>> i1 0 100
>>> 
>>> 



Date2009-03-29 12:31
FromRory Walsh
Subject[Csnd] Re: Re: Re: Re: Re: request for help: periodic event generation
I'm assuming you're working on a new piece with this, in which case I
look forward to hearing it someday. Best of luck.

Rory.


2009/3/29 Dave Seidel :
> Very cool.  Here's how I'm doing it, using a linseg envelope (sorry it's not
> a complete example):
>
>        instr 4
> idur    = p3
> ifreq   = p4
> iamp    = p5
> ipan    = p6
> ibps    = p7
> itail   = p8
>
> kbps    linseg  0, idur-itail, ibps, itail, 0
> k1      metro   kbps
> if (k1 == 1) then
>        event   "i", 1, 0, 3, ifreq, iamp, 0, ipan
> endif
>        endin
>
> Rory Walsh wrote:
>>
>> I was thinking about this again and made the following changes. The
>> values in the ftable are just random values I put in and don't make
>> much sense but it does create periodic rhythms from an envelope stored
>> in a table which might be closer to what you were originally looking
>> for. I'm sure however there is better ways of doing this!
>>
>> 
>> 
>> -odevaudio -b10 -idevaudio -m0d
>> 
>> 
>> sr = 44100
>> kr = 44100
>> ksmps = 1
>> nchnls = 1
>>
>> instr 1
>> kndx init 1
>> ktime init 1
>> k1 metro abs(ktime*2)+2
>> if(k1==1) then
>>       ktime tab kndx%8, p4
>>       event "i", 2, 0, 5, p5
>>       kndx = kndx+1
>> endif
>> endin
>>
>> instr 2
>> kenv expon 10000, p3, 0.01
>> a1 oscil kenv, p4, 1
>> out a1
>> endin
>>
>> 
>> 
>> f1 0 1024 10 1 0 1
>> f2 0 8 2 1    0.5 1  0.5   2 0.1 1 0.3
>> f3 0 4 2 0.5  2   1  0.25  1 1   1 1
>> f4 0 4 2 3  2   10  0.25  1 4   1 4
>> i1 0  100 2 160
>> i1 4 100 3 240
>> i1 8 100 4 100
>> 
>> 
>>
>> 2009/3/28 Dave Seidel :
>>>
>>> Thanks, Rory, that helped a lot!
>>>
>>> - Dave
>>>
>>> Rory Walsh wrote:
>>>>
>>>> Hi David. I'm not sure I understand the problem but I normally do this
>>>> by using a metro and an if statement. I've provided an example below.
>>>> One could easily add a linseg and use the threshold opcode to trigger
>>>> the second instrument. Thinking about this I guess I could have just
>>>> provided random start times to the event opcode, could be overkill on
>>>> my part to use the if statement.
>>>>
>>>> Rory.
>>>>
>>>>
>>>> 
>>>> 
>>>> -odevaudio -b10 -idevaudio -m0d
>>>> 
>>>> 
>>>> sr = 44100
>>>> kr = 44100
>>>> ksmps = 1
>>>> nchnls = 1
>>>>
>>>> instr 1
>>>> ktime init 0.5
>>>> k1 metro abs(ktime)+2
>>>> if(k1==1) then
>>>>      ktime rand 8        ;generate random freq for metro
>>>>      kdur  rand 5        ;random duration for instr 1
>>>>      kfreq rand 12       ;random freq for instr 2
>>>>
>>>>      event "i", 2, 0, abs(kdur)+3, kfreq
>>>> endif
>>>> endin
>>>>
>>>> instr 2
>>>> kenv expon 10000, p3, 0.01
>>>> a1 oscil kenv, cpspch(7+(abs(p4)/100)), 1
>>>> out a1
>>>> endin
>>>>
>>>> 
>>>> 
>>>> f1 0 1024 10 1 0 1
>>>> i1 0 100
>>>> 
>>>> 
>
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>


Date2009-03-29 20:21
FromDave Seidel
Subject[Csnd] Re: Re: Re: Re: Re: Re: request for help: periodic event generation
Thanks, Rory.  My plan at the moment is to trigger instances of this 
little "meta-instrument" itself in real time, so as to make a 
performer-controlled piece based on the same ideas used in "Herald of 
Water, Herald of Air"[1]

- Dave

[1] http://mysterybear.net/article/34

Rory Walsh wrote:
> I'm assuming you're working on a new piece with this, in which case I
> look forward to hearing it someday. Best of luck.
> 
> Rory.
> 
> 
> 2009/3/29 Dave Seidel :
>> Very cool.  Here's how I'm doing it, using a linseg envelope (sorry it's not
>> a complete example):
>>
>>        instr 4
>> idur    = p3
>> ifreq   = p4
>> iamp    = p5
>> ipan    = p6
>> ibps    = p7
>> itail   = p8
>>
>> kbps    linseg  0, idur-itail, ibps, itail, 0
>> k1      metro   kbps
>> if (k1 == 1) then
>>        event   "i", 1, 0, 3, ifreq, iamp, 0, ipan
>> endif
>>        endin
>>
>> Rory Walsh wrote:
>>> I was thinking about this again and made the following changes. The
>>> values in the ftable are just random values I put in and don't make
>>> much sense but it does create periodic rhythms from an envelope stored
>>> in a table which might be closer to what you were originally looking
>>> for. I'm sure however there is better ways of doing this!
>>>
>>> 
>>> 
>>> -odevaudio -b10 -idevaudio -m0d
>>> 
>>> 
>>> sr = 44100
>>> kr = 44100
>>> ksmps = 1
>>> nchnls = 1
>>>
>>> instr 1
>>> kndx init 1
>>> ktime init 1
>>> k1 metro abs(ktime*2)+2
>>> if(k1==1) then
>>>       ktime tab kndx%8, p4
>>>       event "i", 2, 0, 5, p5
>>>       kndx = kndx+1
>>> endif
>>> endin
>>>
>>> instr 2
>>> kenv expon 10000, p3, 0.01
>>> a1 oscil kenv, p4, 1
>>> out a1
>>> endin
>>>
>>> 
>>> 
>>> f1 0 1024 10 1 0 1
>>> f2 0 8 2 1    0.5 1  0.5   2 0.1 1 0.3
>>> f3 0 4 2 0.5  2   1  0.25  1 1   1 1
>>> f4 0 4 2 3  2   10  0.25  1 4   1 4
>>> i1 0  100 2 160
>>> i1 4 100 3 240
>>> i1 8 100 4 100
>>> 
>>> 
>>>
>>> 2009/3/28 Dave Seidel :
>>>> Thanks, Rory, that helped a lot!
>>>>
>>>> - Dave
>>>>
>>>> Rory Walsh wrote:
>>>>> Hi David. I'm not sure I understand the problem but I normally do this
>>>>> by using a metro and an if statement. I've provided an example below.
>>>>> One could easily add a linseg and use the threshold opcode to trigger
>>>>> the second instrument. Thinking about this I guess I could have just
>>>>> provided random start times to the event opcode, could be overkill on
>>>>> my part to use the if statement.
>>>>>
>>>>> Rory.
>>>>>
>>>>>
>>>>> 
>>>>> 
>>>>> -odevaudio -b10 -idevaudio -m0d
>>>>> 
>>>>> 
>>>>> sr = 44100
>>>>> kr = 44100
>>>>> ksmps = 1
>>>>> nchnls = 1
>>>>>
>>>>> instr 1
>>>>> ktime init 0.5
>>>>> k1 metro abs(ktime)+2
>>>>> if(k1==1) then
>>>>>      ktime rand 8        ;generate random freq for metro
>>>>>      kdur  rand 5        ;random duration for instr 1
>>>>>      kfreq rand 12       ;random freq for instr 2
>>>>>
>>>>>      event "i", 2, 0, abs(kdur)+3, kfreq
>>>>> endif
>>>>> endin
>>>>>
>>>>> instr 2
>>>>> kenv expon 10000, p3, 0.01
>>>>> a1 oscil kenv, cpspch(7+(abs(p4)/100)), 1
>>>>> out a1
>>>>> endin
>>>>>
>>>>> 
>>>>> 
>>>>> f1 0 1024 10 1 0 1
>>>>> i1 0 100
>>>>> 
>>>>> 



Date2009-03-29 23:13
FromRory Walsh
Subject[Csnd] Re: Re: Re: Re: Re: Re: Re: request for help: periodic event generation
Sounds good. Keep us posted on the your progress.

Rory.


2009/3/29 Dave Seidel :
> Thanks, Rory.  My plan at the moment is to trigger instances of this little
> "meta-instrument" itself in real time, so as to make a performer-controlled
> piece based on the same ideas used in "Herald of Water, Herald of Air"[1]
>
> - Dave
>
> [1] http://mysterybear.net/article/34
>
> Rory Walsh wrote:
>>
>> I'm assuming you're working on a new piece with this, in which case I
>> look forward to hearing it someday. Best of luck.
>>
>> Rory.
>>
>>
>> 2009/3/29 Dave Seidel :
>>>
>>> Very cool.  Here's how I'm doing it, using a linseg envelope (sorry it's
>>> not
>>> a complete example):
>>>
>>>       instr 4
>>> idur    = p3
>>> ifreq   = p4
>>> iamp    = p5
>>> ipan    = p6
>>> ibps    = p7
>>> itail   = p8
>>>
>>> kbps    linseg  0, idur-itail, ibps, itail, 0
>>> k1      metro   kbps
>>> if (k1 == 1) then
>>>       event   "i", 1, 0, 3, ifreq, iamp, 0, ipan
>>> endif
>>>       endin
>>>
>>> Rory Walsh wrote:
>>>>
>>>> I was thinking about this again and made the following changes. The
>>>> values in the ftable are just random values I put in and don't make
>>>> much sense but it does create periodic rhythms from an envelope stored
>>>> in a table which might be closer to what you were originally looking
>>>> for. I'm sure however there is better ways of doing this!
>>>>
>>>> 
>>>> 
>>>> -odevaudio -b10 -idevaudio -m0d
>>>> 
>>>> 
>>>> sr = 44100
>>>> kr = 44100
>>>> ksmps = 1
>>>> nchnls = 1
>>>>
>>>> instr 1
>>>> kndx init 1
>>>> ktime init 1
>>>> k1 metro abs(ktime*2)+2
>>>> if(k1==1) then
>>>>      ktime tab kndx%8, p4
>>>>      event "i", 2, 0, 5, p5
>>>>      kndx = kndx+1
>>>> endif
>>>> endin
>>>>
>>>> instr 2
>>>> kenv expon 10000, p3, 0.01
>>>> a1 oscil kenv, p4, 1
>>>> out a1
>>>> endin
>>>>
>>>> 
>>>> 
>>>> f1 0 1024 10 1 0 1
>>>> f2 0 8 2 1    0.5 1  0.5   2 0.1 1 0.3
>>>> f3 0 4 2 0.5  2   1  0.25  1 1   1 1
>>>> f4 0 4 2 3  2   10  0.25  1 4   1 4
>>>> i1 0  100 2 160
>>>> i1 4 100 3 240
>>>> i1 8 100 4 100
>>>> 
>>>> 
>>>>
>>>> 2009/3/28 Dave Seidel :
>>>>>
>>>>> Thanks, Rory, that helped a lot!
>>>>>
>>>>> - Dave
>>>>>
>>>>> Rory Walsh wrote:
>>>>>>
>>>>>> Hi David. I'm not sure I understand the problem but I normally do this
>>>>>> by using a metro and an if statement. I've provided an example below.
>>>>>> One could easily add a linseg and use the threshold opcode to trigger
>>>>>> the second instrument. Thinking about this I guess I could have just
>>>>>> provided random start times to the event opcode, could be overkill on
>>>>>> my part to use the if statement.
>>>>>>
>>>>>> Rory.
>>>>>>
>>>>>>
>>>>>> 
>>>>>> 
>>>>>> -odevaudio -b10 -idevaudio -m0d
>>>>>> 
>>>>>> 
>>>>>> sr = 44100
>>>>>> kr = 44100
>>>>>> ksmps = 1
>>>>>> nchnls = 1
>>>>>>
>>>>>> instr 1
>>>>>> ktime init 0.5
>>>>>> k1 metro abs(ktime)+2
>>>>>> if(k1==1) then
>>>>>>     ktime rand 8        ;generate random freq for metro
>>>>>>     kdur  rand 5        ;random duration for instr 1
>>>>>>     kfreq rand 12       ;random freq for instr 2
>>>>>>
>>>>>>     event "i", 2, 0, abs(kdur)+3, kfreq
>>>>>> endif
>>>>>> endin
>>>>>>
>>>>>> instr 2
>>>>>> kenv expon 10000, p3, 0.01
>>>>>> a1 oscil kenv, cpspch(7+(abs(p4)/100)), 1
>>>>>> out a1
>>>>>> endin
>>>>>>
>>>>>> 
>>>>>> 
>>>>>> f1 0 1024 10 1 0 1
>>>>>> i1 0 100
>>>>>> 
>>>>>> 
>
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>