Csound Csound-dev Csound-tekno Search About

[Cs-dev] [Victor.Lazzarini@nuim.ie: Re: New opcodes useful?]

Date2007-12-05 17:59
From
Subject[Cs-dev] [Victor.Lazzarini@nuim.ie: Re: New opcodes useful?]
Just a mild request; can we limit HTML mail to this list?  I really
find this unreadable
------- Start of forwarded message -------
PD seem useful. UDOs are also good because they're didactical, can you
do both?
 
How do the waveshaping opcodes you mention
differ from simply building them with oscillator and table
lookup?

Victor
----- Original Message -----
From: Anthony Kozar <anthonykozar@sbcglobal.net>
Date: Wednesday, December 5, 2007 2:33 am
Subject: [Cs-dev] New opcodes useful?
To: New Csound Developer list <csound-devel@lists.sourceforge.net>

> I am also planning to add a few new opcodes in the next few days
> for dynamic
> waveshaping and phase distortion.  I am sure that the
> waveshaping opcodes
> will be useful, but I wonder about the phase distortion
> ones.  I am
> considering adding them becaus e two of them would require ksmps
> == 1 to
> emulate with orchestra code.  (pdclip could be emulated
> with the limit
> opcode, I think).  Do you think t hese opcodes will be
> useful enough or
> should I just make them available as UDOs?
>
> aout    pdhalf      ain,
> kShapeAmount [, ifullscale]
> aout    pdhalfy     ain,
> kShapeAmount [, ifullscale]
> aout    pdclip      ain,
> kWidth, kCenter [, ifullscale]
>
> PDhalf
>
> This opcode is designed to emulate the "classic" phase
> distortion synthesis
> method of the Casio CZ-series of synthesizers from the mid-
> 1980's.  This
> technique reads the first and second halves of a function table
> at different
> rates in order to warp the waveform.  ; The rates are chosen
> so that the
> overall period of oscillation is preserved.  Thus, phase
> distortion can only
> produce higher partials in a harmonic s eries.  It does not
> produce sidebands
> which may be inharmonic in the way that frequency modulation does.
>
> pdhalf calculates a transfer function which is composed of two linear
> segments.  (See attached image).  These segments meet
> at a "pivot point"
> which always lies on the x axis (for a bipolar input).  The
> kShapeAmountparameter specifies where on the x axis this point
> falls.  The negative half
> of the input range is mapped linearly between -1.0*ifullscale and
> kShapeAmount.  The positive half is mapped linearly between
> kShapeAmount and
> ifullscale.  A value of zero for kShapeAmount will not have
> any effect on
> the input signal.  If the output is used to index a table,
> values for
> kShapeAmount that are less than zero will cause the first half
> of the table
> to be read more quickly than the second half.  The reverse
> is true for
> values of kShapeAmount greater than zero.
>
> Currently, pdhalf expects a bipolar input signal.  So you
> must scale and
> offset your input (and output!) appropriately if it is a
> unipolar phasor.  I
> will probably add an optional parameter to support unipolar
> signals before
> committing.  kShapeAmount is always between -1 and 1 for
> bipolar operation.
>
> A typical example of the use of pdhalf is
>   aosc  phasor  ifreq
>   apd   pdhalf  2*aosc - 1.0,
> kamount   ; convert aosc to bipolar
>   aout  tablei  0.5*(apd+1.0), 1,
> 1  &nb sp;  ; convert apd back to unipolar
>
> PDhalfy
>
> This is a variation on PDhalf that places the pivot point of the phase
> distortion on the y axis ins tead of the x axis.  Thus, it
> does not read the
> two halves of a table at different rates, but instead divides it
> into two
> segments of different sizes depending upon the kShapeAmount
> parameter.  Each
> of these segments is then mapped to half of the oscillator
> period (or just
> the output range if not being used to distort a phasor). 
> This opcode has a
> milder quality to its distortion in my experience.
>
> PDclip
>
> This opcode performs linear clipping on the input signal ain.
> kwidth is the
> percentage of the signal range that is clipped (must be between
> 0 and 1).
> The rest of the input range is mapped linearly from -ifullscale to
> ; ifullscale.  kcenter specifies an offset for shifting the
> unclipped window
> of the signal higher or lower in the range (essentially a DC offset).
> ifullscale se ts the maximum amplitude of the input and output signals
> (defaults to 1.0).
>
> This amounts to waveshaping the input with the following
> transfer function
> (normalized to ifullscale=1.0) :
>
>         1|  
> _______      width of clipped region is
> kwidth         | 
> /             width of unclipped region is (1-kwidth)
>          |
> /              kcenter shifts the unclipped region
> -1       ;
> |/        1        left or right (up to kwidth)
> --------------------
>          /|
>        / |
>       /  |
> ------   |-1
>
> This opcode may be used for direct, linear distortion of an
> audio signal.
> Alternatively, you might use it to modify the output of a phasor
> before it
> is used to index a function table, effectively making this a phase
> distortion technique.
>
> > -----------------------------------------------------------------
> --------
> SF.Net email is sponsored by: The Future of Linux Business White Paper
> from Novell.  From the desktop to the data center, Linux is going
> mainstream.  Let it simplify your IT future.
> http://altfarm.mediapl ex.com/ad/ck/8857-50307-18918-4> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourcef orge.net/lists/listinfo/csound-devel - ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/csound-devel  -=- MIME -=-  This is a multi-part message in MIME format. --Boundary_(ID_CVeaDXSk8bQb4FmKOISlfA) Content-type: text/html; charset=us-ascii Content-transfer-encoding: quoted-printable Content-disposition: inline PD seem useful=2E UDOs are also good because they=27re didactical=2C can= you=3CBR=3Edo both=3F=3CBR=3E=26nbsp=3B=3CBR=3EHow do the waveshaping o= pcodes you mention=3CBR=3Ediffer from simply building them with oscillat= or and table=3CBR=3Elookup=3F=3CBR=3E=3CBR=3EVictor=3CBR=3E----- Origina= l Message -----=3CBR=3EFrom=3A Anthony Kozar =26lt=3Banthonykozar=40sbcg= lobal=2Enet=26gt=3B=3CBR=3EDate=3A Wednesday=2C December 5=2C 2007 2=3A3= 3 am=3CBR=3ESubject=3A =5BCs-dev=5D New opcodes useful=3F=3CBR=3ETo=3A N= ew Csound Developer list =26lt=3Bcsound-devel=40lists=2Esourceforge=2Ene= t=26gt=3B=3CBR=3E=3CBR=3E=26gt=3B I am also planning to add a few new op= codes in the next few days =3CBR=3E=26gt=3B for dynamic=3CBR=3E=26gt=3B = waveshaping and phase distortion=2E=26nbsp=3B I am sure that the =3CBR=3E= =26gt=3B waveshaping opcodes=3CBR=3E=26gt=3B will be useful=2C but I won= der about the phase distortion =3CBR=3E=26gt=3B ones=2E=26nbsp=3B I am=3C= BR=3E=26gt=3B considering adding them because two of them would require = ksmps =3CBR=3E=26gt=3B =3D=3D 1 to=3CBR=3E=26gt=3B emulate with orchestr= a code=2E=26nbsp=3B (pdclip could be emulated =3CBR=3E=26gt=3B with the = limit=3CBR=3E=26gt=3B opcode=2C I think)=2E=26nbsp=3B Do you think these= opcodes will be =3CBR=3E=26gt=3B useful enough or=3CBR=3E=26gt=3B shoul= d I just make them available as UDOs=3F=3CBR=3E=26gt=3B =3CBR=3E=26gt=3B= aout=26nbsp=3B=26nbsp=3B=26nbsp=3B pdhalf=26nbsp=3B=26nbsp=3B=26nbsp=3B= =26nbsp=3B=26nbsp=3B ain=2C =3CBR=3E=26gt=3B kShapeAmount =5B=2C ifullsc= ale=5D=3CBR=3E=26gt=3B aout=26nbsp=3B=26nbsp=3B=26nbsp=3B pdhalfy=26nbsp= =3B=26nbsp=3B=26nbsp=3B=26nbsp=3B ain=2C =3CBR=3E=26gt=3B kShapeAmount =5B= =2C ifullscale=5D=3CBR=3E=26gt=3B aout=26nbsp=3B=26nbsp=3B=26nbsp=3B pdc= lip=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B ain=2C =3CBR=3E=26= gt=3B kWidth=2C kCenter =5B=2C ifullscale=5D=3CBR=3E=26gt=3B =3CBR=3E=26= gt=3B PDhalf=3CBR=3E=26gt=3B =3CBR=3E=26gt=3B This opcode is designed to= emulate the =22classic=22 phase =3CBR=3E=26gt=3B distortion synthesis=3C= BR=3E=26gt=3B method of the Casio CZ-series of synthesizers from the mid= -=3CBR=3E=26gt=3B 1980=27s=2E=26nbsp=3B This=3CBR=3E=26gt=3B technique r= eads the first and second halves of a function table =3CBR=3E=26gt=3B at= different=3CBR=3E=26gt=3B rates in order to warp the waveform=2E=26nbsp= =3B The rates are chosen =3CBR=3E=26gt=3B so that the=3CBR=3E=26gt=3B ov= erall period of oscillation is preserved=2E=26nbsp=3B Thus=2C phase =3CB= R=3E=26gt=3B distortion can only=3CBR=3E=26gt=3B produce higher partials= in a harmonic series=2E=26nbsp=3B It does not =3CBR=3E=26gt=3B produce = sidebands=3CBR=3E=26gt=3B which may be inharmonic in the way that freque= ncy modulation does=2E=3CBR=3E=26gt=3B =3CBR=3E=26gt=3B pdhalf calculate= s a transfer function which is composed of two linear=3CBR=3E=26gt=3B se= gments=2E=26nbsp=3B (See attached image)=2E=26nbsp=3B These segments mee= t =3CBR=3E=26gt=3B at a =22pivot point=22=3CBR=3E=26gt=3B which always l= ies on the x axis (for a bipolar input)=2E=26nbsp=3B The =3CBR=3E=26gt=3B= kShapeAmountparameter specifies where on the x axis this point =3CBR=3E= =26gt=3B falls=2E=26nbsp=3B The negative half=3CBR=3E=26gt=3B of the inp= ut range is mapped linearly between -1=2E0*ifullscale and=3CBR=3E=26gt=3B= kShapeAmount=2E=26nbsp=3B The positive half is mapped linearly between = =3CBR=3E=26gt=3B kShapeAmount and=3CBR=3E=26gt=3B ifullscale=2E=26nbsp=3B= A value of zero for kShapeAmount will not have =3CBR=3E=26gt=3B any eff= ect on=3CBR=3E=26gt=3B the input signal=2E=26nbsp=3B If the output is us= ed to index a table=2C =3CBR=3E=26gt=3B values for=3CBR=3E=26gt=3B kShap= eAmount that are less than zero will cause the first half =3CBR=3E=26gt=3B= of the table=3CBR=3E=26gt=3B to be read more quickly than the second ha= lf=2E=26nbsp=3B The reverse =3CBR=3E=26gt=3B is true for=3CBR=3E=26gt=3B= values of kShapeAmount greater than zero=2E=3CBR=3E=26gt=3B =3CBR=3E=26= gt=3B Currently=2C pdhalf expects a bipolar input signal=2E=26nbsp=3B So= you =3CBR=3E=26gt=3B must scale and=3CBR=3E=26gt=3B offset your input (= and output!) appropriately if it is a =3CBR=3E=26gt=3B unipolar phasor=2E= =26nbsp=3B I=3CBR=3E=26gt=3B will probably add an optional parameter to = support unipolar =3CBR=3E=26gt=3B signals before=3CBR=3E=26gt=3B committ= ing=2E=26nbsp=3B kShapeAmount is always between -1 and 1 for =3CBR=3E=26= gt=3B bipolar operation=2E=3CBR=3E=26gt=3B =3CBR=3E=26gt=3B A typical ex= ample of the use of pdhalf is=3CBR=3E=26gt=3B =26nbsp=3B aosc=26nbsp=3B = phasor=26nbsp=3B ifreq=3CBR=3E=26gt=3B =26nbsp=3B apd=26nbsp=3B=26nbsp=3B= pdhalf=26nbsp=3B 2*aosc - 1=2E0=2C =3CBR=3E=26gt=3B kamount=26nbsp=3B=26= nbsp=3B =3B convert aosc to bipolar=3CBR=3E=26gt=3B =26nbsp=3B aout=26nb= sp=3B tablei=26nbsp=3B 0=2E5*(apd+1=2E0)=2C 1=2C =3CBR=3E=26gt=3B 1=26nb= sp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B =3B convert apd back to unipolar=3CB= R=3E=26gt=3B =3CBR=3E=26gt=3B PDhalfy=3CBR=3E=26gt=3B =3CBR=3E=26gt=3B T= his is a variation on PDhalf that places the pivot point of the phase=3C= BR=3E=26gt=3B distortion on the y axis instead of the x axis=2E=26nbsp=3B= Thus=2C it =3CBR=3E=26gt=3B does not read the=3CBR=3E=26gt=3B two halve= s of a table at different rates=2C but instead divides it =3CBR=3E=26gt=3B= into two=3CBR=3E=26gt=3B segments of different sizes depending upon the= kShapeAmount =3CBR=3E=26gt=3B parameter=2E=26nbsp=3B Each=3CBR=3E=26gt=3B= of these segments is then mapped to half of the oscillator =3CBR=3E=26g= t=3B period (or just=3CBR=3E=26gt=3B the output range if not being used = to distort a phasor)=2E=26nbsp=3B =3CBR=3E=26gt=3B This opcode has a=3CB= R=3E=26gt=3B milder quality to its distortion in my experience=2E=3CBR=3E= =26gt=3B =3CBR=3E=26gt=3B PDclip=3CBR=3E=26gt=3B =3CBR=3E=26gt=3B This o= pcode performs linear clipping on the input signal ain=2E =3CBR=3E=26gt=3B= kwidth is the=3CBR=3E=26gt=3B percentage of the signal range that is cl= ipped (must be between =3CBR=3E=26gt=3B 0 and 1)=2E=3CBR=3E=26gt=3B The = rest of the input range is mapped linearly from -ifullscale to=3CBR=3E=26= gt=3B ifullscale=2E=26nbsp=3B kcenter specifies an offset for shifting t= he =3CBR=3E=26gt=3B unclipped window=3CBR=3E=26gt=3B of the signal highe= r or lower in the range (essentially a DC offset)=2E=3CBR=3E=26gt=3B ifu= llscale sets the maximum amplitude of the input and output signals=3CBR=3E= =26gt=3B (defaults to 1=2E0)=2E=3CBR=3E=26gt=3B =3CBR=3E=26gt=3B This am= ounts to waveshaping the input with the following =3CBR=3E=26gt=3B trans= fer function=3CBR=3E=26gt=3B (normalized to ifullscale=3D1=2E0) =3A=3CBR= =3E=26gt=3B =3CBR=3E=26gt=3B =26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26= nbsp=3B=26nbsp=3B=26nbsp=3B 1=7C=26nbsp=3B=26nbsp=3B =3CBR=3E=26gt=3B =5F= =5F=5F=5F=5F=5F=5F=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B wid= th of clipped region is =3CBR=3E=26gt=3B kwidth=26nbsp=3B=26nbsp=3B=26nb= sp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B =7C=26nbsp=3B =3C= BR=3E=26gt=3B /=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp= =3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B width of= unclipped region is (1-kwidth)=3CBR=3E=26gt=3B =26nbsp=3B=26nbsp=3B=26n= bsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B =7C =3CBR=3E=26= gt=3B /=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nb= sp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B kcente= r shifts the unclipped region=3CBR=3E=26gt=3B -1=26nbsp=3B=26nbsp=3B=26n= bsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B =3CBR=3E=26gt=3B =7C/=26nbsp=3B=26n= bsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B 1=26nbsp=3B=26n= bsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B left or right (= up to kwidth)=3CBR=3E=26gt=3B --------------------=3CBR=3E=26gt=3B =26nb= sp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B /=7C=3C= BR=3E=26gt=3B =26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B= / =7C=3CBR=3E=26gt=3B =26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B=26nbsp=3B= /=26nbsp=3B =7C=3CBR=3E=26gt=3B ------=26nbsp=3B=26nbsp=3B =7C-1=3CBR=3E= =26gt=3B =3CBR=3E=26gt=3B This opcode may be used for direct=2C linear d= istortion of an =3CBR=3E=26gt=3B audio signal=2E=3CBR=3E=26gt=3B Alterna= tively=2C you might use it to modify the output of a phasor =3CBR=3E=26g= t=3B before it=3CBR=3E=26gt=3B is used to index a function table=2C effe= ctively making this a phase=3CBR=3E=26gt=3B distortion technique=2E=3CBR= =3E=26gt=3B =3CBR=3E=26gt=3B =26gt=3B ----------------------------------= -------------------------------=3CBR=3E=26gt=3B --------=3CBR=3E=26gt=3B= SF=2ENet email is sponsored by=3A The Future of Linux Business White Pa= per=3CBR=3E=26gt=3B from Novell=2E=26nbsp=3B From the desktop to the dat= a center=2C Linux is going=3CBR=3E=26gt=3B mainstream=2E=26nbsp=3B Let i= t simplify your IT future=2E=3CBR=3E=26gt=3B http=3A//altfarm=2Emediaple= x=2Ecom/ad/ck/8857-50307-18918-4=26gt=3B =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=3CBR=3E=26gt=3B Csound-devel mailin= g list=3CBR=3E=26gt=3B Csound-devel=40lists=2Esourceforge=2Enet=3CBR=3E=26= gt=3B https=3A//lists=2Esourceforge=2Enet/lists/listinfo/csound-devel --Boundary_(ID_CVeaDXSk8bQb4FmKOISlfA) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 --Boundary_(ID_CVeaDXSk8bQb4FmKOISlfA) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/csound-devel --Boundary_(ID_CVeaDXSk8bQb4FmKOISlfA)-- ------- End of forwarded message ------- ==John ffitch ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net

Date2007-12-05 18:31
FromVictor.Lazzarini@nuim.ie
SubjectRe: [Cs-dev] [Victor.Lazzarini@nuim.ie: Re: New opcodes useful?]
AttachmentsNone  None  None