I need to get the notes, timestamp, and instrument list and all, from general MIDI files.
Almost everything is done, but I also need each instrument corresponding to each track otherwise the notes are useless if I don't know which instrument they belong to.
It seems that this is done by getting the patch list, a patch has the instrument code in a soundbank used by the MIDI sequence.
This seems straight forward, but when I try to use getPatchList()
on a Sequence
object it returns an empty array.
The problem?: it seems like this was never actually implemented in the java MIDI library (??), at least from what I found:
/**
* Get an array of patches used in this sequence.
*
* @return an array of patches used in this sequence
*/
public Patch[] getPatchList()
{
// FIXE: not quite sure how to do this yet.
throw new UnsupportedOperationException("Can't get patch list yet");
}
source: javax.sound.midi.Sequence
Aparently the Android developers couldn't figure it out either. Note this is a normal java program, nothing to do with Android:
public Patch[] getPatchList() {
//FIXME
/*
* I don't understand how to works this method, and so
* I simply return an empty array. 'patches' initializes
* in the constructor as empty vector
*/
Patch[] patch = new Patch[patches.size()];
patches.toArray(patch);
return patch;
}
source: javax.sound.midi.Sequence
So is there anything that can be done about this at all?
Is there another way to get the instruments?
Why is this not implemented?
Did no one actually ever need this since 2005?
答案 0 :(得分:1)
要让MIDI设备选择乐器,您可以向其发送程序变更信息(这也会考虑Bank Select控制器的当前设置)。
要获取序列中所有补丁的列表,请查看所有邮件列表,并收集所有程序编号(以及当时生效的所有银行编号)。
如果您的实施没有这样做,您必须手动执行此操作。