Doküman >> Creating Music on MATLAB? (2841 Okunma)

Tam Metin:YazdırPaylaş

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
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 <>.

v1.0 by Volkan Gezer

*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.


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.


English (EN)

Eklenme Tarihi:

12.02.2013 18:11:08


Volkan Gezer


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

Yorum Yaz

Adı Soyadı:
E-Posta (gösterilmeyecek):
Güvenlik Kodu: 824253

Makaleye Yapılan Yorumlar

Yorum: #1^
Başlık: student

I would like the script for Adele please


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

Ekleyen: Tom Dixon (Eklenme: 27.04.2017 22:28:05)

Sayfa Başı


Sayın Ziyaretçi, lütfen giriş yapın veya kaydolun.

Sıkça Sorulan Sorular

En Çok Okunan 5 Makale

Avast Mobile Security - Ücretsiz Android Güvenli...
Gmail toplu e-posta iletisi silme
Casio FX-82MS (Bilinmeyenler)
Almanya'da Yüksek Lisans (Master) Vize Hakki...
MATLAB'de Müzik Yapmak mı?

En Çok İndirilen 5 Dosya

C Dili
Hermes E-Posta Sunucusu
FreeInstall 2.18
Kendi E-Posta Sunucunuzu Oluşturma