Sample Programming Problems
1) Make
a simple oscil instrument that plays a 3-note chord for every note you
specify in the score. Use p4 for the peak amplitude of the chord and p5 for the
base pitch in PCH. Use p6 and p7 to specify an integer number of semitones
above or below the base pitch that the 2nd and 3rd notes
of the chord should play. (For example, to play a C major chord, which has the
pitches C, E, G, p5 might be 8.00, p6 would be 4, and p7 would be 7.) Use the
following score to test your instrument:
;oscil wave shape
f01 0.000 512 10 1000 250 111 63 40 27
20 15 12 10 8 7 6 5 4
; st dur amp pch sem1 sem2
i01 0 2 15000 7.07 7 15
i01 + . . 8.02 -4 5
i01 + . . 8.03 -3 4
i01 + . . 8.02 -2 4
i01 + 4 . 8.02 -4 5
2)
Make a monophonic FM instrument using foscil
that maps the index of modulation to the peak amplitude, specified in dB in p4
of the score. Assume that the amplitude range is from 10 dB to 90 dB, and make
the index of modulation vary linearly from 1 to 5 over that range of
amplitudes. The instrument should be able to play the following score:
;single sine wave cycle
for foscil
f01 0 10 1
; st dur dbamp pch modfac carfac envrise envdec
i02 0 2 10 7.00 1 1 .25
.5
i02 + . 30
i02 + . 50
i02 + . 70
i02 + . 90
3) Make a stereo version of the Chord Instrument (Example 1, above) that uses an LFO to pan the signal smoothly back and forth between the left and right speakers at a rate in CPS specified in a p-field of the score. (For the LFO, just use an oscili with a simple sine wave for the panning control function.) Modify the score to add the panning frequency in p8, and try various values.
4) Make a subtractive synthesis instrument, using either buzz or gbuzz, that has a Butterworth low-pass filter and a cutoff frequency that sweeps smoothly from the fundamental of the note to a frequency 4 octaves higher and back over the course of p3. The cutoff should move linearly, in terms of octaves, so that halfway through the rise, it is exactly two octaves above the fundamental. (Hint: use linseg to control the cutoff in terms of linear octaves, then use cpsoct to convert from OCT to CPS at the k-rate.) Use p4 for amplitude and p5 to specify the fundamental in PCH, and make a simple test score that plays 4-second notes on your instrument at the pitches 7.00, 7.07, 8.00, 8.07, and 9.00.