Csound Csound-dev Csound-tekno Search About

[Csnd] Re: Re: Re: Re: Re: Re: Re: Phasor with variable phase

Date2009-03-06 22:31
Fromvictor
Subject[Csnd] Re: Re: Re: Re: Re: Re: Re: Phasor with variable phase
If the table uses an extended guard-point as in my example,
the interpolation is between 1 and 1 + a little bit.

I tested it here and it seems to do what you want.

Victor
----- Original Message ----- 
From: "Mark Van Peteghem" 
To: 
Sent: Friday, March 06, 2009 10:25 PM
Subject: [Csnd] Re: Re: Re: Re: Re: Re: Phasor with variable phase


> Yes, the point is to keep it between 0 and 1, otherwise the effect is 
> messed up.
>
> I have thought about your solution, but unless I'm mistaken, the 
> interpolation could generate a number between 0 and 1 when it 'jumps' from 
> 1 to 0 at the end of each cycle, which would cause a stray value at the 
> end of each cycle. With the table opcode that would not happen, but then 
> the precision is too low, unless the table is very big.
>
> I think it shouldn't be that hard to let the phasor opcode accept a k-rate 
> variable for the phase, or is it?
>
> Another solution I thought of is to slightly vary the frequency to imitate 
> the phase variation (by adding the derivative of the phase variation to 
> the frequency), but I think that is more difficult than my other two 
> solutions.
>
> victor wrote:
>> I see, so the fractional bit is to make sure the modulated phase sig
>> is between 0 and 1? If so, you could always do this
>>
>> itab ftgen  1,0,1025,7,0,1024,1
>> aph phasor kfreq
>> aph tablei aph+kph,itab,1,0,1
>>
>> the phase will be modulated, but the table lookup will keep it
>> wrapped around 0-1.
>>
>> Victor
>>
>> ----- Original Message ----- From: "Mark Van Peteghem" 
>> 
>> To: 
>> Sent: Friday, March 06, 2009 9:01 PM
>> Subject: [Csnd] Re: Re: Re: Re: Phasor with variable phase
>>
>>
>>> A hypothetical example is
>>>
>>> aphasor phasor kfreq, kphase
>>> aphasor = aphasor + aphasor*(1-aphasor)*imult
>>> asig tablei kphasor, cosine, 1, 0, 1
>>>
>>> If I then add two signals like this together but one with a varying 
>>> kphase and another with a constant kphase, you get nice effects of 
>>> interference, like I already did with signals generated with vco2.
>>>
>>>
>>> Victor.Lazzarini@nuim.ie wrote:
>>>> So I can't see the need for anything extra; I am not
>>>> sure I understand the need for the frac() functions.
>>>>
>>>> Perhaps an usage example would help.
>>>>
>>>> Victor
>>>>
>>>> ----- Original Message -----
>>>> From: Michael Gogins 
>>>> Date: Friday, March 6, 2009 7:37 pm
>>>> Subject: [Csnd] Re: Re: Phasor with variable phase
>>>> To: csound@lists.bath.ac.uk
>>>>
>>>> > I think he means phase modulation.
>>>> >
>>>> > Regards,
>>>> > Mike
>>>> >
>>>> > On Fri, Mar 6, 2009 at 1:21 PM,  wrote:
>>>> > > I am not sure I understand what you want to do; phasor
>>>> > > outputs a varying phase, so I don't know what you mean
>>>> > > by a 'variable phase'.
>>>> > >
>>>> > > Victor
>>>> > >
>>>> > > ----- Original Message -----
>>>> > > From: Mark Van Peteghem 
>>>> > > Date: Friday, March 6, 2009 4:36 pm
>>>> > > Subject: [Csnd] Phasor with variable phase
>>>> > > To: csound@lists.bath.ac.uk
>>>> > >
>>>> > >> Hi,
>>>> > >>
>>>> > >> I'm looking for a way to make a phasor with a varying phase;
>>>> > >> with the
>>>> > >> phasor opcode the phase is fixed. Note that it should work for
>>>> > >> negative
>>>> > >> values of the phase, so a simple frac(x) doesn't work. So far
>>>> > >> the only
>>>> > >> two solutions I thought of are
>>>> > >>
>>>> > >> aphasor phasor kfreq
>>>> > >> aphasor = frac(frac(aphasor+kphase)-1)+1
>>>> > >>
>>>> > >> and
>>>> > >>
>>>> > >> setksmps 1
>>>> > >> kphasor phasor kfreq
>>>> > >> kphasor loopsegp kphasor+kphase, 0, 1, 1
>>>> > >> aphasor upsamp kphasor
>>>> > >>
>>>> > >> which look quite clumsy and maybe consume more CPU-time than
>>>> > >> necessary.
>>>> > >> --
>>>> > >>   Mark
>>>> > >>   _________________________________________
>>>> > >>   When you get lemons, you make lemonade.
>>>> > >>   When you get hardware, you make software.
>>>> > >>
>>>> > >>
>>>> > >>
>>>> > >> Send bugs reports to this list.
>>>> > >> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>>> > >> "unsubscribe csound"
>>>> > >
>>>> > > ========================
>>>> > > Dr Victor Lazzarini
>>>> > > Senior Lecturer
>>>> > > Dept. of Music
>>>> > > National University of Ireland, Maynooth
>>>> > >
>>>> >
>>>> >
>>>> >
>>>> > --
>>>> > Michael Gogins
>>>> > Irreducible Productions
>>>> > Michael dot Gogins at gmail dot com
>>>> >
>>>> >
>>>> > Send bugs reports to this list.
>>>> > To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>>> > "unsubscribe csound"
>>>>
>>>> ========================
>>>> Dr Victor Lazzarini
>>>> Senior Lecturer
>>>> Dept. of Music
>>>> National University of Ireland, Maynooth
>>>
>>> -- 
>>>  Mark
>>>  _________________________________________
>>>  When you get lemons, you make lemonade.
>>>  When you get hardware, you make software.
>>>
>>>
>>>
>>> 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"
>>
>>
>
> -- 
>  Mark
>  _________________________________________
>  When you get lemons, you make lemonade.
>  When you get hardware, you make software.
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe 
> csound" 


Date2009-03-07 20:17
FromMark Van Peteghem
Subject[Csnd] Re: Re: Re: Re: Re: Re: Re: Re: Phasor with variable phase
Ah, I forgot about the guard point :-)

Mark

victor wrote:
> If the table uses an extended guard-point as in my example,
> the interpolation is between 1 and 1 + a little bit.
>
> I tested it here and it seems to do what you want.
>
> Victor
> ----- Original Message ----- From: "Mark Van Peteghem" 
> 
> To: 
> Sent: Friday, March 06, 2009 10:25 PM
> Subject: [Csnd] Re: Re: Re: Re: Re: Re: Phasor with variable phase
>
>
>> Yes, the point is to keep it between 0 and 1, otherwise the effect is 
>> messed up.
>>
>> I have thought about your solution, but unless I'm mistaken, the 
>> interpolation could generate a number between 0 and 1 when it 'jumps' 
>> from 1 to 0 at the end of each cycle, which would cause a stray value 
>> at the end of each cycle. With the table opcode that would not 
>> happen, but then the precision is too low, unless the table is very big.
>>
>> I think it shouldn't be that hard to let the phasor opcode accept a 
>> k-rate variable for the phase, or is it?
>>
>> Another solution I thought of is to slightly vary the frequency to 
>> imitate the phase variation (by adding the derivative of the phase 
>> variation to the frequency), but I think that is more difficult than 
>> my other two solutions.
>>
>> victor wrote:
>>> I see, so the fractional bit is to make sure the modulated phase sig
>>> is between 0 and 1? If so, you could always do this
>>>
>>> itab ftgen  1,0,1025,7,0,1024,1
>>> aph phasor kfreq
>>> aph tablei aph+kph,itab,1,0,1
>>>
>>> the phase will be modulated, but the table lookup will keep it
>>> wrapped around 0-1.
>>>
>>> Victor
>>>
>>> ----- Original Message ----- From: "Mark Van Peteghem" 
>>> 
>>> To: 
>>> Sent: Friday, March 06, 2009 9:01 PM
>>> Subject: [Csnd] Re: Re: Re: Re: Phasor with variable phase
>>>
>>>
>>>> A hypothetical example is
>>>>
>>>> aphasor phasor kfreq, kphase
>>>> aphasor = aphasor + aphasor*(1-aphasor)*imult
>>>> asig tablei kphasor, cosine, 1, 0, 1
>>>>
>>>> If I then add two signals like this together but one with a varying 
>>>> kphase and another with a constant kphase, you get nice effects of 
>>>> interference, like I already did with signals generated with vco2.
>>>>
>>>>
>>>> Victor.Lazzarini@nuim.ie wrote:
>>>>> So I can't see the need for anything extra; I am not
>>>>> sure I understand the need for the frac() functions.
>>>>>
>>>>> Perhaps an usage example would help.
>>>>>
>>>>> Victor
>>>>>
>>>>> ----- Original Message -----
>>>>> From: Michael Gogins 
>>>>> Date: Friday, March 6, 2009 7:37 pm
>>>>> Subject: [Csnd] Re: Re: Phasor with variable phase
>>>>> To: csound@lists.bath.ac.uk
>>>>>
>>>>> > I think he means phase modulation.
>>>>> >
>>>>> > Regards,
>>>>> > Mike
>>>>> >
>>>>> > On Fri, Mar 6, 2009 at 1:21 PM,  wrote:
>>>>> > > I am not sure I understand what you want to do; phasor
>>>>> > > outputs a varying phase, so I don't know what you mean
>>>>> > > by a 'variable phase'.
>>>>> > >
>>>>> > > Victor
>>>>> > >
>>>>> > > ----- Original Message -----
>>>>> > > From: Mark Van Peteghem 
>>>>> > > Date: Friday, March 6, 2009 4:36 pm
>>>>> > > Subject: [Csnd] Phasor with variable phase
>>>>> > > To: csound@lists.bath.ac.uk
>>>>> > >
>>>>> > >> Hi,
>>>>> > >>
>>>>> > >> I'm looking for a way to make a phasor with a varying phase;
>>>>> > >> with the
>>>>> > >> phasor opcode the phase is fixed. Note that it should work for
>>>>> > >> negative
>>>>> > >> values of the phase, so a simple frac(x) doesn't work. So far
>>>>> > >> the only
>>>>> > >> two solutions I thought of are
>>>>> > >>
>>>>> > >> aphasor phasor kfreq
>>>>> > >> aphasor = frac(frac(aphasor+kphase)-1)+1
>>>>> > >>
>>>>> > >> and
>>>>> > >>
>>>>> > >> setksmps 1
>>>>> > >> kphasor phasor kfreq
>>>>> > >> kphasor loopsegp kphasor+kphase, 0, 1, 1
>>>>> > >> aphasor upsamp kphasor
>>>>> > >>
>>>>> > >> which look quite clumsy and maybe consume more CPU-time than
>>>>> > >> necessary.
>>>>> > >> --
>>>>> > >>   Mark
>>>>> > >>   _________________________________________
>>>>> > >>   When you get lemons, you make lemonade.
>>>>> > >>   When you get hardware, you make software.
>>>>> > >>
>>>>> > >>
>>>>> > >>
>>>>> > >> Send bugs reports to this list.
>>>>> > >> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>>>> > >> "unsubscribe csound"
>>>>> > >
>>>>> > > ========================
>>>>> > > Dr Victor Lazzarini
>>>>> > > Senior Lecturer
>>>>> > > Dept. of Music
>>>>> > > National University of Ireland, Maynooth
>>>>> > >
>>>>> >
>>>>> >
>>>>> >
>>>>> > --
>>>>> > Michael Gogins
>>>>> > Irreducible Productions
>>>>> > Michael dot Gogins at gmail dot com
>>>>> >
>>>>> >
>>>>> > Send bugs reports to this list.
>>>>> > To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>>>> > "unsubscribe csound"
>>>>>
>>>>> ========================
>>>>> Dr Victor Lazzarini
>>>>> Senior Lecturer
>>>>> Dept. of Music
>>>>> National University of Ireland, Maynooth
>>>>
>>>> -- 
>>>>  Mark
>>>>  _________________________________________
>>>>  When you get lemons, you make lemonade.
>>>>  When you get hardware, you make software.
>>>>
>>>>
>>>>
>>>> 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"
>>>
>>>
>>
>> -- 
>>  Mark
>>  _________________________________________
>>  When you get lemons, you make lemonade.
>>  When you get hardware, you make software.
>>
>>
>>
>> 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"
>
>

-- 
  Mark
  _________________________________________
  When you get lemons, you make lemonade.
  When you get hardware, you make software.