java - 我在哪里可以获得 BigClip?

标签 java audio

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

我的问题是我在哪里可以获得该类(class)..我注意到它没有附带普通的 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);
    }


   }        

最佳答案

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

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

关于java - 我在哪里可以获得 BigClip?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7080946/

相关文章:

java - 自动提交错误模式java

java - 卡在java中播放wav文件上......需要一些指导

actionscript-3 - 识别Action Script 3中的声音

android - 锁定屏幕上的Android锁定屏幕/媒体控件

javascript - html5/javascript 音频同时播放多首轨道

Java,按自定义字母顺序对arraylist进行排序

java - Spring,SockJS - WebSocket 握手期间出错 : Unexpected response code 400

java - 如何在 Apache Tomcat 8 中创建子域

java - 无法让登录应用程序工作

javascript - 如何在 Android 中播放歌曲 - phonegap