[Cs-dev] New opcodes useful?
Date | 2007-12-05 02:33 |
From | Anthony Kozar |
Subject | [Cs-dev] New opcodes useful? |
Attachments | pdhalf.jpg None None |
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 because 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 these 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 series. 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 kShapeAmount parameter 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 ; 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 instead 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 sets 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. |
Date | 2007-12-05 07:54 |
From | Victor.Lazzarini@nuim.ie |
Subject | Re: [Cs-dev] New opcodes useful? |
Attachments | None None None |
Date | 2007-12-05 08:29 |
From | Anthony Kozar |
Subject | Re: [Cs-dev] New opcodes useful? |
Victor.Lazzarini@nuim.ie wrote on 12/5/07 2:54 AM: > PD seem useful. UDOs are also good because they're didactical, can you > do both? Thanks. I wrote the phase dist. opcodes (and powershape below) a while ago but I will make UDOs too. > How do the waveshaping opcodes you mention > differ from simply building them with oscillator and table > lookup? They allow for _dynamic_ waveshaping where the transfer function varies over time. I have written the following opcodes so far and hope to come up with some more: aout powershape ain, kShapeAmount [, ifullscale] aout polynomial ain, ka0 [, ka1 [, ka2 [...]]] aout chebyshevpoly ain, ka0 [, ka1 [, ka2 [...]]] polynomial efficiently calculates any single-variable polynomial with k-rate coefficients. chebyshevpoly does the same but each coefficient is a multiplier for an nth-order chebyshev polynomial. With a sine wave input, this allows precise time-varying control over any number of harmonically-tuned partials, but requires only one oscillator. Manual description for powershape: This opcode is very similar to the pow unit generators that already exist in Csound for calculating the mathematical "power of" operation. However, it introduces a couple of twists which I think make it much more useful for waveshaping audio-rate signals. The kShapeAmount parameter is the exponent to which the input signal is raised. Normally, unless the exponent is an odd integer, the pow() of a negative input is a complex number, so the Csound ugens simply return zero in those cases. This will turn a bipolar audio signal into a unipolar signal with large portions of the output pinned to zero. The powershape opcode instead treats all input values as positive but preserves their sign in the output signal. This allows for smooth shaping of any input signal while varying the exponent over any range. (Powershape also (hopefully) deals intelligently with discontinuities that could arise when the exponent and input are both zero. Note though that negative exponents will usually cause the signal to exceed the maximum amplitude specified by the ifullscale parameter and should normally be avoided). The other adaptation involves the ifullscale parameter. The input signal is divided by ifullscale before being raised to kShapeAmount and then multiplied by ifullscale before being output. This normalizes the input signal to the interval [-1,1], guaranteeing that the output will also be within this range. Also, the pow() function provides a smoothly evolving transfer function when its input is in this range. Values of kShapeAmount between (0,1) will make the signal more "convex" while values greater than 1 will make it more "concave" and a value of exactly 1.0 will produce no change in the input signal. Anthony Kozar anthonykozar AT sbcglobal DOT net http://anthonykozar.net/ ------------------------------------------------------------------------- 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 |
Date | 2007-12-05 09:00 |
From | Victor.Lazzarini@nuim.ie |
Subject | Re: [Cs-dev] New opcodes useful? |
Attachments | None None None None |
Date | 2007-12-05 09:30 |
From | "Oeyvind Brandtsegg" |
Subject | Re: [Cs-dev] New opcodes useful? |
Attachments | None None None None |
Date | 2007-12-05 12:13 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Cs-dev] New opcodes useful? |
I agree that it would be excellent to have both the opcodes and the UDOs. -dB On Dec 5, 2007, at 2:54 AM, Victor.Lazzarini@nuim.ie wrote: > 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 |
Date | 2007-12-05 19:40 |
From | Anthony Kozar |
Subject | Re: [Cs-dev] New opcodes useful? |
Well, if my intuitions are correct, using continuous k-rate coefficients with either the polynomial or chebyshevpoly opcodes should produce smooth and continuous changes in the output. I have tested the latter by controlling several harmonics independently and I got smooth changes just as if I had used additive synthesis with multiple oscillators. I would be interested to know if there is some mathematical problem that I am overlooking. Regarding the phase distortion opcodes: the reason I was questioning their utility is that they DO produce aliasing because the derivative of the resulting signal is discontinuous. I think -- but am not sure -- that Casio's original implementation of this technique was not 100% digital. But depending on the genre of music, aliasing is not always a bad thing :) Another use for the PD opcodes is to use them on audio signals instead of phasors, in which case they behave as piecewise-linear transfer functions. This also produces aliasing, but they have definite applications as alternative distortion techniques. powershape is also excellent for distortion, although it can produce milder, bandlimited changes too. At least this is my understanding of everything -- I am not a DSP guru ... Anthony Kozar anthonykozar AT sbcglobal DOT net http://anthonykozar.net/ > Victor.Lazzarini@nuim.ie wrote on 12/5/07 4:00 AM: > > Interesting... I am wondering if radical changes tothe the transfer function > would cause discontinuities inthe output signal. Never thought of the > question. I'll love to try them. Coincidentally, I was only > yesterdayteaching > a class on waveshaping. >> Victor.Lazzarini@nuim.ie wrote on 12/5/07 2:54 AM: >> >>> PD seem useful. UDOs are also good because they're didactical, can you >>> do both? >> >> Thanks. I wrote the phase dist. opcodes (and powershape below) a while ago >> but I will make UDOs too. >> >>> How do the waveshaping opcodes you mention >>> differ from simply building them with oscillator and table >>> lookup? >> >> They allow for _dynamic_ waveshaping where the transfer function varies over >> time. I have written the following opcodes so far and hope to come up with >> some more: >> >> aout powershape ain, kShapeAmount [, ifullscale] >> aout polynomial ain, ka0 [, ka1 [, ka2 [...]]] >> aout chebyshevpoly ain, ka0 [, ka1 [, ka2 [...]]] ------------------------------------------------------------------------- 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 |
Date | 2007-12-05 19:52 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Cs-dev] New opcodes useful? |
They sound like they will be great and I think that they will ALL be very very useful. Can't wait to hear them - in all their aliased glory. The CZ101 lives on!!! Yeah. -dB On Dec 5, 2007, at 2:40 PM, Anthony Kozar wrote: > Well, if my intuitions are correct, using continuous k-rate > coefficients > with either the polynomial or chebyshevpoly opcodes should produce > smooth > and continuous changes in the output. I have tested the latter by > controlling several harmonics independently and I got smooth > changes just as > if I had used additive synthesis with multiple oscillators. I > would be > interested to know if there is some mathematical problem that I am > overlooking. > > Regarding the phase distortion opcodes: the reason I was > questioning their > utility is that they DO produce aliasing because the derivative of the > resulting signal is discontinuous. I think -- but am not sure -- that > Casio's original implementation of this technique was not 100% > digital. But > depending on the genre of music, aliasing is not always a bad thing :) > > Another use for the PD opcodes is to use them on audio signals > instead of > phasors, in which case they behave as piecewise-linear transfer > functions. > This also produces aliasing, but they have definite applications as > alternative distortion techniques. powershape is also excellent for > distortion, although it can produce milder, bandlimited changes too. > > At least this is my understanding of everything -- I am not a DSP > guru ... > > Anthony Kozar > anthonykozar AT sbcglobal DOT net > http://anthonykozar.net/ > > >> Victor.Lazzarini@nuim.ie wrote on 12/5/07 4:00 AM: >> >> Interesting... I am wondering if radical changes tothe the >> transfer function >> would cause discontinuities inthe output signal. Never thought of the >> question. I'll love to try them. Coincidentally, I was only >> yesterdayteaching >> a class on waveshaping. > >>> Victor.Lazzarini@nuim.ie wrote on 12/5/07 2:54 AM: >>> >>>> PD seem useful. UDOs are also good because they're didactical, >>>> can you >>>> do both? >>> >>> Thanks. I wrote the phase dist. opcodes (and powershape below) a >>> while ago >>> but I will make UDOs too. >>> >>>> How do the waveshaping opcodes you mention >>>> differ from simply building them with oscillator and table >>>> lookup? >>> >>> They allow for _dynamic_ waveshaping where the transfer function >>> varies over >>> time. I have written the following opcodes so far and hope to >>> come up with >>> some more: >>> >>> aout powershape ain, kShapeAmount [, ifullscale] >>> aout polynomial ain, ka0 [, ka1 [, ka2 [...]]] >>> aout chebyshevpoly ain, ka0 [, ka1 [, ka2 [...]]] > > > ---------------------------------------------------------------------- > --- > 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 ------------------------------------------------------------------------- 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 |
Date | 2007-12-05 19:54 |
From | Victor.Lazzarini@nuim.ie |
Subject | Re: [Cs-dev] New opcodes useful? |
Attachments | None |
Date | 2007-12-05 20:15 |
From | "Steven Yi" |
Subject | Re: [Cs-dev] New opcodes useful? |
Attachments | None |
Date | 2007-12-05 20:19 |
From | Victor.Lazzarini@nuim.ie |
Subject | Re: [Cs-dev] New opcodes useful? |
Attachments | None |
Date | 2007-12-05 20:54 |
From | "Steven Yi" |
Subject | Re: [Cs-dev] New opcodes useful? |
Attachments | None |
Date | 2007-12-05 20:59 |
From | Victor.Lazzarini@nuim.ie |
Subject | Re: [Cs-dev] New opcodes useful? |
Attachments | None None None |
Date | 2007-12-05 22:46 |
From | Tim Mortimer |
Subject | Re: [Cs-dev] New opcodes useful? |
even i must admit that i'd be tempted to play with both these casio & waveshaping opcodes desribed in this thread if & when i get back to looking into some more oscillator type synthesis at some point in the future. i want to develop some percussion syntax for my python environ eventually, so that might be the invitation to explore some of the "old school" synthesis capabilities of csound. i used to like a lot of beats & stuff back a few years ago anyway. Dub & 2 step & house & stuff. I can see the casio sitting very nicely in some of that.... & dynamic waveshaping was another area i explored unsucessfully in Max a few years ago. I don't have my head fully around the details of the implementation or discussion here, but thought i may as well add my possibly unexpected voice of support for both the opcodes & the pedagogic / hackable UDO versions -- View this message in context: http://www.nabble.com/New-opcodes-useful--tf4947099.html#a14182494 Sent from the Csound - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------- 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 |
Date | 2007-12-05 23:28 |
From | "Steven Yi" |
Subject | Re: [Cs-dev] New opcodes useful? |
Attachments | None |
Date | 2007-12-06 00:00 |
From | "Steven Yi" |
Subject | Re: [Cs-dev] New opcodes useful? |
Attachments | None phase_shaper.csd None None |
Date | 2007-12-06 01:22 |
From | Anthony Kozar |
Subject | Re: [Cs-dev] New opcodes useful? |
Steven Yi wrote on 12/5/07 6:28 PM: > Hmm... what I'm finding is that the PD is sort of like waveshaping but > for the phasor and not the audio signal (phase shaping is what I'm > calling it in this instrument I have here). Thus, what Anthony is > going for is actually different from the CZ101 if I understand the > instrument correctly. PD is exactly waveshaping for the phasor in my understanding too which is why I am lumping these opcodes with the waveshaping ones. (BTW, I like "phaseshaping" :) What might be confusing the issue right now is that my initial implementations of the PD opcodes expect bipolar signals. I plan to change that before they become public to be unipolar with an option for bipolar behavior. The pdhalf opcode is supposed to exactly mimic the CZ-series PD "pattern" that changes a sine wave into a sawtooth approximation. The other two opcodes, pdclip and pdhalfy, represent my own variations on the technique. > andx phasor kpchline > andx table3 andx, giphaseshape_ |
Date | 2007-12-06 06:36 |
From | "Steven Yi" |
Subject | Re: [Cs-dev] New opcodes useful? |
Attachments | None phase_shaper.csd None None |
Date | 2007-12-06 10:05 |
From | Anthony Kozar |
Subject | Re: [Cs-dev] New opcodes useful? |
Steven Yi wrote on 12/6/07 1:36 AM: > (I've attached the > latest version if anyone is interested to render and hear how it's > coming along. =) ) Thanks Steven! Looking forward to trying this out. > I was wondering though that from the experience of doing this now > without *that* much Csound code, I am wondering what advantages are > there to having it as a C opcode library versus a UDO? Well, that is one of the reasons that I was questioning it ... Anthony ------------------------------------------------------------------------- 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 |
Date | 2007-12-06 12:47 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Cs-dev] New opcodes useful? |
Steven, Really wonderful instrument and musical demo. So happy you are working in this area. It was a fantastic instrument in its day. I had 2 of them and loved them. In fact, I hope to buy one again on eBay. Excellent for teaching!!!! Thanks Anthony too - for bringing this into focus for us all. -dB On Dec 6, 2007, at 1:36 AM, Steven Yi wrote: > My head is still buzzing about all this, very interesting sounds! I > spent a couple hours tonight together with the CZ101 manual and > continued to take the instrument from earlier further on, implementing > a lot of the CZ101 features. I've got most of the signal routing > established, now have left to work on the filter key follow that > adjusts amount of phaseshaping to do depending on frequency, but am > getting close. It's not going to be a CZ101 clone as there's some > things I'm not interested to mimic like the 8 stage envelope, but a > lot of the sound quality is there and very similar features which > should make this very useful. If anything, I'm enjoying the sounds > very much! I'll send a message out to the main mailing list and blue > list with copies of the instrument when complete. (I've attached the > latest version if anyone is interested to render and hear how it's > coming along. =) ) > > I was wondering though that from the experience of doing this now > without *that* much Csound code, I am wondering what advantages are > there to having it as a C opcode library versus a UDO? > > steven > > On Dec 5, 2007 5:22 PM, Anthony Kozar |
Date | 2007-12-06 13:30 |
From | Dave Phillips |
Subject | Re: [Cs-dev] New opcodes useful? |
Dr. Richard Boulanger wrote: re: CZ101 > Really wonderful instrument and musical demo. So happy you are > working in this area. > It was a fantastic instrument in its day. I had 2 of them and loved > them. In fact, I hope to > buy one again on eBay. Excellent for teaching!!!! I have one sitting here beside me, I use it to test various synth patches but never use it for its own sounds anymore. Sigh... I have four hardware synths here, and I haven't used any of them for years. Best, dp ------------------------------------------------------------------------- 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 |