1 Setup
2 Functions that generate samples

Lab 8

In this lab, I’d like you to create one test case for each function *before* you develop the function itself. Use check-expect for this.

1 Setup

There are a number of setup steps required:

  1. Set the language level to a minimum of Intermediate Student.

  2. Evaluate this program to load the latest version of the rsound package:
      (require (planet "main.rkt" ("clements" "rsound.plt" 1 3)))

  3. Quit and restart DrRacket.

  4. Make sure it works, by playing the ding.

  5. Open the documentation for rsound, by visiting the web page http://planet.racket-lang.org/package-source/clements/rsound.plt/1/3/planet-docs/rsound/index.html.

  6. To get both the drawing and the playing functions, begin your program with this block:
      (require (planet "main.rkt" ("clements" "rsound.plt" 1 3)))
      (require (planet "draw.rkt" ("clements" "rsound.plt" 1 3)))

2 Functions that generate samples

  1. Develop the function t, that accepts an integer n and returns the cosine of 2π*400*n/44100. Please include at least one test case.

  2. Use the function fun->mono-rsound to generate a sound using this function. Read the documentation for fun->mono-rsound to see how. Play the sound.

  3. Use the function rsound-draw to draw the sound that you generated. Zoom in by clicking on the waveform.

  4. Develop a new function sum-t that is like t but instead produces the sum of three waves of different frequencies, scaled so that the values are no larger than 1.0.

  5. Again, use fun->mono-rsound to generate a sound, rsound-play to play it, and rsound-draw to draw it.

  6. Find a piece of music online. Using rsound-read/clip or rsound-clip, define a sound that is no more than 400 samples.

  7. Play the fragment. How long is the fragment?

  8. Play 100 copies of the fragment, using the times function.

  9. Draw the fragment, using rsound-draw.

  10. Based on the drawing, develop a function my-t that produces a new waveform that is similar to the one you downloaded. Can you make them look and sound the same?