No Title

EECS20: Introduction to Real-Time Digital Systems

Lab03: Music


EECS20: Introduction to Real-Time Digital Systems
©1996 Regents of the University of California.
By K. H. Chiang, William T. Huang, Brian L. Evans.
This lab is taken from Labs for Signals and Systems by Virginia Stonick and Kevin Bradley. URL: http://www-inst.eecs.berkeley.edu/~ee20
News: ucb.class.ee20
Assigned: 12 Feb 97, Checkoff: 19 Feb 97, Writeup Due: 21 Feb 97

Introduction

Music is a succession of notes. Some notes are played simultaneously as chords to add an additional dimension to the sound. A note is simply a tone at an audible frequency plus zero or more harmonics of that tone. The harmonics, if present, are generally at a lesser strength than the fundamental tone and decrease in strength as frequency increases.

There are a number of terms in music theory that can be used to describe a work of music. The melody is the succession of single notes that captures the tune of a given song. The harmony is the succession of chords instead.gif

A simple way to synthesize music is to play the melody as a sequence of audible tones. A more complex synthesis would combine the tone plus harmonics. Even a more complex approach would shape the sounds according to how a human would play the notes on a musical instrument. Synthesizers use the latter approach, plus models of the particular instrument being duplicated. In this laboratory, you will play melodies and shape the sounds associated with them.

Musical Notes

Music is based upon a twelve note scale. Each of those notes can be generated by constructing a sinusoid of the appropriate frequency. Some of these frequencies are listed in Table 1.

  
Figure 1: Frequencies of some selected musical notes.

Certain notes have two names, as the sharp of the note preceding it, or the flat of the note following it.

It is also interesting to note that the frequency of a given note is times the frequency of the preceeding note.

Consider the ``Star-Spangled Banner''. Its first few notes are G, E, middle C, E, G, C, with the duration of the first two notes half as long of the duration of the other notes. These six notes can be generated in Matlab by playing six sinusoids of the appropriate frequencies in sequence.

Improving Quality

Unfortunately, if you do what has been suggested above, the resulting notes do not sound very good. In order to improve the quality, there are a number of things that you can try.

If you vary the volume of a given note as a function of time, as in Figure 2, you can simulate a realistic note.

  
Figure 2: Volume as a function of time for a musical note played realistically.

When you hit a key on a piano keyboard, the volume rises from zero to a maximum value in the attack portion of the note. The volume then decays to an intermediate value, which is sustained for a length of time. This volume will either decay to zero if the key is held for a long period of time, or will be damped out when the key is released. The figure is drawn assuming the latter case.

You can achieve a stacatto effect by not overlapping the notes in time. This is effectively what you are doing if you have simply played the notes in sequence as suggested above. Unfortunately, the stacatto effect applied indiscriminately makes the notes sound as if they were played by an amateur.

Harmonics of the fundamental frequency of a note can be added to make the note sound richer and more enjoyable. The harmonics, sinusoids with frequencies that are multiples of the fundamental frequency, should have amplitudes less than that of the fundamental, so that they do not dominate the note.

Certain notes can be emphasized in relation to others by making the overall amplitudes of their envelopes greater than the others around them.

Questions

  1. Starting from middle C, generate and listen to the notes in Table 1. Take advantage of the fact that the notes are Hz apart. What happens when you double or halve the frequency of a given note?

  2. Select one of your favorite works of music and generate an appropriate set of tones that corresponds to eight or so notes from that work. Make sure that the duration of the notes sounds correct.

  3. Attempt to make your tones more realistic by: Compare your resulting tones to those generated from the electronic keyboard next to the workstation.

  4. What happens to your set of tones when you run it through the half and double functions that you wrote in the first lab?



khc
Mon Feb 5 10:29:47 PST 1996