画钢琴

发布于 2024-09-01 02:48:17 字数 132 浏览 11 评论 0原文

我已经开始研究软件合成器(或键盘)。由于可用的 Jfugue API,我决定使用 Java。我试图弄清楚如何创建键盘用户界面的实际按键(注释),但我陷入困境。我尝试通过将黑白矩形按钮拖放到面板上来创建界面,但这似乎不起作用。有人能指出我正确的方向吗?

I have started working on a software synthesizer (or keyboard). I have decided to use Java because of the available Jfugue API. I am trying to figure out how to go about creating the actual keys (notes) of the keyboard user interface, but I am stuck. I have tried to create an interface by dragging/dropping black and white rectangular buttons onto the panel, but that doesn't seem to work. Could someone point me into the right direction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

随梦而飞# 2024-09-08 02:48:17

查看此帖子的回复 9,了解简单的钢琴键盘这应该可以帮助你开始。您可能需要从头开始阅读该帖子,了解如何处理每个按钮所代表的注释。

Check out reply 9 of this posting for a simple piano keyboard that should get you started. You may want to read the posting from the beginning for ideas on how to handle the note represented by each button.

伊面 2024-09-08 02:48:17

如果您使用 Java/swing,最好的选择是绘制键盘图像并将单击位置映射到各个键盘按键。

If you're using Java/swing, your best bet would be to draw an image of a keyboard and map click locations to the individual keyboard keys.

上课铃就是安魂曲 2024-09-08 02:48:17

我曾经不得不做类似的事情......我发现的最好的解决方案是绘制面板并将其边框和背景设置为键。然后,我使用鼠标侦听器来确定单击了哪个面板以及单击的持续时间。

I once had to do something similar... the best solution I found was to draw panels and set their border and background as keys. I then used mouse listeners to determine which panel was clicked and the duration of the click.

慕巷 2024-09-08 02:48:17

我认为这就是您想要的:

  1. 创建一个扩展 JPanel 的类
  2. 重写paint() 方法来绘制钢琴键
  3. 实现 MouseListener 和 MouseMotionListener,并知道用户何时在某些键上单击鼠标
  4. 使用 JFugue 中的 StreamingPlayer 来播放动态注释

我是 JFugue 的作者,我还想开始一个额外的工作,JFugueUI,它将提供诸如图形键盘之类的东西,人们可以将其包含在自己的应用程序中 - 所以,如果您愿意,请告诉我有兴趣贡献!

I think this is what you want to:

  1. Create a class that extends JPanel
  2. Override the paint() method to draw the piano keys
  3. Implement MouseListener and MouseMotionListener, and know when the user has clicked the mouse over certain keys
  4. Use the StreamingPlayer in JFugue to play notes dynamically

I'm the author of JFugue, and I've also wanted to start a side-effort, JFugueUI, that would provide things like graphical keyboards that people could include in their own applications - so, let me know if you're interested in contributing!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文