Skip to content

Drawable Waveshaper

April 6, 2012

Polynomial Waveshaper

I had a request recently for a drawable waveshaper. It seemed like a simple project but then I realized it would come with a lot of aliasing if not properly implemented. I decided on using a 4-point interpolation to get around this – for every point, the waveshaper interpolates between the closest 4 data values and finds the best approximation.

The result is pretty interesting. As you can see from the image, some pretty complex waveforms can be designed with ease. I’ve included an example ensemble that uses a Ramp Osc to run the waveshaper, basically turning it into an oscillator.  The example ensemble is just that – it is not meant to be a finished project but just something to show you what this can do.

One thing to remember is that for an input of 0, this macro does not necessarily output a 0 as most waveshapers will. Hence, it usually makes sense to use this macro in conjunction with an envelope to keep it off when no sound is running through. It is possible to change the length of the table and the color of the display as demonstrated in the example ensemble.

If anybody uses this for a project, please let me know!

Download here.

17 Comments leave one →
  1. meter maid permalink
    April 6, 2012 3:50 pm

    Wow cool. This is one of those simple to use things that turns into a black hole for time. Can you think of a way to use it to drive a distortion unit like this?

    The structure of that one is pretty terrifying to me.

    • April 6, 2012 4:14 pm

      As long as you make it so that x = 0 outputs 0 you shouldn’t haven any problems using this as a normal waveshaper. You can right click to set any data point to 0 so you can just identify the center one and set it to 0 and it should work as a distortion unit. You could hardcode it to do this automatically with a bit of work, pretty simple if you choose to use a set length.

      Very strange how similar that looks, I swear I’ve never seen it before!

      • meter maid permalink
        April 6, 2012 8:12 pm

        That’s quite a bit over my head actually but I’m having a lot of fun making an instrument with it.

        If the mood ever strikes, a picture tutorial on what you said above would be well appreciated.

      • April 6, 2012 8:18 pm

        Normally a waveshaper is some function f(x) = y, for example y = tanh x. normally, a function is chosen such that f(0) = 0, so when there is no sound coming in, no sound is going out.

        With this macro, you’re drawing your own equation, one where f(0) can equal whatever you want. If you set it up properly, you can have f(0) = 0, see the first snapshot for an example (I think). The graph goes from x = -1 to x =1, so x = 0 is right in the middle. Hope that helps!

        If you don’t want to deal with all that, it would also be trivial to read the amplitude of the incoming audio and turn off the waveshaper when the amp = 0.

      • meter maid permalink
        April 6, 2012 10:22 pm

        I am a bit slow to catch on, especially to math and technical implementation but after just throwing some audio into the input I was happily surprised. It probably sounds closer to what I was originally looking for without any modification (industrial as hell).

        I put together a nice test ensemble that switches between effect and instrument mode but polyphony is quirky, each extra note doubles the overall volume. Is there a simple fix? I took a look at some different polyphonic patches and couldn’t see where this behavior would be inhibited.

      • April 7, 2012 9:04 am

        I just checked with a peak detector and it doesn’t seem to me like the waveform grows any faster than a normal sine during polyphony? Maybe my test was inaccurate…

        Glad you’re finding a use for it!

    • meter maid permalink
      April 7, 2012 5:56 pm

      When I first asked I didn’t think this would work as an audio effect so now I’m curious how your above statements would improve it. I guess it seems pretty unpredictable as it is.

      “If you don’t want to deal with all that, it would also be trivial to read the amplitude of the incoming audio and turn off the waveshaper when the amp = 0”

      Is there a macro or solution for this somewhere? I tried fiddling with a peak detector and compare= but I’m pretty lost.

      • April 7, 2012 9:17 pm

        Oh I don’t know… I think maybe peak detector (on the incoming signal, of course) into compare > 0; use that as a fade control for a crossfader, where the 1 input is the waveshaper and 0 input is the sound source.

        Just a guess.

  2. Michael O'Hagan permalink
    April 7, 2012 2:47 am

    This is awesome, I would love to see an 8 or 16 step wavetable version of this, do you think that would be possible?

    thanks for all your creations sir!!!

    • April 7, 2012 9:07 am

      Howdy, I’m not sure I understand – in what way would this differ from the example ensemble with the length set to 8 or 16? I’m quite sure you could suit it to your purposes 😉

      • Michael O'Hagan permalink
        April 7, 2012 9:33 pm

        I don’t think you are understanding what I’m saying, I would like to be able to choose several different waveshapes with this oscillator and then morph/mutate between waves while I’m playing.

        take a look at Oki Computer in the factory library, or the oki computer engine in Aries. you can choose 16 different waves and the morph wave shapes while playing.

        could this oscillator be made to save several different wave shapes in 1 setting and then change or morph through the wave shapes with a knob control while playing?

      • April 7, 2012 11:01 pm

        That’s certainly a direction I would like to take this in, but it would require an overhaul.

  3. meter maid permalink
    April 8, 2012 8:10 pm

    When used as effect roughly only the middle are seems to be doing anything (set to 128 length here)

    If you can make this a proper effect it would certainly be worth waiting for. This is one of those niche effects that aren’t really available in the commercial VST world too much. The most interesting one out there besides this is the Waveshaper for max for live (previously pluggo)

    • April 9, 2012 8:22 am

      Well, of course. That’s because the values on the left edge respond to incoming inputs near -1 and the edges on the right respond to inputs near 1. If your audio in only goes from -.75 to .75 (for example) the edge values will never be used for anything.

      Of course, most of the activity takes place in the center, so that’s where you get the most response.

      I’m not sure what the picture is of?

      • meter maid permalink
        April 9, 2012 5:23 pm

        The picture just shows the area which is effected by drawing, drawing on the left or the right of that area changes nothing. Making the volume quieter just seems to squeeze the active area more in the middle. I tried a bunch of different types of signals.

        Changing the min/max X range on the XY and Mouse Over so that only the useful area is visible once again seems to squeeze the active area more into the middle.

        The reaktor waveshaper I linked to before demonstrates how signal the signal gets effected with a nice animation and it works from the left to the right all the way.

      • April 9, 2012 7:08 pm

        I just tested running a signal between -1 and 1 at length of 128 and it played back a waveform that represented the entire drawn table. I’m not sure what’s happening in your tests but I don’t see how it would respond differently to an incoming audio signal than it would to a ramp osc, they are all just numbers after all.

  4. meter maid permalink
    December 17, 2012 4:11 pm

    when i’m drawing a waveshape it makes a click/pop when i pass the middle spot, can you think of a fix?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: