是否有一个函数可以返回FluidSynth中声音文件中所有乐器(预设名称)的列表,或至少返回每个音库中预设的数量?
答案 0 :(得分:6)
我能够使用fluidsynth获取乐器名称和银行。您要发送的命令是“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
答案 1 :(得分:0)
这不完全"非迭代",但它是我能找到的唯一方法来获取声音文件中所有预设的列表。
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文档时发现了这一点。请注意顶部的菜单,其中包含指向数据结构,文件等的链接