Assignment 5

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:

  1. 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). Use outFile to write your results to a file, and be sure to use a decent set of speakers or headphones.
  2. Chapter 18 defines a vibrato function, which varies a signal’s frequency at a given rate and depth. Define an analogous function tremolo that varies the volume at a given rate and depth. However, in a sense, tremolo is 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.
  3. 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 three DPair arguments 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’s envLinSeg function.) Test your result.
  4. Generate a signal that causes clipping, and listen to the result. Then use simpleClip to “clean it up” somewhat — can you hear the difference?
  5. 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).
  6. 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 an InstrMap that uses these, and then use renderSF to “drive” your instruments from a Music1 value. Test your result.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>