Matlab Piano

Hello. I am a freshman student at mechanical engineering. I try to make a piano on matlab gui for final project but I don't know how I make exactly. Only keybord is enough for my project but I need help. I will appreciate if you help me. Thank you in advance.

4 Comments

Walter Roberson
Walter Roberson on 19 Dec 2011
Whom is this addressed to?
Are you asking about how to make the GUI, or about how to interface a MIDI keyboard, or about how to do sound synthesis in MATLAB?
hckfb
hckfb on 20 Dec 2011
I ask how to interface a MIDI keyboard and how to do sound synthesis in MATLAB
Jan
Jan on 20 Dec 2011
MIDI?! You asked for a GUI ask keyboard at first. MIDI is another story.
hckfb
hckfb on 20 Dec 2011
http://www.mathworks.com/matlabcentral/fileexchange/21262-matlab-piano
I need same thing but it not needed to complex

Sign in to comment.

Answers (2)

Jan
Jan on 19 Dec 2011

0 votes

As I've answered in your former question: If you ask Google, you find some very well implementations of piano keyboards in Matlab. You can also search in the FileExchange pages.
I did not post the links directly, to give you a chance to find them by your own.

8 Comments

hckfb
hckfb on 20 Dec 2011
I have already done. There are a few piano but I don't understand exactly. There are only m-file and I don't understand which button is correspond which callback so I don't understand how my piano play sound.
Jan
Jan on 20 Dec 2011
What exactly is your question?
hckfb
hckfb on 20 Dec 2011
I want make a matlab gui but I don't know what I write to callback
Walter Roberson
Walter Roberson on 20 Dec 2011
If you are using GUIDE, the callback function will be created automatically and you will merely (!) need to add the calls to the sound synthesis routines to those callbacks.
If you are not using GUIDE, then when you create the uicontrol, specify the name of a routine in the 'Callback' parameter, such as
blackkey5 = uicontrol('Style','pushbutton','Callback', {@keypushed,'b5'}, 'Position', [....]);
and
function keypushed(src, evt, keyid)
[...]
end
hckfb
hckfb on 20 Dec 2011
I using guide. Yes, the callback function will be created automatically but I don't know what I add the calls to the sound synthesis routines to those callbacks.
Thank you.
Walter Roberson
Walter Roberson on 20 Dec 2011
You could start by creating the GUI and setting the callbacks to things like
pianokey(w11)
and have
function pianokey(keyid)
keyname = keyname(keyid);
note = keynote(keyid);
fprintf(1, 'Pressed key #%d, %s, note %s\n', keyid, keyname, note);
end
This will allow you to get your GUI all nicely arranged and will allow you to test the callbacks to be sure that each pushbutton connects to the proper note.
(You would have to build the keyname() and keynote() functions.)
hckfb
hckfb on 20 Dec 2011
http://www.mathworks.com/matlabcentral/fileexchange/21262-matlab-piano
I need same thing but it not needed to complex
Walter Roberson
Walter Roberson on 20 Dec 2011
Might as well start with your GUI, and use dummy callback routines like I show above.
Sound synthesis is not a small topic; if you want to do it, you will need to research it and figure out what you want to implement. Keeping in mind, of course, that imitating force or velocity sensitive keys, or even just figuring out when a key is released, is going to require some cleverness on your part.

Sign in to comment.

Walter Roberson
Walter Roberson on 20 Dec 2011

0 votes

2 Comments

hckfb
hckfb on 20 Dec 2011
http://www.mathworks.com/matlabcentral/fileexchange/21262-matlab-piano
I need same thing but it not needed to complex
Jan
Jan on 21 Dec 2011
It is *your* final project. Therefore it is *your* turn, to simplify the program.

Sign in to comment.

Categories

Find more on Just for fun in Help Center and File Exchange

Asked:

on 19 Dec 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!