Stuck with a SynthEdit project?

Tag: Oscillator

The ED Shape Oscillator.

About the Shape Oscillator.

The oscillator is based on a Look-up-table (LUT) oscillator whose waveform can be drawn, edited and supplied in form of a standard ED Shape. ED shapes are defined, stored and transmitted in the BLOB format.
The Shape Oscillator supports a Sync pulse in Boolean form to reset the Oscillator phase as well as allowing Phase Modulation of adjustable amount and feedback. The total Phase Modulation amount is the sum of the Phase plug voltage scaled by the Phase Amount value and then summed to the oscillator signed output scaled by the overall Phase Feedback value.
The internal waveform LUT is computed by interpolating through the x,y Shape nodes according to the selected Interpolation Type.
Shapes can be modulated by the various means currently provided by the ED Shape Modules pack (e.g.. by usage of a Shape Morhper or Shape Node Modulator etc.) if implemented correctly without any clicks or artifacts.
When using custom drawn waveforms, these are frequently vertically unbalanced, and for this reason an optional DC filter is provided, which will automatically remove any DC bias from the results of all LUTs.
Optional oversampling (up to 32x) for aliasing reduction is also provided.

The ED Shape Oscillator plug layou
t

Important notes about using the Shape Osc.

NOTE: Junction Points.
When drawing waveforms, especially when using the curve interpolations, the user is responsible for setting the junction points properly, in order to preserve waveform continuity (unless you want discontinuity of course). It is also a good idea to set the first and last nodes to zero in the Shape Editor and disable their editing.

NOTE: Level Fluctuations:
Curve interpolation types may cause audio levels to exceed the clipping level (+/- 10V). Internally, the LUTs are therefore always clipped at -10 and +10 V.

NOTE: About Anti-Aliasing.
Any waveform containing sharp edges (sawtooth or pulse for example) will produce aliasing at higher pitches, which can be detected in the Analyzer and heard as a nasty inharmonic (harsh and discordant) component.
The internal oversampler can be set up to a factor of 32x.
So as not to sacrifice CPU efficiency, a simple averaging filter is used for the decimation stage. It can’t offer the accuracy of SynthEdit oversampling or of an actual long sinc filter, but it is effective enough at reducing any aliasing products to a level below the audible threshold and at a fraction of the CPU cost (at least 10x less CPU load).
Keep in mind that anti-aliasing measures may well not be required, unless your shapes (or the result of shape modulation) contain sharp edges.
In the event that you would prefer to use SynthEdit oversampling, please disable the internal oversampler so as not to waste CPU unnecessarily.

NOTE: About shape modulation.
To modulate the input shape with the provided Shape Modifier modules, it is mandatory to use the SE stock Volts 2 Float converter to drive the control float pins of the modifiers with an audio signal (for example from an LFO, ADSR or MIDI control), and to set the conversion rate to its maximum value (currently 60 Hz).
Connecting a Voltage line to a Floating Point plug directly will result in a much lower conversion rate, with very disappointing results.
Actually nothing prevents shape modulation up to (theoretically) the audio rate by using a custom volts->float conversion module or other unconventional means, however despite this transmitting blobs at sample rate or close to it is highly inefficient and is strongly discouraged.
Important: The module will not parse and render any shape to an LUT more than 60 times per second anyway, so there is no real point in trying to do this!

Shape Oscillator Plug descriptions and usage.

.Off/On (Boolean):- Turns the oscillator On or Off.
Please note that, when an oscillator is used in polyphonic mode, there is usually no reason to turn it off, since will be disabled automatically by SynthEdit when no notes are playing.
.Shape (BLOB):- Input for defining the output waveform’s shape in a standard BLOB format (Maximum range -5 to +5 Volts).
Values larger than +/- 5V are internally still allowed despite this the curve may be displayed clipped depending on your Shape Editor settings. The curve will always be clipped at -/+ 10 V internally by the module though.
Important note: Two nodes cannot have the same x co-ordinates (even if their y co-ordinates are different). There must be a very small difference between them.
.Shape ITP (List):- Sets how the shape nodes will be interpolated. The options are; Linear, Curve1, Curve2.
.DC Filter (Properties):- turns off or on the built-in DC filter to prevent DC offsets from appearing on the oscillator output.
.Oversampling (Properties) :- selects the internal oversampling factor
.Pitch Units (Properties):- Selects whether voltage to pitch is to be converted as 1 Volt per Octave or 1 Volt per Hz (Note: not 1 Volt per kHz)
.Pitch (Voltage):- Oscillator frequency (LUTs for second), in Hz or Octaves as specified by the Pitch Units set in properties. The allowed range is from 0 Hz or 0 Octaves, (which still corresponds to a non-zero frequency), up to half Nyquist frequency (or 10 Octaves = 14080 Hz) depending on the Pitch Unit setting.
.Sync (Boolean) :- A true pulse resets the oscillator phase to zero (To the start point of the LUT, unless an additional Phase modulation offset is applied.
.Phase (Voltage):- (Range -10 V to +10V) oscillator phase shift, can be used for phase modulation. A voltage of +5V represents a phase phase shift of half the wave period forward (+PI) while -5V half period backwards (-PI)
.Phase Range (Voltage):- (Range 0 to +10V) Limits the amount of phase modulation applied by the Phase pin
.Phase Feedback (Voltage):- (Range -10V to +10+) Sets the amount of signed oscillator output sent back and summed to the Phase input to achieve a DX7 – like FM feedback . -10V is phase inverted and +10V is in phase.

Using the Shape BLOB string.

Shapes:
Shapes support from two to 100 nodes. A shape can never have less than two nodes. No such thing exists as an “empty” shape: a “void” or default shape is a shape with just the first and the last node set to zero.
Node Values:
Node values internally are represented in normalized float units: from 0 to and including one horizontally, from -1 to and including 1 vertically. However, for compatibility reasons, node positions are still displayed and accepted in Volts by all ED Shape modules: from -5 to 5 Volts horizontally, from -5 to 5 Volts vertically.
First and last nodes:
The first and the last node are fixed at position -5 and +5 and cannot be moved horizontally.
String Format:
The “Legacy” string format consists of nodes between parentheses in Volt units, e.g. (-5,0)(1,-1)(5,1).
Nodes and Node positions:
The first and the last nodes must always be present, and their horizontal position must always be -5 and 5 respectively, and they must all be sequential. Vertical positions must be in -5 to 5 range. No other characters or spaces shall be present. Invalid strings will be rejected.
(This format was inherited from the stock SynthEdit WaveShaper 3)
Shape information storage:
Shape information is now stored and transmitted using a new efficient binary BLOB format. This means that every Shape Editor module must therefore be linked to the destination user module(s) through a Patch MemoryBlob module
Adding and removing nodes:
Shape nodes can be added or removed by a double-click. A double click anywhere in the edit field will create a new node at the corresponding mouse position. Double-clicking on a selected node will delete it. The first and last node cannot be deleted: a double click on them will snap them to the specified baseline for convenience.
Moving Nodes:
Shape nodes can be activated with a mouse click and dragged around within their allowed limits: between the neighboring nodes, and vertically within -5 and 5 or within a smaller range, in case custom MinY/MaxY values are specified

Understanding how the shape is defined:
The easiest way to understand the Shape BLOB format is to look at the ED Shape Editor 5 in operation. It works as a grid of (x-y) co-ordinate values (referred to as “nodes”, each one of which is shown as a circle), so looking at the Shape Editor grid below, this shape would be described as:
(-5,0)(-4,5)(0,0)(4,-5)(5,0)
Breaking this down our first node has the co-ordinates x=-5 and y=0
The second node has x=-4 and y=5
The third node has x=0 and y=0
The fourth node has x=4 and y=-5
The fifth node has x=5 and y=0

Note about x and y: As in map reading the horizontal (X) position is specified first, followed by the vertical (Y) position. The x and y co-ordinates must always be separated by a comma.

The waveshape resulting from (-5,0)(-4,5)(0,0)(4,-5)(5,0)

The waveshape resulting from (-5,0)(-4,5)(0,0)(4,-5)(5,0)

So if you wanted to define a square wave the shape string would be as follows;
(-5,0)(-4.999,5)(-0.009,5)(0,0)(0.009,-5)(4.999,-5)(5,0)
Why (-4.99,5) for the second node? You cannot specify the same x co-ordinates for two nodes, there must be a very small difference between the two, likewise for (-0.009,5) and so on. So OK it’s not a perfect square wave, but we can get extremely close to this.

The waveshape resulting from (-5,0)(-4.999,5)(-0.009,5)(0,0)(0.009,-5)(4.999,-5)(5,0)

The waveshape resulting from (-5,0)(-4.999,5)(-0.009,5)(0,0)(0.009,-5)(4.999,-5)(5,0)

Getting the Shape Editor and Oscillator to communicate.

Because the Oscillator is DSP and the Shape Editor is a GUI module we need a PatchMemory Blob to link them up. If you want you can even display the Node co-ordinates by including an ED GUI Shape BLOB-> String converter (we need this to convert the shape definition from Binary data to ordinary an ordinary numeric string) feeding a Text Entry4 module to display the information.

Using the Shape Oscillator with a Shape Editor.

The ED Shape Editor5.

I used the compact version of the Shape Editor above, as this doesn’t have the colour options for the graphic editor window to make things a little less confusing.
The full version has quite a few plugs and options so that’s on it’s own separate post to cover all the options: go to the Shape Editor post.

The Naïve Oscillator in SynthEdit.

So what is this Naïve Oscillator? I’m guessing you don’t know the term
(I didn’t know what it was for some time). Well it’s all to do with Aliasing, and the frequency limitations that apply to digital audio.
A “normal” oscillator in Synthedit is what is called “bandlimited” to prevent it producing frequencies above the Nyquist limit. The Naïve oscillator is not bandlimited and thus will produce aliasing (and lots of it!).
Note: The naive oscillator is also not very well optimised, so it’s a bit higher on CPU usage than the normal Oscillator module.

The difference between the Naive and normal stock oscillators.

Using the stock Frequency Analyser gives a good demonstration of the difference between the two oscillators.
The top oscillator is bandlimited, so has anti-aliasing built in.
Both Oscillators are generating a sawtooth at just over 1kHz. There is a noticeable amount of distortion and extra non-harmonically related frequencies generated at this frequency.
Notice all the extra frequencies below the 1kHz fundamental coming out of the Naïve Oscillator. What is happening here is that lots of high frequencies are being created by the sawtooth, but due to the limitations of the audio in Synthedit these higher frequencies are actually being folded back on themselves above the maximum audio frequency and appearing as spurious lower frequencies which are not harmonically related to the fundamental frequency.
You can see where the Bandlimiting starts to take affect; the level of the harmonics starts to dip, then suddenly cuts off, compare this with the Naïve Oscillator where the harmonics just keep on going…

Increase the Oscillator frequency to 8kHz and things will get even worse:

This diagram makes things a little clearer, the red dashed line shows the harmonics that have been “folded back” into lower frequencies, being above the maximum our digital audio can handle they aren’t ignored, but instead turned into an ugly sounding inharmonic mess.

Aliasing  and "folding back"

If you want to find out more try these articles:
https://www.metafunction.co.uk/post/all-about-digital-oscillators-part-1-aliasing-foldover
https://www.metafunction.co.uk/post/all-about-digital-oscillators-part-2-blits-bleps

Phase Distortion synthesis in SynthEdit.

Phase Distortion Synthesis was pioneered by Casio in the 1980’s and is based on the idea of distorting the playback phase of a sine wave.

Phase distortion synthesizers like the Casio CZ-1000 are characterized by a very clean sound, similar in some cases to the Yamaha DX-7. The Casio’s 8-stage envelopes for Pitch, Wave shape, and Amplitude were superior to most synthesizers at the time. The main drawback of the Casio was a lack of velocity sensitive keys.
Of course with SynthEdit, you can use the Velocity output of the MIDI to CV module to improve the playability of the Casio sound. Vince Clark (of Erasure) used a rack full of Casio-CZ’s to achieve a “fat” sound. Now you can too!

How the Casio PD synthesizers worked.

Casio’s method of Phase Distortion used oscillators which generated modulator and carrier waveforms, which were synchronized to each other.
The modulators were various wave-shapes that could ‘distort’ the carrier’s sine wave into other shapes, to a degree derived from the Digitally Controlled Wave (DCW) envelope. In doing so, many harmonics were created in the output.
As the modulators were rich in harmonic content, they could create spectra more linearly, i.e. like traditional subtractive spectra, rather than emulating Yamaha’s phase modulation (PM/FM) synthesis.
Yamaha style PM does not require oscillator sync but is usually limited to sine waves, which meant that the output audio spectrum bears the non-linear structure of Bessel functions.
PD is a different type of PM – whose different modulation system caused significant difference in operation and sound between PD and PM. Thus the two methods are significantly different.
The phase transforms were assembled from piecewise linear functions under binary logic control and show the characteristic sharp knees (and for some transforms, even sudden jumps) as they move from minimum to maximum, where the frequency counter’s accumulator wraps around and starts over. The sharp knees are smoothed by the roundness of the modulated sine wave and not too noticeable in the resulting audio signal.

Recreating Phase Distortion synthesis with SynthEdit.

SynthEdit has a Phase Distortion Oscillator module that can be used to recreate that classic sound.
The Modulation Depth input controls the amount of distortion, with Zero Volts giving a pure sine wave and 10 Volts giving a fully distorted wave.
The example below shows the effect of progressively increasing the amount of phase distortion when Wave 1 and Wave 2 are both sine waves. Wave 1 is the main (carrier) oscillator and Wave 2 is the modulating oscillator for the Phase distortion.

Phase distortion waveshapes

There are 8 different wave-shapes to choose from, and you can select different combinations of the two waves-shapes.
The Phase Distortion Oscillator module is used slightly differently from the standard voltage controlled oscillator.

Phase distortion oscillator

The wave-shapes available are: (with the addition of “none” for Wave 2)

List of waveshapes
Typical audio outputs from the Phase Distortion Oscillator


The diagram below shows a typical Subtractive Synthesiser voice containing an oscillator, VCF and VCA sections. The Filter and Amplifier sections are each modulated with a envelope generator (ADSR) , one to control the Volume, and one to control the filter cut-off frequency.

Analogue VCF cutoff sweep diagram

Here is how you can achieve a similar result using the Phase Distortion Oscillator module, with one ADSR modulating the Phase Distortion level, and the second the Audio output level.

Achieving an imitation of a VCF sweep in a PD synthesizer

There is (usually) no VCF section, instead the ADSR that would have modulated a filter is connected to the Phase Distortion Oscillator’s Modulation Depth input plug. This gives a sound very somewhat similar to traditional subtractive synthesis, but without the need for a filter. Of course if you want to add a filter into the mix there’s nothing stopping you (Hybrid Synthesis).

A simple Phase Distortion Synth constructed in SynthEdit.

The basic synthesizer is quite a simple arrangement of a PD Oscillator, two ADSR modules and a VCA, but it can be made as complex as you like with more oscillators, (plus filters if you wish), and a noise source. As with most structures, you can add to them and make them as complex as your imagination and ingenuity will permit.

Basic Phase Distortion Synthesizer

SynthEdit Oscillators.

The oscillator is arguably (OK we could say the keyboard, but let’s not get picky) the starting point for sound generation in a Synthesizer, after all it’s where almost all of the sounds are created.
The classic analogue Oscillator or VCO in a synthesizer had a choice of five basic waveforms: Sine Wave, Triangle wave, Sawtooth, Ramp (which is the reverse of a sawtooth), and Pulse.

Oscillator waveshapes and noise.

Saw and pulse waves’ spectral content is very rich. For example, a saw wave with a base frequency of 500 Hz comprises harmonics spaced at equal intervals, with exponentially decaying amplitude as shown below.

Sawtooth harmonic spectrum

However, many physical instruments harmonics are of lower amplitude at high frequencies, or may have resonances at particular frequencies. We can achieve this by filtering out, or boosting different frequencies with various types of filter.

The waveform affects the harmonics.
The exact relation between waveform and harmonic content is a very complex mathematical subject (Fourier analysis).
Sawtooth wave:
A sawtooth waveform contains all harmonics in inverse proportion to their number – with all these mathematical relationships you know something ‘natural’ is going on. So the 2nd harmonic is half the amplitude of the fundamental, the 5th harmonic is a fifth the amplitude and so on. Being so rich in harmonics, sawtooth waves are commonly used for brass, strings and some woodwind sounds.


Square or pulse wave:
The square wave contains only odd-numbered harmonics in the same proportion as in sawtooth waves. It produces a ‘hollow’ sound and is typically used for clarinets and reed instruments.


Triangle wave:
Triangle waves contain only odd harmonics, as with square waves, but at much lower amplitudes. In fact – yes, it’s more maths – the relationship is the square of the harmonic number. The 3rd harmonic has an amplitude one ninth (3×3) of the fundamental, the 5th has an amplitude of 1/25th (5×5) and so on. Although triangle waves do contain harmonics, they are not very dominant and triangle waves sound very sine-like. Some synthesisers dispense with a sine wave in favour of a triangle waveform.

Sine wave Harmonics:
A pure sine wave produces just the fundamental frequency, with no (or as close to as possible) Harmonics.
Complex Wave: Usually referred to as Noise, this is an almost random variation in audio voltage with no fixed frequency content. Useful for creating percussion sounds, and adding breath sounds when synthesising flutes or similar instruments.

We don’t need to get into the technicalities of how the shapes are created, just how to use, and control them.

Basic VCO module

The Pitch plug: This controls the frequency or “Pitch” of the oscillator, the default voltage to frequency response is 1 octave per volt, the same as an analogue synthesizer.
We connect this to a Detuner Module so that the frequency can be set by octave, semitone, and fine tuned as an offset against any other oscillators if required.
The pitch of SynthEdit’s Oscillator modules are calibrated in Volts per Octave.
This means that signal of 5 Volts on the pitch plug sets the oscillator frequency to 440 Hertz or Middle A, (the note in the centre of a piano keyboard). Increasing the input by 1 Volt will cause the pitch to rise one octave- so the oscillator frequency doubles to 880 Hz .

How pitch is related to voltage

Simplified: volts=1.442695041* Log(0.07272727273Hz)
To convert Volts to Frequency; Frequency = 440*2^(Volts-5)

To convert MIDI note number to Volts;
There are 128 midi notes. There are 12 semitones on an Octave.  5.0 Volts is middle-A (MIDI note 69) 
Volts = 5.0+(MIDI note number-69)/12


The Pulse Width Plug: This controls the on and off times of the Pulse wave form- (see the diagram below) which in turn controls the sound of the tone due to the change in the number of harmonics in the waveform. Note: This control only varies the output when the pulse waveform is selected.

Effect of varying the pulse width

The waveform plug: Connects to a drop down list or similar selector control, so you can select the required waveform.
Sync: This plug allows you to synchronize the oscillator against another oscillator, which can produce some interesting (and outright ugly in some cases) harmonic changes dependent on the frequencies of the two Oscillators.
Phase Mod plug: allows you to phase shift the oscillator waveform by applying a voltage within the range of -5 Volts to +5Volts. By connecting this to the audio output of another Oscillator this allows you to create FM type effects from the two Oscillators.
PM Depth plug: This allows you to control the amount of the signal applied to The Phase Modulation plug that affects the Oscillator.

Smooth Peaks, or The Gibbs Effect.
In the oscillator’s Properties window you will see an advanced
option called Smooth Peaks (Gibbs Effect). Now compare the two oscillators’
waveform in a scope, and you will discover they are different. The top display is with Smooth Peaks turned off.
We can see a sharp peak with a ripple effect preceding the peak.
If we enable Smooth Peaks then the waveform will more closely resemble a saw wave. Disable smooth peaks, and a big ripple and spike appear at the edge.

Gibbs effect or Peak Smoothing


Why is this? Without going into very complex maths and programming,
the waveform is band-limited, meaning that its frequencies
range no further than from 0 Hz to half the sampling rate.
The Fourier series tells us summing an infinite number of sine waves
creates a band-limited saw wave. Summing a limited number of sine
waves creates what programmers and mathematicians call the Gibbs effect; we call it ripples at the edges.
The same happens to other waveforms with sharp
edges—ramp and pulse come to mind. So, this rippling waveform is a
fixture in the digital domain. Smooth Peaks curtails the effect, but also
noticeably diminishes high frequency content above 4 kHz.

Sync X-Fade (Anti Alias):-
Reduces Aliasing noise when Syncing Oscillators at Audio rates. This can be disabled to provide precise note-on phase sync (useful for phase modulation patches) at the expense of introducing aliasing artefacts into the audio output.

Oscillator Sync:

When we Synchronise two oscillators in Synthedit, we ensure that the both start in phase (at the 0 volts part of the cycle) here we have two oscillators which are running at different frequencies, but are Synchronised.

Oscillator synchronized

With the Sync connection removed they are no longer starting at the 0 volts/0 degrees point as they did when synchronised.

Oscillators unsynchronized

When the first oscillator in the chain is higher in pitch than the following oscillator, this sync trick causes it to sound as if the following oscillator is tracking the leading oscillator’s pitch: any changes to the leading oscillator’s pitch will also cause a change in the following oscillator’s pitch. This works because you’re forcing the follower to reset in sync with the natural resets on the leading oscillator, locking them to the same frequency.
This crude form of pitch tracking can be used in a pinch to cause multiple oscillators to track together—but it’s a bit crude and has a noticeable side effect. The higher the frequency of the first oscillator, the more truncated the following oscillator’s shape will become—ultimately changing both its timbre and its amplitude. As such, this method of oscillator synchronization isn’t typically used for pitch tracking—after all, in most situations, you could just use the same keyboard, sequencer, or pitch control voltage to control both oscillators simultaneously anyway. So … what does this form of oscillator sync achieve?
Well it does produce some harmonically richer sounds by syncing even a simple sine wave, and once we get to a sawtooth the harmonics can become really wild especially when the first oscillator is lower in frequency than the second.

Oscillator 1 has a lower frequency than Oscillator 2

Oscillator 1 has a higher frequency than Oscillator 2 (Note that as Oscillator 1 rises in frequency the amplitude of Oscillator 2 will decrease)


Oscillator sync becomes very interesting once you start affecting the follower’s frequency independently from the leader. By modulating the follower’s frequency (with LFOs, envelopes, random voltages, etc.), you can achieve a crazy range of sounds some usable others- well a noise. Many of these sounds can be heard in synth lines from the 1980s (Cars, Keith Emerson to name but a few).
This is something that it’s better to try out for yourself than to hear and see the results than for me to attempt to describe