| |
Introduction to Haskell, HasSound, and Audio Synthesis
Due Friday, October 6
The purpose of this assignment is to get you started programming
in Haskell, and in particular doing audio synthesis using HasSound. You
should use the following HasSound Tutorial instead of the one in the HasSound
distribution:
-
(a) Suppose that we create a wavetable containing 200 elements
of a pure sine wave. Using a sampling rate of 44.1kHz, at what frequency
will aliasing occur? (b) If we are only interested in reproducing
audible sounds, how large should the wavetable be to ensure that aliasing does
not occur? (c) In practice, do you think that there is any advantage to
using a wavetable either larger or smaller than the answer to (b)?
-
(a) Create a signal using amplitude modulation, in which the
carrier frequency is the note pitch p, and the modulating frequency varies
between 0 and p/2. But in addition, you should modulate the modulating
frequency (!) with some other fixed frequency of your choice. (b)
Now do the same thing, but use frequency modulation.
-
Create a wavetable that implements a "trapezoidal" envelope --
it rises linearly from zero to some value, then sustains that value, then
drops linearly back to zero. The width of the base of the trapezoid
should be the note duration. Use this envelope to control the signal in
(2) above.
-
(a) Create tremolo and vibrato effects by taking two
p-fields, one for each effect, which specify the depth of the effect.
The tremolo depth should be a fraction of the note amplitude (velocity), and
vibrato effect should be a fraction of the note pitch. For example, a
note "c 4 qn [a, t, v]" could be a quarter-note middle C with amplitude a,
tremolo t, and vibrato v. If t is .1 then the note's amplitude should
vary by 10% of a, and if v is .05 then the note's pitch should vary by 5% of
the frequency corresponding to middle C. You can use a fixed
rate for both the tremolo and vibrato. (b) use the envelope in (3)
above to control these effects over the duration of a note -- i.e. the effect
is zero at the beginning, then ramps up to the depth specified by the p-field,
then drops back to zero.
-
Write a HasSound program that uses the first p-field in a note
statement to specify the number of odd harmonics added to the fundamental,
which should be a pure sine wave. (This is harder than it sounds... in
particular, you may have to limit the total number of harmonics.)
-
Use your imagination to create an instrument of arbitrary
complexity and aesthetic appeal :-).
Solution.
|