# How to make a Shepard tone, shape frequency amplitude response in Reaktor

Here's a video demonstrating combining a Pitch LFO and an Amplitude LFO in Reaktor's Form ensemble to create "infinitely upward" glissando in Reaktor.

I'd like to be able to play a scale or melodic passage of Shepard tones that does this and am envisioning that one way of doing it is to run the Osc output through a filter or EQ which would attenuate frequencies above and below a central bandwidth according to a specific or specified curve.

I have tried using a Peak EQ as well as a couple of the Shaper BP Modules, but am pretty lost in the woods.

Am I even on the right track? Frequently, when I'm playing with the control knobs on the EQ or Shaper, the Synth makes a click sound and needs to be restarted to even generate a tone again.

Will include the panel here, which may give some sense of the value ranges provided by the auto-generated controls:

UPDATE:

Realized last night that my initial approach is completely wrong. EQ or Filtering affects the entire frequency spectrum and will largely just remove upper partials. We need to insert some logic that affects the Amplitude input of the Oscillator.

I imagine that this will be some math between the Pitch input and the Constant (1) seen below.

UPDATE 2

My idea now is to develop some kind of algorithm by which all pitches above and below a specified octave's midpoint–the tritone–(for example F#-66 for the C-60 octave) are exponentially (or perhaps logarithmically) attenuated. My first step along this line of thinking is simply to hard-code a different Amplitude level for all pitches below 66:

So what I want is that note `66` (for example) will be Amplitude `1`, `65` will be `0.9` (maybe), `64` will be `0.8`, etc... and the same where `67`, `68` will be `0.9`, `0.8` and so on. But I imagine I'd ultimately like to be able to control that Amplitude curve with a knob or two, as desired curves might change based on the timbre of the sound.

I'm also wondering if it would make sense to autogenerate the High and Low octaves and only need to play the Middle octave of the scale (or melodic equivalent.)

UPDATE 3

It's quite possibly that I'm misunderstanding how "Shepard Tones" are supposed to work. I am still working on implementing a version of @YourUncleBob's answer.

It seems that "his" approach is to send the sound through a Filter that creates the octave-equivalency-based illusion that support the "infinitely ascending or descending" illusion.

What I had been thinking to do, again, is to create an amplitude attenuation curve which attenuates the volume of each "note" (keyboard input) further as it gets further away from a central tone.

Then as long as the "melody" is played in multiple octaves in parallel, the illusion should work.

I am making some progress. What I have done so far is:

• Subtract pitch input from Central Tone
• Run the Remainder through a `Rectifier` (math) so that negative values are positive.
• Compare the Rectified Remainder to 0 and if it's 0, send a `1` to the Amplitude, otherwise, make a fraction out of it since `Amplitude` is looking for a number from `0` to `1`. So larger numbers become smaller amounts (ie. `2` => `1/2`, `3` => `1/3`, etc)
• I'm hacking the curve a bit by multiplying the divisor (pitch minus central tone remainder) by `2` so that the fractions are smaller, and also by using `0.8` instead of `1` for the Central Tone.

I'm displaying some of the numbers:

Then I go through this elaborate process of creating the content in the DAW:

It's kind of cool with a lot to still work out:

1. Notes are "clicking" intermittently at the onset
2. I'd like to be able to have a logarithmic attenuation curve where it attenuates faster the further it is from the central pitch
3. The higher pitches need to attenuate more aggressively than the low ones
4. Do I have to actually `play` or `program` all of these parallel octaves? Seem like the instrument should be able to generate the full spectrum by default.

In the meantime the process is being enjoyable.

• If you want constantly shifting filtering, you could look into Comb Filters. Here's how they sound: youtu.be/w0NQwQuSMFk?t=193 and how to build them in Reaktor: adsrsounds.com/reaktor-tutorials/… Otherwise you'll have to build a filterbank with several Peak EQ's and have their frequency and volume modulated by LFO's or envelopes as described in the video you linked. – Your Uncle Bob Apr 2 '19 at 4:21
• Thanks. I just updated the OP, thinking that it's actually probably the Amplitude going into the Osc that needs to be attenuated based on Pitch input. I will totally check the Comb filters, but am I wrong in my new thinking? – MikeiLL Apr 2 '19 at 13:47
• Do you want to play a melody (or any other sound or recording) and then run that through a Shepard-like filter, or do you want to play an ever-rising scale? I'm getting useful results with a Shepard-like bank of Peak EQ's, but I'm not sure what you're after. – Your Uncle Bob Apr 2 '19 at 23:33
• @YourUncleBob I want to play an ever-rising "scale", hopefully will work with a small-interval melody. – MikeiLL Apr 3 '19 at 0:29

The most flexible way to have a parameter whose value is different depending on which note you play, is to use an event table. That way, you can set a specific value for every MIDI note (e.g. for volume or filter key follow, or to create alternative tunings). Here's a simple example:

By creating a one-dimensional table of length 128, which holds values from 0 to 1, you can set the volume of every key separately. If you make the table visible in the panel (in the "view" panel), and set it to drawing mode (strl-click/right-click on the table in the panel), you can use the mouse to draw in values.

By adding an Event Voice Combiner, you can get the last note played to set the write position, and also use the Value slider to set its value. Once all values have been set, you can make the table invisible again. Its values can be saved and loaded automatically with the instrument.

You can of course use a smaller table, and e.g. have a value per octave, or interpolate between adjacent values.

If you don't need the detail of the solution with tables, you can just rescale the MIDI note input to the range 0 ~ 1 and then send it through a Control Shaper and set the output values for input 0, 0.25, 0.5, 0.75 and 1 to create the desired curve.

You can also use the Control Shaper for a solution with a variable center point and width. The center point knob sets the note number (0 ~ 127) for which the output value will be 1, and the width knob sets the distance (1 ~ 127) from the center note to the note where the output value will be 0. The output value will be linearly interpolated between value 1 and 0 for notes within the range, and be 0 for notes ouside the range.

You can change the interpolation of the output values from linear to a curve with a wider or narrower peak around the center point, e.g. by using the square of the values, or its inverse (this works because the range is 0 ~ 1). The three options are sent to a Selector module (in linear interpolation mode) so that a knob with values 0 ~ 2 can select the desired curve.

• Using the Event Table method with the Stepsize set to `0.00001` (`1E-05`) allows for a pretty nice curve into silence. Something I'm confused by is that the output values from the Event Table are between `0` and about `2.6`. I was expecting values between `0` and `1` since that's what the Value Range is set to. – MikeiLL Apr 19 '19 at 0:13
• @MikeiLL Had you entered values in the table already before you set the range to 0 ~ 1? Existing values are not clipped or scaled when changing the value range. Newly entered values are always clipped to the range. (At least they are in version 4) – Your Uncle Bob Apr 19 '19 at 0:24
• Not sure if I had, but I noticed that the upper range of table values was actually matching the number of Unison Voices, which was `4`. If I have Max Unison and Voice both set to `10` and the Value Range of the table set to `0.1` then I get a range from `0` to `1`. – MikeiLL Apr 19 '19 at 0:30
• @MikeiLL I'd never considered the effect of unison on table modules. They are a strange mix of monophonic (the data itself) and polyphonic (the reading and writing). If unison voices indeed add up the table values, that is very strange indeed; I can't imagine under what circumstances that would be logical. If four voices write a value 1 to the table, you'd expect the value to still be 1, not 4. – Your Uncle Bob Apr 19 '19 at 0:43

If you want to be able to play a melody while using Shepard Tones, the easiest way is probably to use a simple synth sound with a lot of harmonics, like an unfiltered sawtooth wave, and run it through a band-pass filter bank with constantly shifting frequencies.

Here's an instrument that uses a variable number of band-pass filters tuned an octave apart. The instrument's polyphony sets the number of filters. Each filter's frequency is slowly shifted upwards, and its output level follows a sine wave, so that the different filters fade in and out.

The ramp oscillator controls the filter frequency, and a sine wave based on its output controls the voice's volume. Set the oscillator's mode to standard, so that it jumps back from its maximum value to zero without any anti-aliasing (which would create glitches in the sine wave). In each voice a phase offset is added to the monophonic ramp oscillator output, and thus also to the sine wave, so that the filters are tuned octaves apart, and their volumes fade in and out in turn.

The panel controls have theses ranges:

• Rate knob: -127 to -0, in 127 steps
• Frequency: 0 to 127 in 127 steps
• Resonance: 0.872 to 0.999 in 127 steps of 0.001
• Depth: 24 to 87.5 in 127 steps of 0.5
• Level: -24 to 39.5 in 127 steps of 0.5
• Voices lamp: 1 to 128 in 127 steps, continuous mode, value visible, image not visible
• 11kHz lamp: 127 to 1000, continuous mode disabled

The settings in the image above give a good idea of what it can do. It's similar to a vowel filter or phaser, but with a continuous upward motion. The frequency knob sets the lowest frequency of the filter sweeps, the number of filters (i.e. the polyphony) decides how high the filter sweeps go, adding one octave per voice.

I found that the frequency of the PeakEQ and band pass filters in Reaktor 4 is limited to note number 127, which is around 11kHz. As you increase the polyphony or the frequency knob, the 11kHz lamp warns you if the upper range of the filter sweeps reaches 11kHz. You can use higher settings, but the sound may have a permanent boost around 11kHz.

This is the basic synth I use as a sound source. It's a separate instrument, and you can set the polyphony independently. You can of course run the output of any Reaktor instrument through the Shepard Filter. Low chords played with bright synth sounds will work best.

• So that is an `in` port going into the `Peak EQ` and an `out` port coming out of the `Mixer`, right? Should the `Shepard Filter` be monophonic? In Reaktor 5, the Sine Oscillator also has a `p` input for "logarithmic control of pitch". I currently have it set to a constant of `60`. Is the `-1` module an `inverter` (`-x` in R5)? What information is the `Voices` `lamp` displaying, how many voices are currently being generated? – MikeiLL Apr 4 '19 at 3:08
• Yes, it's an instrument by itself, with an audio input and output. The instrument is polyphonic (but some modules marked in orange, like the mixer, are monophonic); the number of voices sets the number of filters (displayed by the lamp). That's not a sine oscillator, but a mathematical sine function. -1 is indeed an inverter. – Your Uncle Bob Apr 4 '19 at 6:20
• Still wondering what the `Voices` lamp is supposed to display. Mine is just reading `127`. Am I understanding correctly that it will require a second instrument to feed an audio signal into the `input`? Will I need three or more octaves if I want to create a "Shepard Scale"? – MikeiLL Apr 5 '19 at 1:31
• The lamp should display the polyphony of the Shepard filter, i.e. the number of filters tuned octaves apart. I'm working on an improved version, with just one ramp oscillator, and some bug fixes. Yes, it requires audio input; any bright synth sound will do. – Your Uncle Bob Apr 5 '19 at 2:05
• The filter instrument doesn't listen to any keys. You set the polyphony to how many filters frequency bands you want,and then they're always on. The lamp is just a reminder of what polyphony the instrument is set to. Settings from 1 to 12 will give you different kinds of effects. More than 12 voices doesn't make much sense, because the filter sweeps would go to inaudibly high frequencies. (Btw, I updated my answer) – Your Uncle Bob Apr 5 '19 at 3:31