Highly Customizable Distortion with the Sample Scanner Unit


I’ve been able to successfully make wavetables for the ER-301 using:

  • Excel (or google sheets?) and Audacity
  • Javascript (nodejs and an audio library I found)

I could prob do some kind of tutorial on one of these methods if there’s interest (and after re-learning it myself :wink:). I was just wondering if anyone had found a better/slicker/faster way.


I have done the same using Python, there’s a pretty simple .wav library. I currently have a simple script I customize for each different function but I have been wanting to make it a more general-purpose tool that can use anything in the “math” package.

I have been using a distortion mapper based on the tanh() function (pretty common for cheap distortion in the box) and it sounds pretty nice.

1 Like

Here is the program I used to generate the tanh() mapping, and the sample, if anybody else wants to use them.

import wave
import struct
from math import tanh


def write_tanhwave(resolution=1000):
    file = wave.open('tanh-48k.wav', 'w')
    data = []

    num_frames = resolution
    half_frames = num_frames / 2.0
    half_domain = 5.0
    sample_scale = 65535 / 4.0 

    for frame in range(num_frames):
        val = tanh(half_domain * (frame - half_frames)/half_frames)
            struct.pack('h', int(val*sample_scale)))
    file.setparams((1, 2, SAMPLERATE, 0, 'NONE', 'not compressed'))

if __name__ == '__main__':



This is hugely useful and will allow me to do a bunch of stuff I have been wanting to do with sample scanners for a while. I’m going to try to modify it to make some unique quantizer functions.

Hey @bgribble since I am a bit of a noob when it comes to (python) programming, could you maybe explain how to run the code? Would love to do a custom distortion/custom curves in general on the 301…

Sure! The snippet of code I wrote doesn’t use anything beyond the Python standard library so it’s pretty easy to get running.

  • Make sure you have Python 3.x installed. Just typing “python” into a terminal should enter you into an interactive interpreter which will print the version. If it prints “Python 2.[something]” as the version, try typing “python3”; they sometimes are both installed.
  • If you don’t have python v3.x installed, you can download it for free at python.org
  • Save the code snippet I included above into a text file, let’s call it “mkwave.py”
  • Run the file by typing “python mkwave.py” (or “python3 mkwave.py” if that is how python3 is installed)
  • It will create a new file called “tanh-48k.wav” which is the sample to use in your sample scanner.

To change the function that you are making a wave file for, just change the "val = " line. Python’s “math” library has all the trig functions you would care to use, see Numeric and Mathematical Modules — Python 3.11.1 documentation … you can write your own helper function to combine logic, math, and/or randomness to substitute in there if you want more than just a plain math function.

The scaling is set up so that the function is called with X values in 1000 evenly-spaced steps over the range from -5 to 5, with the Y values scaled so that a function with a range from -1 to 1 like tanh will take up half of the range of the wave file (so a signal at +/- 1 will be at -6dBFS peak amplitude)


im trying to get python working and its giving me a lot of trouble - I installed anaconda once and it won’t upgrade my Python version - anyways if you right click on the file you get the tahn wav - is it the same as if you ran it from python in this instance?

Should be! If the tanh file is created it means the script ran.

1 Like


@bgribble - you mentioned a keyword :slight_smile: I’ve eyed the Instruo Tanh module; how difficult would it be to do the same within the 301? Is it already possible with an existing unit?

I actually just recently got the instruo tanh module so I can speak to it a bit. There are a few particularities about the way the sample scanner works that makes it slightly wonky.

One of those aspects of the sample scanner is how it handles voltages that are out of the bounds of the sample. For instance if you send +5v (or maybe 10) to the input the sample scanner will return the value at the end of the sample. If you increase the input past this threshold the sample scanner will return the value at the beginning of the sample, essentially wrapping back around. When using samples that have a large discontinuity at the start and end(like a tanh) when the scanner wraps around you will have a rapid drop from +5v to -5v, making pulse wave type sounds.

You can get around this by making a tanh file that has longer flat sections(essentially distorting your signal more at lower voltages) and by keeping the input voltage below that wrapping threshold.

As for the instruo tanh I have been wanting a distortion module for a long time, it was pretty cheap, and has three channels. I find the sample scanner to be slightly fiddly for clipping distortion, because of the wrapping behavior mentioned, but that same behavior makes it great as a wave folder. Just load a sine wave or triangle wave and toss a gain stage before it. Increase the gain past 1 for wavefolding.

1 Like

Thanks for the explanation! That clarified things up a lot. And you are right, the Tanh is not prohibitively expensive, maybe I should look into that one, too…

Is it possible to put a limited on the signal you’re running into the sample scanner so it never goes beyond the bounds of the sample?

You can do that or put an upper limit on your gain control, but it limits the amount of distortion you can apply. This is why you use a sample whose ends are extended, to have more range to clip into. I haven’t done this extensively, so I’m not sure how crunchy you can get a signal.

It would be cool to have a custom unit with 3 or 4 samples useful to simulate some kind of distortion, from diodes like those that are on elektron analog heat (clean boost, mid drive, round fuzz).
it would also be interesting to simulate the stape saturation…
I would try but I am unable to re-create single cycle samples with that precision.
has anyone worked on this and would like to share with other users? :grin:

waveedit by synthesis technology is a good way to easily create your single cycle waveforms.


You can actually use the single cycle unit like a sample scanner with the ability to fade between waveforms. Just set the speed to 0, reset the oscillator so it is at zero and use the phase input as the input that the sample scanner would have. Nice morphing waveshaping.


some discussion about it here:

1 Like

@hyena that is awesome! Just playing with this and noticing that just a tad of f0 at sub audio rate gives a nice vibrato!


yep! there’s a lot to explore there :slight_smile: