Hi,
On Sun, Sep 12, 2010 at 10:04:23PM +0200, Pierre Massat wrote:
Now please, could someone tell me how this works? Like this tan distortion, this table that switches from 0 to 1 with a variably soft transition, what is this supposed to model, and what does it do to the raw waveform?
What is happening here is called waveshaping, which just means passing a signal through some kind of (lookup) function. This is waveshaping for example:
[osc~ 440] | [cos~] | [dac~]
Here you use the output of the [osc~] to look up the value of a cosine function at that point and play that to the [dac~]. You could use a different source wave instead of the [osc~], for example play a sample. But as all audio signals can be made up from adding sinewaves, the [osc~] is a good source to analyze the waveshaping and get predictable results.
Instead of the [cos~] you can use any kind of function, for example [exp~], [abs~], [pow~] etc. For functions, that do not have a directly equivalent Pd objectclass like [cos~], it is common to store the function into a [table] object and read through it with a [tabread4~]. This also allows you to draw your own waveshaping functions with the mouse.
An [osc~] object only produces values between -1 and 1, while [tabread4~] needs to have values from 0 up to the table size to be able to read through the whole table. In fact, because of the interpolation tabread4~ does, you should start reading out at 1 and only go to "tablesize - 2".
So you need to scale the osc~-range (-1,1) to e.g. a range of (1, 1025) for a table of size 1027 as the message box [; mysine sinesum 1024 1( would produce for a [table mysine].
Scaling is made simply by addition and multiplication of the osc~ signal. Example:
[osc~ 440] -1,1 | [*~ 512] -512,512 | [+~ 512] 0,1024 | [+~ 1] 1,1025 | [tabread4~ mysine] reads from: [table mysine 1027] | [dac~]
Now try to draw around in [table mysine] a bit. :)
Writing a tanh-function into the table is popular around here as matju and Martin Peach demonstrated, but it's by far not the only way to waveshape. Chebyshev functions are well analysed, too, and work great to create clarinets from sinewaves, and exponentials and powers and all that can be used, too.
I'd like to try the sigmoid function but i don't really understand the way the whole thing works.
Just look at the size of the table that's storing the sigmoid, then scale you [osc~] accordingl. Remeber to add [+~ 1] at last and only read up to the second to last point.
Also, i'm assuming the size of the table matters. Miller's Chebyshev table in the help patch is 129 points wide, i guess the sound would improve if i made it larger, wouldn't it?
Yes.
This is all very exciting for me right now! I always thought distortion could not be properly modelised, but the stuff i've tried today sounds pretty good to me.
At least it sounds dirty. :)
Frank Barknecht Do You RjDj.me? _ ______footils.org__