| Hi, Andrés,
Thanks for you rapid response. Your suggestion seems to make sense. I will
have a chance to try it in a day or so, and let you know.
-Lou
On 11/5/08 16:50, "Andres Cabrera " wrote:
> Hi Lou,
>
> Whenever an instrument event (i-statement or MIDI event) occurs, all
> opcodes inside the instrument call their initialization functions.
> This is the init-pass. This happens once per note unless reinit is
> called. Then the k-perf loop executes, which means that opcodes update
> their k-rate and a-rate values. So in effect, i-rate values are only
> updated on the init pass and k- and a-rate values are updated once
> every control block (a-rate variables are actually vectors (lists)
> which are processed once per k-period).
> The init pass includes the opcodes within UDOs as well. I suspect that
> for UDOs, the xin opcode has not updated the k-rate variables when the
> init pass is performed, so i(kphase) is probably always 0. You should
> probably do the conversion to i-rate outside the UDO in the caller
> instrument, and have the UDO take an i-rate variable for that
> parameter.
>
> You may also need to use the "init" opcode to have a k-rate variable
> take a value at the init pass.
>
> Let me know if this works.
>
> Cheers,
> Andrés
>
>
> On Wed, Nov 5, 2008 at 12:54 PM, Lou Cohen wrote:
>> I've written a UDO that accepts a k-rate variable and passes it to oscil as
>> the "phase" parameter. Since oscil requires that "phase" be an i-rate
>> variable, I convert the k-rate variable to i-rate using the i()
>> construction.
>>
>> This seems to give me the result I want, namely that the signal returned
>> from oscil is displaced by the desired phase. However, I don't ALWAYS get
>> the desired result. Sometimes the oscil opcode behaves as if "phase" is zero
>> even when it's not.
>>
>> Is there something about initialization and krate that I may be
>> misunderstanding?
>>
>> Below is the UDO that appears to sometimes treat phase as zero even though
>> I'm passing in a non-zero value. The printout always shows k(iphase) to be
>> zero. I'm having trouble actually looking at i(kphase), since it's an i-rate
>> variable inside of a UDO.
>>
>>
>> Given hi, low, table, cycles and phase, return current value
>> ;syntax:
>> ;kscaled valuefromtable ihi, itable, ilow, icycles, iphase, idur,
>> iinterptype
>>
>> opcode valuefromtable, k,KKKKKKKK
>>
>> khi,ktable,klow,kcycles,kphase,kdur,kinterptype, kdebug xin
>> ikphase = i(kphase)
>> kunscaled oscili 1, kcycles/kdur, i(ktable), ikphase
>> if(kinterptype == 0) then
>> kscaled getvallinear khi, klow, kunscaled
>> endif
>> if(kinterptype == 1) then
>> kscaled getvalexponential khi, klow, kunscaled
>> endif
>>
>> if(kdebug<0) then
>> printk 5,khi,8
>> printk 5,klow,8
>> printk 5,kphase,8
>> printk 5,k(ikphase),8
>> printk 5,kscaled,8
>> endif
>>
>> xout kscaled
>> endop
>>
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>
>
---------------------------
Permanent email: loucohen@jolc.net
Music and video: http://ruccas.org/wiki.pl/Lou_Cohen
More music and video: http://www.youtube.com/loucohen
Astronomy: http://www.jolc.net
Open Sound: http://www.opensound.org
QFD:
http://www.pearsonhighered.com/educator/academic/product/0,3110,0201633302,0
0.html
----------------------------
|