Answered step by step
Verified Expert Solution
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 seconds worth of Johann Sebastian Bach's Fugue # for the WellTempered 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 computergenerated 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, Each student will submit hisher 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: voicem where m or 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: voicempitch voicemstart voicemduration Each of these fields is a vector. For a given structure for example, voice 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. For example, the first number in the vector voicestart voicestart is the start time in seconds of the first note in the sequence of notes defined by voice The first number in the vector voiceduration voiceduration is the duration in seconds of this first note. The first number in the vector voicepitch voicepitch is the pitch number of this first note. Using the symbol p to represent the pitch number voicempitchn the pitch number for the nth note of the mth voice, the frequency of this note is given by times Hz A couple of examples might be helpful. When the frequency is Hz When the frequency is 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 When you move your finger on the keyboard to the right by keys, the frequency doubles. For example, your finger moves keys to the right in shifting from the key associated with pitch number to the key associated with pitch number and the corresponding frequencies are Hz and Hz respectively. A set of 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. 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 mfile and a function mfile. 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 hertz or equivalently, samples per second This sampling frequency is only onefourth the sampling frequency kHz used on a CD but 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
The file fugue.mat is available on Canvas. It contains numerical data that encode about
seconds worth of Johann Sebastian Bach's Fugue # for the WellTempered 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 computergenerated 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,
Each student will submit hisher 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:
voicem where m or
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:
voicempitch
voicemstart
voicemduration
Each of these fields is a vector. For a given structure for example, voice 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.
For example, the first number in the vector voicestart
voicestart
is the start time in seconds of the first note in the sequence of notes defined by voice The
first number in the vector voiceduration
voiceduration
is the duration in seconds of this first note. The first number in the vector voicepitch
voicepitch
is the pitch number of this first note.
Using the symbol p to represent the pitch number voicempitchn the pitch number
for the nth note of the mth voice, the frequency of this note is given by
times Hz
A couple of examples might be helpful. When the frequency is Hz When
the frequency is 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 When you move your finger on the keyboard to the right by keys, the
frequency doubles. For example, your finger moves keys to the right in shifting from the key
associated with pitch number to the key associated with pitch number and the
corresponding frequencies are Hz and Hz respectively. A set of 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.
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 mfile and a function mfile. 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 hertz or equivalently, samples per second This sampling frequency
is only onefourth the sampling frequency kHz used on a CD but 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
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started