CSc 4630/6630 Programming Assignment 4

Documentation
The first thing in your program should be documentation, such as the following. This should appear at the very top of your program.
  % program(number).m
  %
  % Author: (Your Name)
  % Account: (your account name, or student e-mail)
  % CSc 4630/6630 Program (this program number)
  %
  % Due date: (put the due date here)
  %
  % Description:
  % (Give a brief description of what your program does.)
  %
  % Input:
  % (State what the program inputs are.)
  %
  % Output:
  % (State what the program outputs are.)
  %
  % Usage:
  % (Give an example of how to use your program.)
  % (For example: out = myabs(in); )
  %
Verify that the help command shows this information.

Objectives

  1. Practice designing a program iteratively.
  2. Practice implementing a GUI and callback functions in MATLAB.
  3. Develop a useful sound recording program.

Create a simple sound editor

Make a graphical interface that has an area for a plot, along with buttons "record", "stop", "play", "select", "cut", and "save".

Pressing "record" should start recording sound, and stop when the "stop" button is pressed. If the user presses "record" again, your program should start recording sound like before, discarding the previous recording. It is a good idea to let the user know that recording is taking place, and one way to indicate that is to show the text "recording" on the interface. This can be done with a text area on the interface, with a call to the "set" function. Make sure to have the font large enough to be easily seen. When the "stop" button is pressed, show the recorded sound in the plot. Whenever the user presses a button, the text area should be updated appropriately.

The "play" button should play back the recorded sound.

The "select" button should allow the user to select two points on the graph (i.e. with ginput). You can show the selected region by drawing a line on the figure. The command "hold on" allows a second thing to be plotted, and you can add a line segment with a command like

    plot([x1, x2], [y1, y2], 'r*-').

Better yet, you can add 4 such lines to form a rectangle.

The "cut" button means that the recorded sound should be altered, where everything between the start of the selection to the end of the selection should be removed. The program should show the sound plot again, without the selected area. (Hint: use "cla" to clear the "axes" instead of "clf", which would clear the entire interface.) When the user presses "play" after this, the sound should play without the removed part.

Finally, the "save" button means that the sound data should be written to a file. To keep things simple, you can use the filename "prog4sound.ogg".

Tips:


Turn In Your Work

  1. your source code (and .fig if you have one)
  2. an example output file (.ogg)
  3. a log of at least one run

Make sure to use plain text files (.txt, .csv, or .m, as appropriate).


* A script is short for typescript, where everything typed is saved. This keeps a log of all the input and output. MATLAB provides this capability with the diary command. For example, diary out records all inputs and outputs in a file named ``out''. Do NOT call your script file ``programX.m'', or it may overwrite your homework! Make sure to keep a backup of your work. Type help diary at the MATLAB prompt for more information.