C#键盘监听器 [英] C# Keyboard Listener

查看:90
本文介绍了C#键盘监听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一:抱歉我的英语不好!



现在我的问题。



我正在尝试为键盘编写程序。



示例:如果我按音乐键盘上的C,程序显示C(通过麦克风输入)

我知道可以编写吉他调音器...



我希望你理解我的意思。





感谢您的阅读





Fabian

First: Sorry about my bad English!

Now my Question.

I am Trying to write a program for a Keyboard.

Example: If i Press the C on a Music Keyboard, and the Program Shows a C (via Microphone Input)
I know it possible to program a Guitar Tuner...

I hope you understand what i mean.


Thanks for reading


Fabian

推荐答案

最简单的方法是将音符作为单独的WAV或MP3文件保存 - 对于吉他调音器,你需要少量的音符 - 并且在按键上播放它们。 />


如果将它们保存为WAV文件,您可以将它们添加到您的应用程序资源中,并轻松播放它们:

The easiest way is to hold the notes as individual WAV or MP3 files - for a Guitar tuner where you need a small number of notes that is fine - and play them on the keystroke.

If you save them as WAV files, you can add them to your application Resources, and play them very easily:
SoundPlayer keyOfC= new SoundPlayer(Properties.Resources.NoteC);
keyOfC.Play();





除此之外,还有Console.Beep - 但它可能不适用于所有操作系统 - 它允许您指定频率和持续时间:



Beyond that, there is Console.Beep - but it may not work in all OS's - it allows you to specify the frequency and duration:

Console.Beep(261, 10000);

将播放C十秒钟


您是说要按一个音符 - 在你的.NET应用程序中键入MIDI键盘,如mid-C,并以某种形式显示中间C音符?



如果你使用的话MIDI键盘,请参阅:[ ^ ]。



请清楚说明您在使用术语时所指的内容:键盘。
Are you saying that you want to press a note-key on a MIDI keyboard, like middle-C, and have a middle-C note shown in some form, in your .NET application ?

If you are using a MIDI keyboard, see: [^].

Please clarify exactly what you refer to when you use the term: "keyboard."


这篇关于C#键盘监听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆