W
-oscillator wave type collectionHere's a list of wave types with rendered audio for the W
oscillator. Apart from the built-in types, there's also recipes for making various wave types using modulation techniques.
Each instance of W
can use any one wave type in the built-in set – available to listen to below, these waveforms are also described in the wave type table on the language page. This built-in set is meant to make the most useful static waveforms easy to reach for. Of course, further types of waves can be made by combining several W
instances, adding waves of different type, frequency, phase, polarity, etc. – or modulating them.
The WAV files for the types have been produced with an extra-high sample rate and downsampled; this makes particularly the saw
wave cleaner, but the difference with simpler rendering is otherwise difficult to hear.
Sine.
Wsin t3
Triangle. Mellow – upper harmonics decrease fast.
Wtri t3
Square root of sine. Medium-bright – upper harmonics decrease moderately fast.
Wsrs t3
Square. Bright – upper harmonics decrease slowly.
Wsqr t3
Evenangle. Mellow – upper harmonics decrease fast.
Wean t3
Catear. Medium-bright – upper harmonics decrease moderately fast.
Wcat t3
Eventooth. Bright – upper harmonics decrease slowly.
Weto t3
Parabola. Mellow – upper harmonics decrease fast.
Wpar t3
Mellowtooth. Medium-bright – upper harmonics decrease moderately fast.
Wmto t3
Sawtooth. Bright – upper harmonics decrease slowly.
Wsaw t3
Half-rectified sine. Mellow (louder harmonics) – upper harmonics decrease fast.
Whsi t3
Sine parabola. Mellow (quieter harmonics) – upper harmonics decrease fast.
Wspa t3
To go beyond the basic set of 12 wave types, using phase distortion synthesis options in combination with some type makes for new variations playing nice with FM and PM. This is recommended for using derivative wave types that can be used as flexibly as possible. Below are some examples.
PWM is easy to do using the Casio-style PD option p.x
. Using a Wsqr
oscillator, any duty cycle percentage can be entered right after using the shorthand syntax as well, e.g. Wsqr.x0.25
or Wsqr[x0.25]
for 25%.
The classic NES APU waveforms include 4 different pulse widths – 12.5% (1⁄8), 25% (1⁄4), 50% (1⁄2), 75% (3⁄4) – though 2 of them (25% and 75%) sound the same.
The following example plays the four variations in order, using an 80 Hz base frequency.
Wsqr f80 p.x1/8; p.x1/4; p.x1/2; p.x3/4
Dynamically varying values by adding modulators can be done in the usual ways. Generally, PWM can sound nice until the pulse width becomes too extreme, e.g. keeping it within a 5%–95% range (though others may suggest different lower and upper bounds).
Different underlying waveforms than a square wave are usually affected in a different-sounding way when the same distortion is done with them. After all, the result is that the width proportion of halves of each wave cycle change, for whatever wave type is selected. A sine sounds pure at 50%, less pure as values move away from that. (One wave type can be used as a softer square wave, Wsrs
.)
It also matters where you consider the 'center' of each wave cycle to be; this can be changed for the p.x
distortion using its p.x.p
phase offset option. For example, moving it by 1⁄4 cycle so the distortion treats the peak of a triangle wave as the beginning, then Wtri
makes a plain triangle at 50%, but morphs towards becoming a sawtooth as the duty cycle changes, as in the following example where a 1 Hz LFO moves the duty cycle in the range 5%–95%.
Wtri f80 p.x[W f1 a1/2*0.95].p1/4 t5
Simple variations on sines include the Yamaha OPL2 & OPL3 waveforms, used in those FM synth chips and a number of chiptunes. All of these waveforms except type 0 (just a sine), type 6 (a square wave), and type 7 (the "logarithmic sawtooth" a.k.a. "derived square" wave) can be produced using a sine wave and one or two PD options. There's several ways to get it done, but the PD scaling and clamping options for pulsar synthesis can produce them all.
These versions, unlike the AM versions further below, always preserve the base frequency, rather than it sometimes being doubled or halved.
Due to an unwanted interaction between aliasing reduction in the W
oscillator and some extreme phaseshaping, some of the below examples include mn
, which switches the oscillator to naive mode. This can always be done, but not doing it where done below may sound worse.
Sine. Waveform 0. Nothing to be done.
W t3
Half-sine. Waveform 1. Scaling PD variation. Zoom out 2x for the "on/off sine", zoom in 2x after to remove the negative half (the padding line remaining such).
W[c2 d2] mn t3
Hold PD variation (same result). Overwrite half the waveform from the end backwards with the end amplitude.
W[h-1/2] mn t3
Abs-sine. Waveform 2. Scaling PD variation. Zoom in 2x to remove the negative half.
W[d2] mn t3
Pulse-sine, a.k.a. pseudo-sawtooth. Waveform 3 (1⁄4 sine alternating with equal silence). Scaling PD variation. Zoom out 2x for the "on/off sine", zoom in 4x after (changing only the non-padding part).
W[c2 d4] t3
On/off sine – every other cycle only. Waveform 4. Scaling PD variation. Zoom out 2x.
W[c2] t3
Abs-sine – every other cycle only – a.k.a. camel sine. Waveform 5. Zoom out 2x, while doubling the frequency of the non-padding part; then zoom in 2x after to remove the negative half from both cycles.
W[c2.f2 d2] mn t3
The general theme is clear – three values can be modified to move between these wave type variations. Here they are again, 1 second each and reusing the same oscillator.
W p[c1.f1 d1] mn ; p[c2.f1 d2] ; p[c1.f1 d2] ; p[c2.f1 d4] ; p[c2.f1 d1] ; p[c2.f2 d2]
For example, the difference between half-sine and camel-sine is that the latter uses c2.f2
, so if you want 3 crests instead of 2, make it c2.f3
instead. And an analogous change to the waveform can be made by adjusting f
whenever c
is greater than 1, such as making a sine alternating between two cycles on, two cycles off, with c2.f2 d1
.
Using AM options allows combining waveforms using multiplication of amplitudes (with different shifting and scaling). Apart from more complex sounds and uses, some simple waveform recipes give familiar results.
Below examples use the long-form syntax for value range modulation. Where it says a0..1.r
the same thing could instead be written in the short way as a0.r1
. (In fact everything can be written equally well in either way here, as at most one endpoint has modulators of its own. The mental arithmetic is pretty easy too here, with the key amplitude values for modulators just -1, 0, and +1.)
Note that there's a weakness to using AM to create derivative wave types – they don't work with FM or PM unless you modulate every waveform combined through AM in the same way.
Simple variations on sines include the Yamaha OPL2 & OPL3 waveforms, used in those FM synth chips and a number of chiptunes. All of these waveforms except type 0 (just a sine), type 6 (a square wave), and type 7 (the "logarithmic sawtooth" a.k.a. "derived square" wave) can be produced using a sine wave and AM which adds one or two Wsqr
square wave modulators, flipping amplitude polarity for and/or muting segments of the sine waveform.
Sine. Waveform 0. Nothing to be done.
W
Half-sine. Waveform 1. Needs one square wave, with the same frequency, for 100% depth classic AM. (Amplitude drops to 0 when the square wave is low.)
W a0..1.r[Wsqr r1]
Abs-sine. Waveform 2. Needs one square wave, with the same frequency, for ring modulation (RM). (Amplitude flips polarity when the ± 1.0 square wave is low.) Note that the base frequency doubles as a result.
W a0[Wsqr r1]
Pulse-sine, a.k.a. pseudo-sawtooth. Waveform 3 (1⁄4 sine alternating with equal silence). Needs two square waves, one with the same frequency (for amplitude polarity-flipping to make both halves the same) and one with the double (to cut amplitude to 0 every other quarter of the waveform). Note that the base frequency doubles as a result.
W a0..0[Wsqr r1].r[Wsqr r2]
It would work equally well to write this using a0[Wsqr r1 a0..1.r[Wsqr r2]]
, which unlike the above can also be written using the short-form syntax (using a0.r1
and not a..1.r
).
On/off sine – every other cycle only. Waveform 4. Needs one square wave, of half the frequency, to cut amplitude to 0 every other cycle. Note that the base frequency halves as a result.
W a0..1.r[Wsqr r1/2]
Abs-sine – every other cycle only – a.k.a. camel sine. Waveform 5. Needs two square waves, one with the same frequency (for amplitude polarity-flipping to make both halves the same) and one with the half (to cut amplitude to 0 every every other cycle). Note that the base frequency halves as a result.
W a0..0[Wsqr r1].r[Wsqr r1/2]