本文整理汇总了Java中javax.sound.midi.MidiSystem.getMidiFileTypes方法的典型用法代码示例。如果您正苦于以下问题:Java MidiSystem.getMidiFileTypes方法的具体用法?Java MidiSystem.getMidiFileTypes怎么用?Java MidiSystem.getMidiFileTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.midi.MidiSystem
的用法示例。
在下文中一共展示了MidiSystem.getMidiFileTypes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
boolean foundDuplicates = false;
int[] aTypes = MidiSystem.getMidiFileTypes();
for (int i = 0; i < aTypes.length; i++)
{
for (int j = 0; j < aTypes.length; j++)
{
if (aTypes[i] == aTypes[j] && i != j) {
foundDuplicates = true;
}
}
}
if (foundDuplicates) {
throw new Exception("Test failed");
} else {
System.out.println("Test passed");
}
}
示例2: actionPerformed
import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e)
{
try
{
Tune t = m_tuneBookEditorPanel.getTuneEditArea().getTune();
if (t!=null)
{
JFileChooser chooser = new JFileChooser(lastDirectory);
int returnVal = chooser.showSaveDialog(m_parent);
File file = chooser.getSelectedFile();
if (file!=null)
{
MidiConverterAbstract conv = new BasicMidiConverter();
Sequence s = conv.toMidiSequence(t);
int[] types = MidiSystem.getMidiFileTypes(s);
if (types.length>0)
MidiSystem.write(s,types[0],file);
}
}
}
catch (IOException excpt)
{ excpt.printStackTrace(); }
}
示例3: getFirstSupportedMidiFileType
import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
/**
* Returns the first supported MIDI file type.
*
* @param sequence the sequence;
* @return the supported MIDI file type.
*/
public static int getFirstSupportedMidiFileType(Sequence sequence) {
int[] fileTypes = MidiSystem.getMidiFileTypes(sequence);
if (fileTypes.length == 0) {
throw new SpongeException("No supported MIDI file format");
}
return fileTypes[0];
}
示例4: saveMidi
import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
/**
* Saves the MIDI data from a pattern into a file.
* @param pattern the pattern to save
* @param file the File to save the pattern to. Should include file extension, such as .mid
*/
public void saveMidi(Pattern pattern, File file) throws IOException
{
Sequence sequence = getSequence(pattern);
int[] writers = MidiSystem.getMidiFileTypes(sequence);
if (writers.length == 0) return;
MidiSystem.write(sequence, writers[0], file);
}
示例5: getPreferredMidiType
import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
/**
* Gets the preferred MIDI type. This is a "Standard-MIDI-File Type 1" file.
*/
public static int getPreferredMidiType(Sequence sequence) {
int[] types = MidiSystem.getMidiFileTypes(sequence);
int type = 0;
if (types.length != 0) {
type = types[types.length - 1];
}
return type;
}