|
While I don't have an in depth explanation, I do have a real world example that might help some people wrap there heads around i(). I use the i() operator a lot when I am working with wiimote pieces. I usually set one of the wiimote's motion outputs, such as the pitch or x-axis acceleration to a k-rate global variable(i.e. gkpit or gkx). Then I use one of the other outputs such as the Y-axis to set off a trigger, which leads to a schedkwhen which creates an instance of an instrument. Inside the instrument are lines such as "kfreq = i(gkpit)" or "kamp = i(gkx)". These lines basically sample the values of the global variables which can then be used to control various parameters of the sound. In this context, using the i() operator eliminates the need for several lines of code featuring "samphold" and "trigger" for each global variable.
Mark
----- Original Message ----
From: Julian Peterson
To: csound@lists.bath.ac.uk
Sent: Thursday, December 25, 2008 12:29:05 AM
Subject: [Csnd] Re: Re: Re: k to i
Hi Lou:
No. As Art H. points out, this requires the reinit opcode.
Essentially, i(k) allows you to use data that's stored in a k variable as an init value. However, this is tricky, because the i pass happens before the first k pass. Thus, the following doesn't work:
instr 1
kblah = 1
iblah = i(kblah)
print iblah
endin
because the variable kblah isn't assigned 1 until after iblah tries to pull a value from kblah. If you run this instrument as it is, it tells you that iblah = 0, not 1.
i() only works in cases where the kpass has already occurred. For what you are trying to do, this should work. You would be writing a value from a FLTK slider to a global k value from one instrument; then when a second instrument is activated, it can take the value already written to the global k value by the first instrument as an i value.
This is somewhat confusing; suffice to say that the i() operator is only useful in circumstances where another instrument has written a value to a global k value or if the instrument in question reinitializes its values at some point after it has already made a k pass.
Does anyone know of a good explanation of this out there on the web or in a book? Understanding the whole i-pass k-pass process, esp. with respect to i() can be confusing to those who haven't had to use it before, and I'm afraid that my rather terse explanation might not be all that useful : )
J
On Dec 24, 2008, at 8:21 PM, Lou Cohen wrote:
> Art,
>
> Does this mean that an i-time parameter can be varied at k-rate, as in:
>
> krisetemp init 1
> idur = p3
> idec init 0.1
> krisetemp = krisetemp * 1.0001
> irise = i(krisetemp)
> kres linen kamp, irise, idur, idec
>
> I can't quite imagine what happens at initialization time, and what happens
> later on with code like this.
>
> Thanks for clarifying! and happy holidays to all.
>
> -Lou
>
>
> On 12/24/08 17:25, "Art Hunkins " wrote:
>
>> Use the i function - as in, i(x). X is the k-time variable. Just don't use
>> it in a k-rate expression; use it alone.
>>
>> Art Hunkins
>>
>> ----- Original Message -----
>> From: "CarlosJP"
>> To:
>> Sent: Wednesday, December 24, 2008 4:39 PM
>> Subject: [Csnd] k to i
>>
>>
>>>
>>> Hi,
>>>
>>> I would like to control exp envelope duration from a fltk valuator. The
>>> problem is that expseg dur paramater is an i-time one and the output of
>>> the
>>> valuator has k-rate instead. It's fine for me if an idur variable is first
>>> initialized to the current value of the valuator (that is, ignoring later
>>> widget changes during that note's span), but I don't know how to achieve
>>> that initial k to i conversion, if possible at all. Any help would be
>>> appreciated.
>>>
>>> Best regards
>>> -Carlos
>>> --View this message in context:
>>> http://www.nabble.com/k-to-i-tp21156957p21156957.html
>>> Sent from the Csound - General mailing list archive at Nabble.com.
>>>
>>>
>>>
>>> Send bugs reports to this list.
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>>> csound"
>>
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
|