6 – Simon Says – Sounds

We add functionality to the “Simon Says” game that we started last week; specifically, we add sound and figure out how to create random sequences that we can use in the game.

Watch this video about the difference between analog and digital signals by bookofscience at home: What is Analog and Digital?

Watch this video about digitizing sound by Production Bytes at home: Digital Audio 101

Class work

Topics for today

  • Analog vs. digital
  • Audio formats supported by the Audio element of HTML 5
    • wav: Wave Audio Format (Uncompress format by MS)
    • mp3: Motion Picture Experts Group format (Compressed format)
    • ogg: (no license)
  • HTML Events
  • HTML5 audio
  • freesound.org
  • Audacity

Workfiles

Download in class: simon-says.zip

Individual files:

We are starting where we left off last week, on version 0 of Simon Says, i.e., we will use simon_0.html and lib0.js and add functions to it to get to version 1.

v1 – Playing pitches when we click on the lightbulbs

  1. simon_1.html: the only change is to point to the new js script
     

     
  2. lib1.js: adding sounds
     

     
  3. Our page so far: simon_1.html

Mini-project (estimated time: 1:30 hour)

For the following exercise, our starting point is simon_1. Download the following file that contains the simon_1 version together with new sounds and images: ss-class-exercise.zip

  1. Replace the sounds of the lightbulbs with other sounds. The new version should work something like this:
    simon_1_class_sounds.html

    Note: Audacity saves new files with a permission of 640 (No access for everyone). In that case, they will play correctly locally but when uploaded to a server they will generate the following error:

    “Failed to load resource: the server responded with a status of 403 (Forbidden)”

    In this case, you need to change the permission of the file to 644 (Read-only for everyone), e.g., in the Mac, you can change the permissions of a file in the ‘Sharing and Permissions’ section of the the ‘Get Info’ window of the corresponding file.

  2. Replace the initial images of the lightbulbs with other images. The new version should work something like this:
    simon_1_class_images_a.html
  3. Replace the images of the lightbulbs with other images. The new version should work something like this:
    simon_1_class_images.html

Answer:

ss-class-exercise-solution.zip