Android:将自定义 Midi Instruments DLS 文件加载到 Sonivox EAS 中

问题描述 投票:0回答:1

我正在使用流行的 billthefarmer 驱动程序包 创建一个 Android midi 应用程序。在 this 线程中 Markus Kauppinen 的帮助下,我能够使我的应用程序成功生成和控制 MIDI 事件(注释、暂停等)。

你们中的一些人可能知道,Sonivox EAS Android 库中包含的默认 GM1 乐器听起来并不是最好的。对于我的应用程序,我希望有一种将自定义乐器加载到合成器中的方法,例如萨克斯管的特定型号。

我发现了 5 年前的这个帖子,问我如何做同样的事情。该问题的答案建议使用 EAS.h 库中的 EAS_LoadDLSCollection() 方法。不幸的是,程序员只能找到一种将自定义 DLS 文件加载到库中的方法,而不能真正生成可演奏乐器的声音字体(术语错误?),可以通过它来演奏音符。

任何人都可以阐明如何通过原生 Sonivox EAS Midi 库在 Android 中加载和使用自定义乐器吗?

android audio midi
1个回答
0
投票

加载DLS文件代码

#include <EAS.h>

// Assuming `pEASData` is the initialized EASData handle, and `dlsFilePath` is the path to your DLS file.
EAS_RESULT result;
EAS_HANDLE dlsHandle;
result = EAS_LoadDLSCollection(pEASData, dlsFilePath, &dlsHandle);
if (result == EAS_SUCCESS) {
    // DLS file loaded successfully, you can now play MIDI with custom instruments.
}

在 FluidSynth 中加载 SF2 声音字体的示例代码

#include <fluidsynth.h>

// Create the synthesizer and settings
fluid_settings_t* settings = new_fluid_settings();
fluid_synth_t* synth = new_fluid_synth(settings);

// Load the SF2 soundfont
int soundfont_id = fluid_synth_sfload(synth, "path/to/soundfont.sf2", 1);
if (soundfont_id == -1) {
    printf("Error loading soundfont\n");
}

// Play a MIDI note using the soundfont
fluid_synth_noteon(synth, 0, 60, 127);  // Channel 0, note 60 (Middle C), velocity 127

检查一下你的问题就会解决。

© www.soinside.com 2019 - 2024. All rights reserved.