我在哪里可以获得BigClip?

时间:2011-08-16 15:41:17

标签: java audio

我做了这个与剪辑一起使用的声音类,我注意到了大文件的问题。我看到人们一直在谈论一个名为BigClip的类 这与Clip只能处理大文件相同......

我的问题是我在哪里可以获得该课程...我注意到它没有普通的Java XD 以及如何将其实现到我的代码中..

这是我的代码:

package org.game.engine;

import java.io.File;
import java.io.IOException;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;

//Declaring all the fields
public class SoundEngine {
private Clip clip;
private  AudioInputStream sound;
private boolean stoped = false;
private DataLine.Info info;
private File soundFile;

//Constructor for a sound
 public SoundEngine(String filename) throws Exception {

// specify the sound to play
soundFile = new File(filename);
sound = AudioSystem.getAudioInputStream(soundFile);

// load the sound into a clip
info = new DataLine.Info(Clip.class, sound.getFormat());
clip = (Clip) AudioSystem.getLine(info);
System.out.println( Integer.toString(clip.getBufferSize()));
clip.open(sound);
}


    //Method do start/play the sound once
    public void start() throws LineUnavailableException, IOException, UnsupportedAudioFileException{
        if (stoped) {
             sound = AudioSystem.getAudioInputStream(soundFile);
             info = new DataLine.Info(Clip.class, sound.getFormat());
             clip = (Clip) AudioSystem.getLine(info);
             clip.open(sound);
             stoped = false;
        }
        clip.start();
    }


    //Method do pause the sound
    public void pause() {
        clip.stop();
    }



    //Method to fully stop the sound
    public void stop() {
        //make sure sound reloads it self because of the full stop
        stoped = true;
        //closes and drains
        clip.close();
        clip.drain();  
    }



    //Methd for looping sounds
    public void loop() throws UnsupportedAudioFileException, LineUnavailableException, IOException {
          if (stoped) {
              //reloads the sound incase the sound is fully stoped
                     sound = AudioSystem.getAudioInputStream(soundFile);
                     info = new DataLine.Info(Clip.class, sound.getFormat());
                     clip = (Clip) AudioSystem.getLine(info);
                     clip.open(sound);
                     stoped = false;
          }
          //starts the looping
        clip.loop(Clip.LOOP_CONTINUOUSLY);
    }


   }        

1 个答案:

答案 0 :(得分:2)

BigClip的代码显示在answer to this question上。

有必要编译它以供您自己使用。没有预先构建的Jar可以添加到类路径中。 (好吧,有一个预先制作的Jar,但不是我提供给其他人使用的 - 酿造你自己的。)