是否有一个函数可以返回FluidSynth中声音字体文件中所有乐器的列表(预置名称),或者至少返回每个声库中预设的数量?
发布于 2014-06-24 18:51:41
这并不是完全“非迭代”,但这是唯一的方法,我可以找到一个列表的所有预设在一个声音字体文件。
fluid_preset_t* preset = new fluid_preset_t();
// Reset the iteration
sf->iteration_start(sf);
// Go through all the presets within the soundfont
int more = 1;
while (more) {
more = sf->iteration_next(sf, preset); // Will return 0 if no more soundfonts left
if (more) {
// Get preset name
char* presetname = preset->get_name(preset);
int banknum = preset->get_banknum(preset);
int num = preset->get_num(preset);
// Do something with the presetname, bank number and program number
// Such as add it to some list so that you can refer to it later
}
}..。其中sf是一个声音字体对象。
在查看http://fluidsynth.sourceforge.net/api/index.html的API文档时发现了这一点。请注意顶部的菜单上有指向数据结构、文件等的链接。
发布于 2013-10-01 21:33:18
我能够使用流体合成获得工具名称和银行。您要发送的命令是"inst 1“(获取加载在位置1中的声音字体的所有仪器)。
$ echo "inst 1" | fluidsynth /path/to/FluidR3_GM.sf2
FluidSynth version 1.1.6
Copyright (C) 2000-2012 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of E-mu Systems, Inc.
Type 'help' for help topics.
000-000 Yamaha Grand Piano
000-001 Bright Yamaha Grand
000-002 Electric Piano
000-003 Honky Tonk
000-004 Rhodes EP
000-005 Legend EP 2
000-006 Harpsichord
000-007 Clavinet
...
...
...
128-035 Jazz 3
128-036 Jazz 4
128-040 Brush
128-041 Brush 1
128-042 Brush 2
128-048 Orchestra Kit发布于 2021-09-01 16:45:18
我试过这个:
static void inspectsoundfont()
{
fluid_sfont_t* sfont = fluid_synth_get_sfont_by_id(synth, font_id);
for (int bank = 0; bank < 16384; bank++)
{
for (int num = 0; num < 128; num++)
{
fluid_preset_t* preset = fluid_sfont_get_preset(sfont, bank, num);
if (preset == nullptr)
continue;
const char* name = fluid_preset_get_name(preset);
std::cout << "bank: " << bank << " index: " << num << " " << name << std::endl;
}
}
}synth是合成器对象,font_id来自fluid_synth_sfload。给了我一张银行名单和预置的名字。
https://stackoverflow.com/questions/18302596
复制相似问题