Due Friday March 2 at noon.
Install the latest version of Euterpea on your computer as follows:
- Either delete or rename the folder containing your old version of Euterpea.
- In the folder in which you wish the new version installed, type:
darcs get http://bebop.cs.yale.edu/~euterpea/Euterpea
at a command prompt (note the case sensitivity). - cd to the Euterpea folder, and type:
cabal update
cabal install
at a command prompt.
Now when you start up GHCi, it will know about the new version of Euterpea.
Do the following exercises:
- Using the Euterpea function
osc, create a simple sinusoidal wave, but using different table sizes, and different frequencies, and see if you can hear the differences (report on what you hear). UseoutFileto write your results to a file, and be sure to use a decent set of speakers or headphones. - Chapter 18 defines a
vibratofunction, which varies a signal’s frequency at a given rate and depth. Define an analogous functiontremolothat varies the volume at a given rate and depth. However, in a sense,tremolois a kind of envelope (infinite in duration), so define it as a signal source, with which you can then shape whatever signal you wish. Consider the “depth” to be the fractional change to the volume — i.e. a value of 0 would result in no tremolo, a value of 0.1 would vary the amplitude from 0.9 to 1.1, and so on. Test your result. - Define an ADSR (“attack/decay/sustain/release”) envelope generator (i.e. a signal source) called
envADSR, with type:
type DPair = (Double, Double) -- pair of duration and amplitude
envADSR :: DPair -> DPair -> DPair -> Double -> AudSF () Double
The threeDPairarguments are the duration and amplitude of the attack, decay, and release “phases,” respectively, of the envelope. The sustain phase should hold the value of the decay phase. The fourth argument is the duration of the entire envelope, and thus the duration of the sustain phase should be that value minus the sum of the durations of the other three phases. (Hint: use Euterpea’senvLinSegfunction.) Test your result. - Generate a signal that causes clipping, and listen to the result. Then use
simpleClipto “clean it up” somewhat — can you hear the difference? - Write a more ambitious clipping function. In particular, one that uses some kind of non-linear reduction in the signal amplitude as it approaches plus or minus one (rather than abruptly “sticking” at plus or minus one, as in
simpleClip). - Define two instruments, each of type
Instr (AudSF () Double). These can be as simple as you like, but each must take at least two “Params.” Define anInstrMapthat uses these, and then userenderSFto “drive” your instruments from aMusic1value. Test your result.