當前位置: 首頁>>代碼示例>>Java>>正文


Java MidiSystem.getMidiFileTypes方法代碼示例

本文整理匯總了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");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:MidiFileTypeUniqueness.java

示例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(); }
}
 
開發者ID:Sciss,項目名稱:abc4j,代碼行數:24,代碼來源:PlayerApp.java

示例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];
}
 
開發者ID:softelnet,項目名稱:sponge,代碼行數:15,代碼來源:MidiUtils.java

示例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);
}
 
開發者ID:d2fn,項目名稱:passage,代碼行數:15,代碼來源:Player.java

示例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;
}
 
開發者ID:Xenoage,項目名稱:Zong,代碼行數:12,代碼來源:MidiScoreFileOutput.java


注:本文中的javax.sound.midi.MidiSystem.getMidiFileTypes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。