コード例 #1
1
 public MidiFileFormat getMidiFileFormat(URL url) throws InvalidMidiDataException, IOException {
   InputStream inputStream = url.openStream();
   try {
     return getMidiFileFormat(inputStream);
   } finally {
     inputStream.close();
   }
 }
コード例 #2
1
 public MidiFileFormat getMidiFileFormat(File file) throws InvalidMidiDataException, IOException {
   InputStream inputStream = new FileInputStream(file);
   // inputStream = new BufferedInputStream(inputStream, 1024);
   try {
     return getMidiFileFormat(inputStream);
   } finally {
     inputStream.close();
   }
 }
コード例 #3
1
ファイル: MidiPlayer.java プロジェクト: ramp818/LightOuts2
 /**
  * Loads a sequence from an input stream. Returns null if an error occurs.
  *
  * @param is
  * @return
  */
 public Sequence getSequence(InputStream is) {
   try {
     if (!is.markSupported()) {
       is = new BufferedInputStream(is);
     }
     Sequence s = MidiSystem.getSequence(is);
     is.close();
     return s;
   } catch (InvalidMidiDataException ex) {
     ex.printStackTrace();
     return null;
   } catch (IOException ex) {
     ex.printStackTrace();
     return null;
   }
 }
コード例 #4
1
ファイル: SoundManager.java プロジェクト: tmackgit/GameDev
    public void run() {
      // get line and buffer from ThreadLocals
      SourceDataLine line = (SourceDataLine) localLine.get();
      byte[] buffer = (byte[]) localBuffer.get();
      if (line == null || buffer == null) {
        // the line is unavailable
        return;
      }

      // copy data to the line
      try {
        int numBytesRead = 0;
        while (numBytesRead != -1) {
          // if paused, wait until unpaused
          synchronized (pausedLock) {
            if (paused) {
              try {
                pausedLock.wait();
              } catch (InterruptedException ex) {
                return;
              }
            }
          }
          // copy data
          numBytesRead = source.read(buffer, 0, buffer.length);
          if (numBytesRead != -1) {
            line.write(buffer, 0, numBytesRead);
          }
        }
      } catch (IOException ex) {
        ex.printStackTrace();
      }
    }
コード例 #5
1
 public Sequence getSequence(URL url) throws InvalidMidiDataException, IOException {
   InputStream inputStream = url.openStream();
   try {
     return getSequence(inputStream);
   } catch (InvalidMidiDataException e) {
     if (TDebug.TraceAllExceptions) {
       TDebug.out(e);
     }
     inputStream.close();
     throw e;
   } catch (IOException e) {
     if (TDebug.TraceAllExceptions) {
       TDebug.out(e);
     }
     inputStream.close();
     throw e;
   }
 }
コード例 #6
1
 public Sequence getSequence(File file) throws InvalidMidiDataException, IOException {
   InputStream inputStream = new FileInputStream(file);
   // inputStream = new BufferedInputStream(inputStream, 1024);
   try {
     return getSequence(inputStream);
   } catch (InvalidMidiDataException e) {
     if (TDebug.TraceAllExceptions) {
       TDebug.out(e);
     }
     inputStream.close();
     throw e;
   } catch (IOException e) {
     if (TDebug.TraceAllExceptions) {
       TDebug.out(e);
     }
     inputStream.close();
     throw e;
   }
 }
コード例 #7
1
ファイル: SoundManager.java プロジェクト: tmackgit/GameDev
  /** Creates an AudioInputStream from a sound from an input stream */
  public AudioInputStream getAudioInputStream(InputStream is) {

    try {
      if (!is.markSupported()) {
        is = new BufferedInputStream(is);
      }
      // open the source stream
      AudioInputStream source = AudioSystem.getAudioInputStream(is);

      // convert to playback format
      return AudioSystem.getAudioInputStream(playbackFormat, source);
    } catch (UnsupportedAudioFileException ex) {
      ex.printStackTrace();
    } catch (IOException ex) {
      ex.printStackTrace();
    } catch (IllegalArgumentException ex) {
      ex.printStackTrace();
    }

    return null;
  }