如何设置MIDI声像?

发布于 2024-11-27 21:30:16 字数 446 浏览 0 评论 0原文

谁能建议我如何设置 MIDI 声音的平移。我正在使用java MIDI合成并且可以使其发声。但我希望声音从左扬声器平移到右扬声器。我谷歌了一下,但我似乎不太清楚?这是我正在处理的代码示例:

Synthesizer synthesizer = MidiSystem.getSynthesizer();

synthesizer.open();

MidiChannel channel = synthesizer.getChannels()[0];

Soundbank soundbank = synthesizer.getDefaultSoundbank();

synthesizer.loadAllInstruments(soundbank);

channel.programChange(0,instrument);
channel.noteOn(60,200);`

我非常感谢您的帮助。 非常感谢!

Can anyone please suggest me how to set panning for a MIDI sound. I am using java MIDI synthesis and can make it sound. But I want the sound to pan from left to right speakers. I did google but it seemed not to clear to me much? Here the example of code I am working on:

Synthesizer synthesizer = MidiSystem.getSynthesizer();

synthesizer.open();

MidiChannel channel = synthesizer.getChannels()[0];

Soundbank soundbank = synthesizer.getDefaultSoundbank();

synthesizer.loadAllInstruments(soundbank);

channel.programChange(0,instrument);
channel.noteOn(60,200);`

I am very grateful for any help.
Thanks much!

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

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

发布评论

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

评论(1

_畞蕅 2024-12-04 21:30:16

根据 MIDI 规范,平移由 Control Change 消息编号 10 控制。这是“粗略”值(7 位精度),但显然“精细”14 位版本(控制更改 42)是 可能会被真实设备忽略

知道了这一点,您应该能够使用 JavaSound MidiChannel API 控制平移:

final int PAN_CONTROLLER = 10; 
// Pan to Center:
channel.controlChange(PAN_CONTROLLER, 64);

// Pan hard left:
channel.controlChange(PAN_CONTROLLER, 0);

// Pan hard right:
channel.controlChange(PAN_CONTROLLER, 127);

// "Active stereo", Jimi-Hendrix-style
// sweep from almost-full left to almost-full right:
for (int position = 8; position < 127; position += 8) {
    channel.controlChange(PAN_CONTROLLER, position);
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {
    }
}

According to the MIDI spec, panning is controlled by Control Change message number 10. This is the "coarse" value (7 bits of precision) but apparently the "fine" 14-bit version (control change 42) is likely to be ignored by real devices.

Knowing this, you should be able to use the controlChange(int, int) method in the JavaSound MidiChannel API to control your panning:

final int PAN_CONTROLLER = 10; 
// Pan to Center:
channel.controlChange(PAN_CONTROLLER, 64);

// Pan hard left:
channel.controlChange(PAN_CONTROLLER, 0);

// Pan hard right:
channel.controlChange(PAN_CONTROLLER, 127);

// "Active stereo", Jimi-Hendrix-style
// sweep from almost-full left to almost-full right:
for (int position = 8; position < 127; position += 8) {
    channel.controlChange(PAN_CONTROLLER, position);
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文