コード例 #1
0
  public SonarSoundEngine(int maxChannels) throws LineUnavailableException {
    silentSample = new SonarSample(new float[] {0}, 44100);
    Mixer mixer = AudioSystem.getMixer(null);

    sdl = (SourceDataLine) mixer.getLine(new Line.Info(SourceDataLine.class));
    sdl.open(new AudioFormat(rate, 16, 2, true, false), bufferSize * 2 * 2 * 2 * 2 * 2);
    soundBuffer.order(ByteOrder.LITTLE_ENDIAN);
    sdl.start();

    try {
      /*            FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
      volumeControl.setValue(volumeControl.getMaximum());*/
    } catch (IllegalArgumentException e) {
      // System.out.println("Failed to set the sound volume");
    }

    listenerMixer = new ListenerMixer(maxChannels);

    leftBuf = new float[bufferSize];
    rightBuf = new float[bufferSize];

    Thread thread = new Thread(this);
    thread.setDaemon(true);
    thread.setPriority(10);
    thread.start();
  }
コード例 #2
0
ファイル: Senso.java プロジェクト: zale90/hg78ijavaprojects
 public void start(Game.Spiel senso) {
   this.setVisible(true);
   // new Senso();
   s = senso;
   neustarten(true);
   läuft = true;
   spiel = new Thread(this);
   spiel.start();
 }
コード例 #3
0
  public AudioPlayer(final JFrame frame) {
    clipListener =
        new LineListener() {
          public void update(LineEvent event) {
            if (event.getType() != STOP) return;

            clip.removeLineListener(clipListener);
            clip = null;

            synchronized (notificationMutex) {
              playing = false;
              notificationMutex.notifyAll();
            }
          }
        };

    worker =
        new Thread(
            new Runnable() {
              public void run() {
                while (true) {
                  synchronized (notificationMutex) {
                    try {
                      notificationMutex.wait(1000);
                    } catch (InterruptedException e) {
                      // ignore this
                    }

                    if (!running) return;
                    if (playing) continue;
                  }

                  File file = null;
                  try {
                    file = queue.poll();
                    if (file != null) playNext(file);
                  } catch (Exception e) {
                    log.severe(
                        format("Cannot play audio file %s: %s", file, getLocalizedMessage(e)));
                    showMessageDialog(
                        frame,
                        MessageFormat.format(
                            Application.getInstance()
                                .getContext()
                                .getBundle()
                                .getString("cannot-play-voice"),
                            file,
                            e),
                        frame.getTitle(),
                        ERROR_MESSAGE);
                  }
                }
              }
            },
            "AudioPlayer");
    worker.start();
  }
コード例 #4
0
 private static synchronized void ckpl() {
   if (enabled) {
     if (player == null) {
       player = new Player();
       player.start();
     }
   } else {
     ncl.clear();
   }
 }
コード例 #5
0
ファイル: MusicPlayer.java プロジェクト: redclock/Adv-Game
 /** 开始音乐线程 */
 public void start() {
   // midi和wav需要不同的方法
   if (m_midi == null) {
     musicThread = new Thread(this);
     musicThread.start();
     m_stopped = false;
   } else {
     m_midi.InitSequence(m_filename);
     m_midi.play(m_looped);
   }
 }
コード例 #6
0
ファイル: Spaceship.java プロジェクト: LukeJHarvey/SpaceShip
 sound(String _name) {
   soundFile = new File(_name);
   myThread = new Thread(this);
   myThread.start();
 }
コード例 #7
0
ファイル: Spaceship.java プロジェクト: LukeJHarvey/SpaceShip
 public void start() {
   if (relaxer == null) {
     relaxer = new Thread(this);
     relaxer.start();
   }
 }