Doküman >> Creating Music on MATLAB? (12677 Read)

Full Text:PrintShare

On my previous article told that I would add the codes of my "3 Octave Music Player Project". The codes can be downloaded from here, but you need a password to download the file. 

The code is licensed under GNU, so you need to obey GNU license and include my name if you would like to use it in any of your work.

You can contact me via the top menu or add a comment below to get your password (If site language is Turkish, click on the top-right link to change into English). Here is the usage of the Music Player:

 

***3 Octave Note Player for MATLAB***


Copyright (c) 2012-2013 - Volkan Gezer

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

v1.0 by Volkan Gezer
http://volkangezer.scienceontheweb.net

*Quick Start Guide:

a) Files required:

musicplay.m - Main function file
returnNotes.m - Note letter to note number equivalent conversion function

b) Usage

0) Change MATLAB active directory to this directory.

1) Enter left and right hand notes in a char array using space between notes.

*Notes should be entered as follows: NoteLetter[Sharp(#)symbol]OctaveNumber.

Example: C#4 D5

* Since notes will be inside a char array, they should follow the rule below:
x=['NoteLetter1[Sharp(#)symbol]OctaveNumber1 NoteLetter2[Sharp(#)symbol]OctaveNumber2'];

*** Square brackets are optional, but single quotes are obligatory!

Example: i=['C#4 D5'];

* For neat coding, you may want to go to next line. To go to next line, close single quote
('), add three dots (...), go to next line, start line using single quote again and leave
a space before entering new note.

Example:

j=['C4 D3 G5 D4 D4 E4 A4' ...
' C4 C4 G5 F#4 E4 A4'
];

2) Call function to play the notes.

After writing notes for both left and right hand (see below (3) if you have no notes for left hand)
call function using: musicplay(rightHandNotes, leftHandNotes, defaultOctave, startFromLeft,
playFromLeft, waittime, sampleCount, samplingFreq)

At least two arguments (rightHandNotes, leftHandNotes) should be given so that others will get
their default values.

3) If you have no notes for leftHandNotes:

* You should create a silent note using x=['N0'] and playFromLeft argument should be zero.

*** This will bypass playing from left hand notes.


4) More questions on usage or looking for examples?

Execute: run('./twinkletwinklelittlestar_regular.m') - for Twinkle Twinkle Little Star
Execute: run('./someonelikeyou_regular.m') - for Adele - Someone Like You
Execute: run('./someonelikeyou_numbereq.m') - for Adele - Someone Like You (number equivalent of notes)
Execute: run('./titanium_regular.m') - for David Guetta - Titanium


Execute "doc musicplay" on MATLAB

c) Troubleshooting:

Here are some problems that you may experience and their solutions:

1) Subscript indices must either be real positive integers or logicals. - The first note at first line
starting after single quote must not have a space in front of it.
2) CAT arguments dimensions are not consistent. - You used multiple lines, but forgot to place "..." at
the end of the lines.
3) In an assignment A(I) = B, the number of elements in B and ... - There are no spaces between notes
or octave number is missing (e.g. you only wrote C instead of C4).
4) Index exceeds matrix dimensions. - You have more than one space between notes.

Language:

English (EN)

Date added:

12.02.2013 18:11:08

Added by:

Volkan Gezer

Tags:

matlab music player, playing music on matlab, matlab fun, matlab playing notes, matlab create music


Write a Comment

First Name Last Name:
E-Mail (will not be shown):
Title:
Comment:
Security Code: 708288


Comments to this article


Comment: #1^
Title: student
Comment:

I would like the script for Adele please

Answer:

Thank you for the message. I sent you the password via e-mail.

Added by: Tom Dixon (Added by: 27.04.2017 22:28:05)
Comment: #2^
Title: Student
Comment:

If you dont mind. Please to guve me some script of some songs for my reference or basis

Answer:

Sent by e-mail.

Added by: Lance Nichol Canaveral (Added by: 09.10.2018 06:54:47)
Comment: #3^
Title: I would like it for educational purposes
Comment:

Im working on MATLAB at school, were making sounds as you did for SLY. thx

Answer:

The password was sent by e-mail.

Added by: Lebouli (Added by: 19.12.2018 10:53:38)


Top of the page