Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can I press on a key in a midi keyboard and know which key was pressed and play the note by c#? Thank you very much
Posted
Updated 29-Dec-15 22:59pm
v2
Comments
BillWoodruff 30-Dec-15 4:41am    
You start by moving your hands off the midi keyboard on to the computer keyboard, and doing research on CodeProject and the web on C# AND Midi. Then you come back with specific questions.

I'm guessing you can use this: Wrapper Library for Windows MIDI API[^]

However, speaking from experience, the issue I found with that actually has to do with the latency of the output. The midi is fine, but without using ASIO the audio is noticeably delayed as soon as you do *any* significant processing on the audio and that makes it impossible to create any kind of reasonable audio app in C#

However, there are other options, all with drawbacks and advantages. Synthmaker - now Flowstone is excellent for simple coding of surprisingly intricate VSTs and FLStudio plugins but it's MIDI support is not great.

The best option I've found from experience is (and I don't like it admittedly) is to use C++. You can rely on the STL and even boost libraries to help you along - and I recommend it, particularly if you're doing MIDI because containers and iterators are the order of the day if you're doing any midi sequencing in C++.
 
Share this answer
 
You can use some 3r-party .NET library which wraps MIDI functionality with the capability to handle MIDI input events.
See, for example,
https://code.google.com/p/midi-dot-net/wiki/SimpleExamples[^].

See also this CodeProject article: C# MIDI Toolkit[^].

I personally did not work with MIDI input yet, only used MIDI output, but I have MIDI hardware and planned to get to this field of activity one day, so I don't know how bad is the latency problem, but I cannot agree that it can be related to software processing — it can be done too fast to be noticeable, but I don't know how bad hardware latency can be. In some USB-based hardware (I don't mean MIDI), I observed latency of few milliseconds. I guess it depends on the hardware interface you use.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900