Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The file fugue.mat is available on Canvas. It contains numerical data that encode about 3 0 - seconds worth of Johann Sebastian Bach's Fugue #

The file fugue.mat is available on Canvas. It contains numerical data that encode about 30-
seconds worth of Johann Sebastian Bach's Fugue #2 for the Well-Tempered Clavier. You are to
write MATLAB code that loads this file, synthesizes the notes with correct timing, and then
plays the notes.
You will also prepare a document discussing possibilities for the computer-generated synthesis
of music.
In order to complete this project, you will need a computer with both MATLAB and sound. If
you use a computer in the ECE department, you may need a set of headphones.
This project is a rewritten version of a project given on the CD accompanying the book:
J. H. McClellan, R. W. Schafer, and M. A. Yoder, Signal Processing First, Prentice Hall, 2003.
Each student will submit his/her own work. You may discuss this project with other students.
But your submissions must be the fruit of your own labor.
Description of Project
The file fugue.mat contains a structure array called voice with three elements. (In musical
terms, this fugue contains three voices.) These elements are:
voice(m), where m =1,2, or 3
Each of these elements is a structure. Each of the elements represents a sequence of notes that is
to be played. Each structure contains three fields:
voice(m).pitch
voice(m).start
voice(m).duration
Each of these fields is a vector. For a given structure for example, voice(2) the three
vectors pitch, start, duration are of equal length. These three vectors together
define a sequence of notes. The vector start defines the start time of each note. The vector
duration defines the duration of each note. The vector pitch defines the pitch of each
note.
2
For example, the first number in the vector voice(2).start
voice(2).start(1)
is the start time in seconds of the first note in the sequence of notes defined by voice(2). The
first number in the vector voice(2).duration
voice(2).duration(1)
is the duration in seconds of this first note. The first number in the vector voice(2).pitch
voice(2).pitch(1)
is the pitch number of this first note.
Using the symbol p to represent the pitch number voice(m).pitch(n), the pitch number
for the n-th note of the m-th voice, the frequency of this note is given by
440\times 2(49)12 Hz
A couple of examples might be helpful. When =49, the frequency is 440 Hz. When =37,
the frequency is 220 Hz.
The vector start tells you when each note should start, and the vector duration tells you
how long each note should last. Both of these vectors measure time in seconds.
In musical terms, each of the pitch numbers (numbers in the vector pitch) represents a key on
the piano keyboard. This scheme accounts for both black and white keys. The pitch number
increases as your finger moves from left to right on the keyboard. Middle C has been assigned
the pitch number 40. When you move your finger on the keyboard to the right by 12 keys, the
frequency doubles. For example, your finger moves 12 keys to the right in shifting from the key
associated with pitch number 37 to the key associated with pitch number 49, and the
corresponding frequencies are 220 Hz and 440 Hz, respectively. A set of 12 consecutive keys
(including both black and white keys) is called an octave, corresponding to a doubling of the
frequency.
Based on the above comments, the following idea should be forming in your mind. The file
fugue.mat contains the same information normally found on sheet music. The program that
you write will essentially replace three instruments. Your program will take the information
from fugue.mat and use this information and the sound capability of the computer to play this
fugue. The actual playing of the fugue is accomplished by passing a signal vector, which your
program constructs, to the function sound. The signal vector will also be recorded.
3
Specific Instructions
You will first copy the file fugue.mat from Canvas into the folder that you will use as the
current folder while working on this project.
You will write a script m-file and a function m-file. The function will be called from the script.
Within the script, you will load the file fugue.mat into the MATLAB workspace using load.
The script will also define a variable representing the sampling frequency and assign this
variable the value 11025(hertz or, equivalently, samples per second). This sampling frequency
is only one-fourth the sampling frequency (44.1 kHz) used on a CD, but 11025 Hz is adequate
for the purpose of this project.
Your function will produce a signal vector representing one note. There will be three input
arguments to this function. The first of these is the pitch number. The next argument is the
duration in seconds. The final argument is the sampling frequency in hertz. This function will
not need the start time because the signal vector produced by this function will later be shifted to
start at the correct time. (That shifting will occur in the script

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions