当前位置: 首页>>代码示例>>Java>>正文


Java MidiFileFormat类代码示例

本文整理汇总了Java中javax.sound.midi.MidiFileFormat的典型用法代码示例。如果您正苦于以下问题:Java MidiFileFormat类的具体用法?Java MidiFileFormat怎么用?Java MidiFileFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MidiFileFormat类属于javax.sound.midi包,在下文中一共展示了MidiFileFormat类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMidiFileFormat

import javax.sound.midi.MidiFileFormat; //导入依赖的package包/类
public MidiFileFormat getMidiFileFormat(File file) throws InvalidMidiDataException, IOException {
    FileInputStream fis = new FileInputStream(file); // throws IOException
    BufferedInputStream bis = new BufferedInputStream(fis, bisBufferSize);

    // $$fb 2002-04-17: part of fix for 4635286: MidiSystem.getMidiFileFormat() returns format having invalid length
    long length = file.length();
    if (length > Integer.MAX_VALUE) {
        length = MidiFileFormat.UNKNOWN_LENGTH;
    }
    MidiFileFormat fileFormat = null;
    try {
        fileFormat = getMidiFileFormatFromStream(bis, (int) length, null);
    } finally {
        bis.close();
    }
    return fileFormat;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:StandardMidiFileReader.java

示例2: getSequence

import javax.sound.midi.MidiFileFormat; //导入依赖的package包/类
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:StandardMidiFileReader.java

示例3: getMidiFileFormat

import javax.sound.midi.MidiFileFormat; //导入依赖的package包/类
@Override
public MidiFileFormat getMidiFileFormat(File file) throws InvalidMidiDataException, IOException {
    FileInputStream fis = new FileInputStream(file); // throws IOException
    BufferedInputStream bis = new BufferedInputStream(fis, bisBufferSize);

    // $$fb 2002-04-17: part of fix for 4635286: MidiSystem.getMidiFileFormat() returns format having invalid length
    long length = file.length();
    if (length > Integer.MAX_VALUE) {
        length = MidiFileFormat.UNKNOWN_LENGTH;
    }
    MidiFileFormat fileFormat = null;
    try {
        fileFormat = getMidiFileFormatFromStream(bis, (int) length, null);
    } finally {
        bis.close();
    }
    return fileFormat;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:StandardMidiFileReader.java

示例4: getSequence

import javax.sound.midi.MidiFileFormat; //导入依赖的package包/类
@Override
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:StandardMidiFileReader.java

示例5: JavaSoundAudioClip

import javax.sound.midi.MidiFileFormat; //导入依赖的package包/类
public JavaSoundAudioClip(InputStream in) throws IOException {
    if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.<init>");

    BufferedInputStream bis = new BufferedInputStream(in, STREAM_BUFFER_SIZE);
    bis.mark(STREAM_BUFFER_SIZE);
    boolean success = false;
    try {
        AudioInputStream as = AudioSystem.getAudioInputStream(bis);
        // load the stream data into memory
        success = loadAudioData(as);

        if (success) {
            success = false;
            if (loadedAudioByteLength < CLIP_THRESHOLD) {
                success = createClip();
            }
            if (!success) {
                success = createSourceDataLine();
            }
        }
    } catch (UnsupportedAudioFileException e) {
        // not an audio file
        try {
            MidiFileFormat mff = MidiSystem.getMidiFileFormat(bis);
            success = createSequencer(bis);
        } catch (InvalidMidiDataException e1) {
            success = false;
        }
    }
    if (!success) {
        throw new IOException("Unable to create AudioClip from input stream");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:JavaSoundAudioClip.java

示例6: getMidiFileFormat

import javax.sound.midi.MidiFileFormat; //导入依赖的package包/类
public MidiFileFormat getMidiFileFormat(URL url)
  throws InvalidMidiDataException, IOException
{
  InputStream is = url.openStream();
  try
    {
      return getMidiFileFormat(is);
    }
  finally
    {
      is.close();
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:14,代码来源:MidiFileReader.java


注:本文中的javax.sound.midi.MidiFileFormat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。