rtsetparams(44100, 2) load("WAVETABLE") wave = maketable("wave", 1000, "square") WAVETABLE(0, 8.7, 30000, 6.00, 0.5, wave)
rtsetparams(44100, 2) load("WAVETABLE") wave = maketable("wave", 1000, "square") amp = 10000 dev = 0.004 for (i = 0; i < 4; i += 1) { WAVETABLE(0, 8.7, amp, 6.00+irand(0, dev), 0.5, wave) }
The "dev" parameter is set to less then 1/2-a-semitone (I'm using oct.pc for my pitch specification) -- and that's the upper bound. The real amount of pitch deviation will be set by the random number generator. Fooling around with the "dev" value can be fun! Also notice that the note is slightly sharp; I don't have it 'centered' around 6.00. If I did this:
WAVETABLE(0, 8.7, amp, 6.00+irand(-dev, dev), 0.5, wave)
I would like to have a 'bigger' sound in the stereo spectrum, though. One way to do this would be to spread each of the four notes across the two speakers using the p4 p-field of the notes:
rtsetparams(44100, 2) load("WAVETABLE") wave = maketable("wave", 1000, "square") amp = 10000 dev = 0.004 for (i = 0; i < 4; i += 1) { WAVETABLE(0, 8.7, amp, 6.00+irand(0, dev), i/3, wave) }
I don't really think that is 'wide' enough, though, and I'd like to 'fatten' the sound a little more. I'm going to collapse all four of the square-wave notes into channel 0 of their output and run that into the PANECHO instrument to have the sound ping-pong delayed between the two stereo channels:
rtsetparams(44100, 2) load("WAVETABLE") load("PANECHO") bus_config("WAVETABLE", "aux 0 out") bus_config("PANECHO", "aux 0 in", "out 0-1") wave = maketable("wave", 1000, "square") amp = 4000 dev = 0.004 for (i = 0; i < 4; i += 1) { WAVETABLE(0, 8.7, amp, 6.00+irand(0, dev), 0, wave) } PANECHO(0, 0, 8.7, 1, 0.2, 0.34, 0.5, 5.0, 0)
Two things I want to change now. First of all, the abrupt attack and decay are being picked up by the PANECHO and scattered through the beginning and ending of the sound. This could be a cool effect, but I want something more 'rounded'. This is easily done by applying an amplitude envelope with maketable(). I could do it to each of the WAVETABLE notes, but it's easier just to apply it to the PANECHO, which is the last instrument in the audio chain:
rtsetparams(44100, 2) load("WAVETABLE") load("PANECHO") bus_config("WAVETABLE", "aux 0 out") bus_config("PANECHO", "aux 0 in", "out 0-1") wave = maketable("wave", 1000, "square") amp = 4000 dev = 0.004 for (i = 0; i < 4; i += 1) { WAVETABLE(0, 8.7, amp, 6.00+irand(0, dev), 0, wave) } pamp = 1 pampenv = maketable("line", 1000, 0,0, 10,1, 90,1, 100,0) PANECHO(0, 0, 8.7, pamp*pampenv, 0.2, 0.34, 0.5, 5.0, 0)
The other thing I want to change is to add a little more animation to the sound. I'm getting a fair amount of action from the detuned square waves, but the tuning remains completely fixed during the course of the sound. In the real world, this doesn't happen; oscillators drift out of tune one way and another. I'm going to semi-simulate this by attaching an LFO (low frequency oscillator -- generally an oscillator that works under 20 Hz) to the pitch of each of my four square-wave oscillators:
rtsetparams(44100, 2) load("WAVETABLE") load("PANECHO") bus_config("WAVETABLE", "aux 0 out") bus_config("PANECHO", "aux 0 in", "out 0-1") wave = maketable("wave", 1000, "square") amp = 4000 dev = 0.004 theLFO = {} // note that we have to initialize Minc arrayse maxLFOfreq = 2.0 maxLFOdev = 0.001 for (i = 0; i < 4; i += 1) { theLFO[i] = makeLFO("sine", irand(maxLFOfreq), irand(maxLFOdev)) } for (i = 0; i < 4; i += 1) { WAVETABLE(0, 18.7, amp, 6.00+irand(0, dev)+theLFO[i], 0, wave) } pamp = 1 pampenv = maketable("line", 1000, 0,0, 10,1, 90,1, 100,0) PANECHO(0, 0, 18.7, pamp*pampenv, 0.2, 0.34, 0.5, 5.0, 0)
I also made the notes longer so I could hear more of the evolution of the sound due to the dynamic pitch-changing. Hearing the longer audio really brought out the 'square-waviness' of the sound for me, and I think I'd like to mellow things out a little more. I can do this by inserting a low-pass filter into the audio chain:
rtsetparams(44100, 2) load("WAVETABLE") load("MOOGVCF") load("PANECHO") bus_config("WAVETABLE", "aux 0 out") bus_config("MOOGVCF", "aux 0 in", "aux 1 out") bus_config("PANECHO", "aux 1 in", "out 0-1") wave = maketable("wave", 1000, "square") amp = 10000 dev = 0.004 dur = 21 theLFO = {} maxLFOfreq = 2.0 maxLFOdev = 0.001 for (i = 0; i < 4; i += 1) { theLFO[i] = makeLFO("sine", irand(maxLFOfreq), irand(maxLFOdev)) } for (i = 0; i < 4; i += 1) { WAVETABLE(0, dur, amp, 6.00+irand(0, dev)+theLFO[i], 0, wave) } MOOGVCF(0, 0, dur, 1, 0, 0, 0, 700, 0.7) pamp = 1 pampenv = maketable("line", 1000, 0,0, 10,1, 90,1, 100,0) PANECHO(0, 0, dur, pamp*pampenv, 0.2, 0.34, 0.5, 5.0, 0)
One last thing I'd like to do -- the filter creates an interesting sound, but it might even be more interesting if I had the cutoff frequency of the filter randomly move around (by the way, how did I know to try 700 Hz for the cutoff? Just by fooling around... for years). This can be done using the low-freqency makerandom() p-field command:
rtsetparams(44100, 2) load("WAVETABLE") load("MOOGVCF") load("PANECHO") bus_config("WAVETABLE", "aux 0 out") bus_config("MOOGVCF", "aux 0 in", "aux 1 out") bus_config("PANECHO", "aux 1 in", "out 0-1") wave = maketable("wave", 1000, "square") amp = 10000 dev = 0.004 dur = 21 theLFO = {} maxLFOfreq = 2.0 maxLFOdev = 0.001 for (i = 0; i < 4; i += 1) { theLFO[i] = makeLFO("sine", irand(maxLFOfreq), irand(maxLFOdev)) } for (i = 0; i < 4; i += 1) { WAVETABLE(0, dur, amp, 6.00+irand(0, dev)+theLFO[i], 0, wave) } randcutoff = makerandom("even", 0.3, 500, 2000) MOOGVCF(0, 0, dur, 1, 0, 0, 0, randcutoff, 0.7) pamp = 1 pampenv = maketable("line", 1000, 0,0, 10,1, 90,1, 100,0) PANECHO(0, 0, dur, pamp*pampenv, 0.2, 0.34, 0.5, 5.0, 0)
rtsetparams(44100, 2) load("WAVETABLE") load("MOOGVCF") load("PANECHO") bus_config("WAVETABLE", "aux 0 out") bus_config("MOOGVCF", "aux 0 in", "aux 1 out") bus_config("PANECHO", "aux 1 in", "out 0-1") wave = maketable("wave", 1000, "square") amp = 10000 dev = 0.004 dur = 21 theLFO = {} maxLFOfreq = 2.0 maxLFOdev = 0.001 for (i = 0; i < 4; i += 1) { theLFO[i] = makeLFO("sine", irand(maxLFOfreq), irand(maxLFOdev)) } for (i = 0; i < 4; i += 1) { WAVETABLE(0, dur, amp, 6.00+irand(0, dev)+theLFO[i], 0, wave) } randcutoff = makerandom("even", 0.3, 500, 2000) smoothcutoff = makefilter(randcutoff, "smooth", 100, 1000) MOOGVCF(0, 0, dur, 1, 0, 0, 0, smoothcutoff, 0.7) pamp = 1 pampenv = maketable("line", 1000, 0,0, 10,1, 90,1, 100,0) PANECHO(0, 0, dur, pamp*pampenv, 0.2, 0.34, 0.5, 5.0, 0)
rtsetparams(44100, 2) load("WAVETABLE") load("MOOGVCF") load("PANECHO") srand() bus_config("WAVETABLE", "aux 0 out") bus_config("MOOGVCF", "aux 0 in", "aux 1 out") bus_config("PANECHO", "aux 1 in", "out 0-1") wave = maketable("wave", 1000, "square") amp = 8000 dev = 0.004 dur = 49 theLFO = {} maxLFOfreq = 2.0 maxLFOdev = 0.001 for (i = 0; i < 4; i += 1) { theLFO[i] = makeLFO("sine", irand(maxLFOfreq), irand(maxLFOdev)) } for (i = 0; i < 4; i += 1) { WAVETABLE(0, dur, amp, 6.00+irand(0, dev)+theLFO[i], 0, wave) WAVETABLE(0, dur, amp/2, 5.00+irand(0, dev)+theLFO[i], 0, wave) } randcutoff = makerandom("even", 0.3, 500, 2000) smoothcutoff = makefilter(randcutoff, "smooth", 100, 1000) MOOGVCF(0, 0, dur, 1, 0, 0, 0, smoothcutoff, 0.8) pamp = 1 pampenv = maketable("line", 1000, 0,0, 10,1, 90,1, 100,0) PANECHO(0, 0, dur, pamp*pampenv, 0.2, 0.34, 0.7, 5.0, 0)