Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] New opcodes useful?

Date2007-12-05 13:08
From"Michael Gogins"
SubjectRe: [Cs-dev] New opcodes useful?
As it happens, I am currently working on a piece that uses the distort 
opcode, and it is an interactive piece where I recompute the wavetable for 
the Chebyshev polynomial on the fly by multiplying all of the coefficients 
in the polynomial (i.e. I change the numbers in the function table 
interactively). With small tables this is smooth and does not cause clicks, 
but with larger (quieter and better) tables there are clicks. So, I think 
your opcodes sound like a better and smoother way of doing the same thing, 
and I am looking forward to trying them out.

Regards,
Mike

----- Original Message ----- 
From: "Anthony Kozar" 
To: "Csound Developer list" 
Sent: Wednesday, December 05, 2007 3:29 AM
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
> 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

Date2007-12-05 19:55
FromAnthony Kozar
SubjectRe: [Cs-dev] New opcodes useful?
I am very glad that several people seem interested in these opcodes.  I will
try to get them into CVS tonight.

My new chebyshevpoly opcode should definitely be useful for your piece.  I
am wondering whether we need versions with k-rate input/output or a-rate
coefficients?  Hopefully, the method I am using to recalculate the linear
combination of Chebyshev polynomials is efficient enough -- perhaps it could
be improved.

You may also be interested in experimenting with powershape which also
produces smoothly varying distortion without clipping for any signal with
known upper/lower bounds.

Anthony Kozar
anthonykozar AT sbcglobal DOT net
http://anthonykozar.net/

Michael Gogins wrote on 12/5/07 8:08 AM:

> As it happens, I am currently working on a piece that uses the distort
> opcode, and it is an interactive piece where I recompute the wavetable for
> the Chebyshev polynomial on the fly by multiplying all of the coefficients
> in the polynomial (i.e. I change the numbers in the function table
> interactively). With small tables this is smooth and does not cause clicks,
> but with larger (quieter and better) tables there are clicks. So, I think
> your opcodes sound like a better and smoother way of doing the same thing,
> and I am looking forward to trying them out.


-------------------------------------------------------------------------
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-06 10:12
FromAnthony Kozar
SubjectRe: [Cs-dev] New opcodes useful?
The new waveshaping and PD opcodes are in CVS now -->  Opcodes/shape.c
SConstruct should build the new plugin library.

I will send more docs and examples tomorrow.  For now, please refer to my
prior posts.  NOTE:  I will be changing the PD opcodes to work with unipolar
signals by default before Csound 5.08 is released.  So any code that you
write with them now will have to be modified slightly.

I wrote one more new opcode tonight:  a sync-able phasor based on the
original phasor code.  It has both a sync input and sync output so that
multiple syncphasors can be chained together.  Syntax is:

    aphase, asyncout   syncphasor   xcps, asyncin [,initialphase]

Here is a quick example showing both the phase and sync outputs.  (Try
opening it in an audio editor).



nchnls = 2

instr 1
    imaxamp    =           10000
    anosync    init        0.0
    
    kslavecps  line        cpspch(p4), p3, cpspch(p4) * 3
    am, async  syncphasor  cpspch(p4), anosync
    aout, as   syncphasor  kslavecps, async
    adeclick   linseg      0.0, 0.05, 1.0, p3 - 0.1, 1.0, 0.05, 0.0
    
             out         aout * adeclick * imaxamp, as * 1000
endin




i1 0 1    7.00
i1 + 0.5  7.02
i1 + .    7.05
i1 + .    7.07
i1 + .    7.09
i1 + 2    7.06

e




Anthony Kozar
anthonykozar AT sbcglobal DOT net
http://anthonykozar.net/

Anthony Kozar wrote on 12/5/07 2:55 PM:

> I am very glad that several people seem interested in these opcodes.  I will
> try to get them into CVS tonight.


-------------------------------------------------------------------------
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-06 22:54
From"Oeyvind Brandtsegg"
SubjectRe: [Cs-dev] New opcodes useful?
AttachmentsNone  None  None  None