Making Noise

In this activity, you will make a noise sample from scratch by making the computer play a set of random volume intensities.

Needed for SOUND GENERATOR...

SOUND GENERATOR

Sound is pressure waves, and the patterns of those waves determine what the sound sounds like. In Snap!, sounds can be generated as lists of volume intensities. You'll start by creating one second of "noise", which is just random intensities that sound like static.

Making Noise

  1. Open your "Sparks-Making-Noise" project if isn't open already.
  2. Create a variable called noise to store the intensity values, and make it start as an empty list.
    show variable (noise); set (noise) to (list)
  3. Talk with Your Partner
    What is the difference between the inputs of the following two expressions? What is the difference between their outputs?
    pick random (-1) to (1)
    pick random (-0.99999) to (1)
  4. noise variable watcher showing a list of long decimals between -1 and 1 Talk with Your Partner What will this code do?
    warp(repeat((sample rate) of sound (microphone(samples)))(add(pick random (-0.99999) to (1)) to (noise)))
    Look at the variable watcher on the Snap! stage to confirm. Drag its corner to expand, and then scroll.
  5. Click for a break-down of how this code works.

    • The above code repeatedly adds a random number between -1 and 1 to the noise variable.
    • The first input to pick random is -0.99999 instead of -1 to force that block to output decimals rather than only integers.
    • The add block is repeated sampling rate number of times.
    • The warp block acts like a time-warp to speed things up.

    The sample rate is how many intensity samples fit in one second of sound samples detected by the microphone.
    (sample rate) of sound (microphone(samples)) reporting 44100

  6. Set Up Your Headphones or Speakers Build that code in Snap!, then drag the noise variable into the play block, turn down the volume, and play the noise. Debug your code if needed.
    play sound (noise)
  7. Now Is a Good Time to Save
In this activity, you created noise by making the computer play a bunch of random volume intensities.