Creating Music with MATLAB: Code, Synthesis, and Possibilities Explained

  • MATLAB
  • Thread starter needOfHelpCMath
  • Start date
  • Tags
    Matlab Music
In summary, the conversation discusses a project in which the goal is to write MATLAB code that loads a file containing data on a musical piece and synthesizes the notes to play the music. The file contains a structure array with three elements, representing three voices in the music. Each element has three fields - pitch, start, and duration - which define the sequence of notes. The conversation also includes a discussion on the frequency of the notes and a question about the purpose of the project.
  • #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:
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};
I am not sure if my code is right or i complete do not know what they are asking for.
 
Physics news on Phys.org
  • #2
Are you interested in actually creating music? Or you want to develop something semi-trivial so you can analyse it using MATLAB?
 

1. What is MATLAB and how is it used in creating music?

MATLAB is a programming language and software environment used for numerical computation, data analysis, and visualization. It can also be used for creating music by generating and manipulating audio signals, synthesizing sounds, and creating musical algorithms.

2. Can beginners without any coding experience use "Creating Music with MATLAB"?

Yes, "Creating Music with MATLAB" is designed to be accessible for both beginners and experienced coders. The book provides step-by-step instructions and explanations, making it easy for beginners to follow along and learn how to create music with MATLAB.

3. Can I create any type of music with MATLAB?

Yes, MATLAB can be used to create a wide range of musical styles and genres. It has built-in functions for generating basic waveforms, as well as tools for creating more complex sounds and effects. With some programming knowledge, the possibilities are endless.

4. Do I need any additional hardware or software to use MATLAB for music creation?

No, all you need is a computer and the MATLAB software. While some additional software and hardware can enhance your music creation experience, they are not necessary to get started with creating music using MATLAB.

5. Is "Creating Music with MATLAB" suitable for professional musicians and producers?

Yes, "Creating Music with MATLAB" is suitable for both beginners and professionals. It covers a wide range of topics, from the basics of programming to advanced techniques for music creation. It can be a valuable resource for anyone interested in using MATLAB for music production.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
575
  • MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
Back
Top