Tone Matrix

Wednesday, July 30


Due Wednesday, July 30 at 11:59 PM

  • Submit to Paperless. Deadline is 11:59 PM.
  • The late day policy gives you the ability to self-grant an extension (as long as you have not used all your late days); we trust you will make reasonable and sparing use of this power. Be sure to reserve late days for emergencies.
  • Reminder: You have a limited pool of late days. You have a total of 4 late days to use throughout the quarter, but you cannot use more than 2 late days per assignment. Late days are expended in 24-hour blocks. See the Assignments page for more details.

In this assignment, you'll build a digital instrument, the Tone Matrix, controlled with a simple visual interface. The Tone Matrix is a square grid of lights, each of which is initially turned off. The user can turn lights on and off by clicking and dragging across the grid.

Each light in the grid represents a musical note at a specific point in time. Lights further to the left are played before lights further to the right. The row of a light determines which note is played: lights toward the bottom of the Tone Matrix have a lower pitch than lights toward the top. All lights on the same row play the same note and correspond to playing that note at different points in time. If multiple lights are turned on in the same column, they will be played simultaneously when their column is played.

Here's a video demonstrating the Tone Matrix in action:


Over the course of this assignment, you will implement all the parts of the Tone Matrix - the code to generate the sounds, the code that interfaces with the mouse, and the code that draws everything on the screen. In doing so, you will gain experience implementing classes and working with dynamic memory allocation.

This assignment is to be completed individually. Working in pairs/groups is not permitted.

Learning goals

  • Students will be able to implement a class according to a provided interface definition.
  • Students will understand how code is written in the role of implementer and how that differs from code written in the role of client.
  • Students will gain practice with pointers, dynamic arrays, and explicit management of memory using new and delete.
  • Students will develop an appreciation for the need to be vigilant when working with memory and pointers.
  • Students will be able to identify tradeoffs in implementation options and to reason about how these choices impact the flexibility and efficiency of a class and its member functions.

Assignment parts

This assignment consists of a warmup debugging exercise and two programming tasks.

  • Debugging Warmup

    This warm-up debugging exercise is designed to get you comfortable exploring arrays in memory and seeing what lies beyond them.

  • Simulating a String Instrument

    Complete the implementation of a StringInstrument class that performs a simplified physical simulation of a plucked string instrument. This class will generate the sounds used by the Tone Matrix.

  • Implementing the Tone Matrix

    Implement the ToneMatrix class, which will maintain a grid of lights, respond to user input, determine when to pluck each string, and decide what data gets sent to the computer speakers. You can then play with your awesome creation!

Timeline

We recommend the following timeline for completing each of the three parts to this assignment:

  • Aim to complete the Debugging Warmup the day this assignment goes out.
  • Aim to complete String Simulation within three days of this assignment going out.
  • Aim to complete Tone Matrix within seven days of this assignment going out.

Getting started

๐Ÿ“ฆ Starter project

The starter project is provided as a zip archive. Download the zip, extract the files, and move the project folder to your CS106B folder. Open the .pro file in Qt Creator to get started.

Resources

Here are resources that will be helpful for this assignment:

Getting help

Working very closely with raw memory and implementing your own classes can get tricky! We recommend drawing lots of diagrams and making maximal use of the debugger.

Look for an announcement on the Ed forum for the YEAH session for this assignment. If you have questions for us, the Ed forum is open 24/7 for general discussion. Always start by searching first to see if your question has already been asked and answered before making a new post. To troubleshoot a problem with your specific code, your best bet is to bring it to the LaIR helper hours or office hours.

Submit

Before you call it done, run through our submit checklist to be sure all your ts are crossed and is dotted. Then upload your completed files to Paperless for grading.

Please submit only the files you edited; for this assignment, these files will be:

  • StringInstrument.cpp
  • StringInstrument.h
  • ToneMatrix.cpp
  • ToneMatrix.h
  • short_answer.txt
  • Any images you generate for short answer Question 8.

Don't forget to submit the header (.h) files listed above, your short_answer.txt file, and any images you generate for short answer Question 8!

Super important note: After submission, double check that you have uploaded the correct files and not old versions of your work or blank copies. We do not accept re-submissions after the late deadline has passed.

๐Ÿ Submit to Paperless.

Note: On Paperless, all due dates and submission times are expressed in Pacific time.