Sample Synthesis
via Sinewave Modulation and Goldwave

by Krisjanis Gale (theHacker)


Undoubtedly, you've heard them in chiptunes. If you've ever loaded one one up in st3 or ft2, you know what they look like. And if you've ever taken a class in trigonometry, you know where they come from. Of course I speak of perhaps the most useful of all waves - the sinewave.

You may unwittingly assume that sinewaves are boring in their standard form and you would indeed be correct. When the sine function is calculated with respect to time and its results dumped to a raw file and when it is loaded into your favorite tracker, its peculiar sound, although novel at first, quickly becomes annoying. Often, in an attempt to make it more interesting, musicians modify its sound by abusing the portamento and volume slide effects. This too results in banality.

So why bother with sinewaves? That's a good question, and the very point of this article. The sine function, when modulated over time and only then dumped to a sample file can yield many vastly interesting sounds. From snares to organs to bassdrums to faked resonance-filtered acid samples, modulated sinewaves take on varied and distinct personalities.

At this point, I assume that you have at least tried to use Goldwave's expression evaluator, but were clueless as to what to type into the function field. That's okay. Let's start at the very beginning. Load up Goldwave and create a new file. Disregard the standard sample rate and enter 44000. The reason? Well, for the most part you will want to use sinewaves with frequencies that are multiples of 55 hertz. This is both convenient and benificial, as 55 hertz happens to be a perfectly tuned A. So, waves with frequencies 55, 110, 220, 440, 880, 1760, etc. are all A's. The reason you want to use a sample rate of 44000 is that it is evenly divisible by any one of these frequencies.

So now you have a new file open. Now what? Well, let's synthesize one cycle of a sinewave with frequency of 220 hertz (middle A). Select the expression evaluator and input this function: sin(2*pi*t*220). The sine function repeats after 2*pi. So that's just a constant that says you want one complete cycle of sine. 't' refers to time. Goldwave considers sample position 0 as t=0 and the sample rate as t=1. So for a file using a sample rate of 44000, t would become 1 at sample position 44000. So, the function sin(2*pi*t) would yield one cycle of sine across one second, or a sinewave with frequency 1 hertz. But we wanted 220 hertz; hence the frequency modifier. You could enter the function sin(2*pi*t*f) and input '220' in the 'f' field towards the bottom of the expression evaluator dialogue box; that's entirely up to you. The results are the same.

So now you have a sinewave. Or rather, you have 220 repetitions of the same cycle of the sine function per second. This might seems needlessly redundant, and it is. Let's reduce this file down to just one cycle of the sine function we just used. Since we have 220 cycles per second and we're using a sample rate of 44000 then one would expect that each cycle of the sine function only occupies (44000/220) sample positions, or 200.

(I am using "sample positions" instead of bytes for reasons of clarity. Every sample position takes 2 bytes when you're working with 16 bit files.) So, highlight 200 sample positions and crop them. We now have one cycle of the function: sin(2*pi*t*220).

All this work just to derive the same sinewave that's been overused in chiptunes since the beginning of time... great. Relax. There was a reason for all this. Now that you know how to make a sinewave, you know how to modify it. Let's start with very basic frequency modulation. Try this function: sin(2*pi*t*(220-(55*sin(2*pi*t)))). This is a sinewave with a frequency that bounces between (220-55) and (220+55) every second. Use sin(2*pi*t*(220-(55*sin(2*pi*t*55)))) to make it modulate between (220-55) and (220+55) 55 times a second. Experiment with other inner functions for other forms of modulation. Okay, so that's frequency modulation. Another really useful way to spice up the sine function is with amplitude modulation.

Allow me to first introduce three more Goldwave symbols. 'n' is like 't' but it refers to the current sample position. 'T' and 'N' refer to maximum time and maximum sample position. For a one-second file with sample rate of 44000, T=1 and N=44000. Clever use of 't', 'T', 'n', and 'N' can yield many forms of fading and modulated amplification. Just for argument sake, enter the function: (n/N). What do you see? A diagonal line occupying the upper half of the sample window. Try: ((N-n)/N). Gee, it's a line going in the other direction.

Simplistic though they may seem, these tiny expressions become powerful when used as multipliers for other functions. Try this on a one-second file: ((N-n)/N)*sin(2*pi*t*220). It's our 220hz sinewave again, but it fades out over time. ((T-t)/T)*sin(2*pi*t*220) would have the same effect. Let's try another form of amplitude modulation: cos((pi/2)*(n/N))*sin(2*pi*t*220). It's another faded sinewave, but it's being modified by a nonlinear function. So now you know just about all there really is to know about amplitude modulation. Again, experiment until it makes sense and until you find your own interesting functions.

Okay, so you know how to make a sinewave and how to modify it via two important methods. Now what? Believe it or not, using only these three bits of knowledge you can create fantastic synthesized sound. The key is this and this alone: EXPERIMENT. Take the sine of a sine; add two different waves; square the sine function; cube the sine function; mix a faded-out sinewave with another that's fading in; do all of the above; etc. Just remember that this is time well spent. Not only are you learning more about how many expensive synthesizers make their sound, but you're creating the cleanest and most original of all sound.

Krisjanis Gale
theHacker[ultrabeat/fyoozhen/kfmf]

kgale@attila.stevens-tech.edu

06/18/96

To get you started, here's a list of some of my own expressions for Goldwave. Some were derived methodically, others accidentally. Enjoy them, but more importantly, learn from them.

Key: 'N' - file length in sample positions (not bytes). 'f' - (initial) frequency

* where N and f aren't specified, try N=sample rate (1 second) and 220, or experiment with other values.


// Typical sinewave:
   sin(2*pi*t*f)
{} A good starting point for all equations.

// 6 multiples:
   sin(2*pi*t*f)*sin(4*pi*t*f)*sin(8*pi*t*f)
  *sin(16*pi*t*f)*sin(32*pi*t*f)*sin(64*pi*t*f)
{} Six sinewaves, multiplied by each other.  A very odd synth indeed.

// Very odd use of sine:
   sin(4*sin(8*pi*f*t))
{} A sine of a sine?  Yup...  to create varying degrees of weirdness, play
   a bit with the multipliers before the second sine and before the pi.

// "Beep":
   (4/3)*((N-n)/N)*sin(16*pi*t*f)
{} The 4/3 takes the sine wave just beyond the clipping point...
   this creates initial loudness, fading down to nothing.

// Interesting sin/tan combination:
   ((N-n)/N)*sin(2*pi*t*f)+(1/256)*tan(2*pi*t*f)
{} Sure, everyone's used the sine function to generate synths, but who
   ever thought of using the tangent function?!

// Clavichord synth:
   (rand(8)/8)*sin(rand(8)*pi*t*f)
{} Experiment with the random values and evaluate several times to get
   the sound you want.

// Neat organ synth:
   ((N-n)/N)*sin(8*pi*f*t)+(n/N)*sin(2*pi*f*t)
{} You'll swear it's a real percussive organ; have fun with it by adding
   echo and/or using longer file lengths.

// Pretty good snare:
   ((N-n)/N)*sin(2*pi*t*f)+(1/2)*((N-n)/N)*sin(rand(16)*t*f)
{} No joke, it sounds like a snare; experiment with the random value if you
   want a more (or less) "pure" sinewave; completely eliminate the random
   function to generate a synth-tom.

// "Kwerk":
   (11/10)*((N-n)/N)*sin(16*pi*((f*(N-n))/N)*t)
{} The frequency decreases as the evaluator moves through each byte,
   creating a quirky sound that starts out with a high frequency
   and ends up at zero.

// Phaser:
   ((N-n)/N)*sin(2*pi*sqrt(t)*f)
{} Sounds much like a vintage Star Trek sound effect.

// Another good snare:
   ((N-n)/N)*(sin(2*pi*sqrt(t*f))+(1/4)*sin(2*pi*t*rand(4)*f))
{} Almost sounds like a 909 snare.

// Beat pulse:
   ((N-n)/N)*sin(2*pi*sqrt(t*f))
{} Not a true bassdrum, but can be used as one.

// Overdriven beat pulse:
   (4/3)*cos((pi/2)*(n/N))*(sin(2*pi*sqrt(t*f))
   +((1/8)*cos((pi/2)*(n/N))*sin(2*pi*t*rand(4)*f)))
{} Same as above, but overdriven and with slight noise added.

// Acid emulation:
   sin(2*pi*t*f*cos(2*pi*t*f))
{} Almost sounds like a 303 acid sample.

// Spacey alarm:
   sin(pi*t)*sin(2*pi*t*f*sin(16*pi*t*f))
{} A REALLY WEIRD equation.  Try it and see!

// Frequency modulation:
   (sin(2*pi*t*(55-(55*(2*pi*t*55))))+sin(2*pi*t*(55+(55*(2*pi*t*55)))))/2
{} Sounds like something straight out of 2001: A Space Odyssey.

// Deep boom tom:
   (cos(pi*(n/16000))^2)*(sin(2*pi*t*(110+(110*sin(pi*(n/16000)))))
   +sin(2*pi*t*220)+sin(2*pi*t*(440-(220*sin(pi*(n/16000))))))
{} A very deep boom when played back at low frequencies.

// Frequency-modulated beat pulse:
   sin(2*pi*t*(f/(2^(t*40))))
   f=880
   N=4400
   rate=44000
{} Makes a nice bass drum.

// Shorter freq-mod pulse:
   sin(2*pi*t*(f/(2^(t*160))))
   f=1760
   N=4400
   rate=44000
{} Slight modification of previous synth.

// High-pitch freq-mod pulse:
   sin(2*pi*t*((f+(880*sin(2*pi*t*440)))/(2^(t*160))))
   f=1760
   N=4400
   rate=44000
{} Modification of original with far more modulation.

// Bizarre alarm sound:
   (sin(10*pi*t)*sin(2*pi*t*(t*4400)))
   +(sin(20*pi*t)*sin(2*pi*t*(220+(219*sin(40*pi*t)))))
   T=1
   rate=44000
{} Accidentally discovered synth; pretty cool sound effect.

// Metallic pulse:
   (4/3)*cos((pi/2)*(n/N))*(sin(2*pi*(n/N)*f)
   +((1/4)*sin(2*pi*t*rand(4)*f*8)))
   f=3520
   N=8000
{} A beat pulse with a strange metallic quality.

// Crackly snare:
   (cos((pi/2)*(n/N))^4)*((sin(2*pi*sqrt(t*f))^3)
   +((1/4)*(cos((pi/2)*(n/N))^2)*tan(2*pi*t*rand(16)*f)))
   f=1760
   N=4000
{} Very interesting snare modification.

[II]--[II]--[II]--[II]--[II]--[II]--[II]--[II]--[II]--[II]--[II]--[II]--[II]