- #1
needOfHelpCMath
- 72
- 0
I have project code using MatLab and so far I am having difficulties of understanding what it is asking for. May anyone explain for me please.
The file fugue.mat 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.This is the code that i must read in to in order to play my code sound:
function soundproject3(fileToRead1)
%IMPORTFILE(FILETOREAD1)
% Imports data from the specified file
% FILETOREAD1: file to read
% Auto-generated by MATLAB on 27-Nov-2016 16:45:27
% Import the file
newData1 = load('-mat', fileToRead1);
% Create new variables in the base workspace from those fields.
vars = fieldnames(newData1);
for i = 1:length(vars)
assignin('base', vars{i}, newData1.(vars{i}));
end
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 × 2(𝑝−49)⁄12 Hz
So here what i have so far:
I am not sure if my code is right or i complete do not know what they are asking for.
The file fugue.mat 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.This is the code that i must read in to in order to play my code sound:
function soundproject3(fileToRead1)
%IMPORTFILE(FILETOREAD1)
% Imports data from the specified file
% FILETOREAD1: file to read
% Auto-generated by MATLAB on 27-Nov-2016 16:45:27
% Import the file
newData1 = load('-mat', fileToRead1);
% Create new variables in the base workspace from those fields.
vars = fieldnames(newData1);
for i = 1:length(vars)
assignin('base', vars{i}, newData1.(vars{i}));
end
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 × 2(𝑝−49)⁄12 Hz
So here what i have so far:
Code:
voice(1).pitch(1)
pitch(1) = {1};
voice(1).start(1)
start(1) = {1};
voice(1).duration(1)
duration(1) = {1};
voice(1).pitch(2)
pitch(2) = {1};
voice(1).start(2)
start(2) = {1};
voice(1).duration(2)
duration(2) = {1};
voice(1).pitch(3)
pitch(3) = {1};
voice(1).start(3)
start(3)= {1};
voice(1).duration(3)
duration(3) = {3};