Matlab Piano
Show older comments
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
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
on 20 Dec 2011
Jan
on 20 Dec 2011
MIDI?! You asked for a GUI ask keyboard at first. MIDI is another story.
hckfb
on 20 Dec 2011
Answers (2)
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
on 20 Dec 2011
Jan
on 20 Dec 2011
What exactly is your question?
hckfb
on 20 Dec 2011
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
on 20 Dec 2011
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
on 20 Dec 2011
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.
Walter Roberson
on 20 Dec 2011
0 votes
MIDI: see
Sound synthesis: see
Categories
Find more on Just for fun in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!