Removed the lwjgl dependency in faver of bcl, also on repo.or.cz.
[alterverse.git] / src / org / alterverse / sound / SoundManager.java
blobd7cfeb2c58fdaf1c1a19f609e0082a1d848fe8a7
1 /***************************************************************************
2 * Copyright (C) 2010 by the Alterverse team *
3 * email: rynkruger@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write see: *
17 * <http://www.gnu.org/licenses/>. *
18 ***************************************************************************/
20 package org.alterverse.sound;
22 import java.util.ArrayList;
23 import bcl.bcl;
25 public class SoundManager {
26 static ArrayList<Sound> delsounds;
27 static boolean running;
28 static Thread runner;
30 public static void init() {
31 bcl.initAudio();
32 delsounds=new ArrayList<Sound>();
33 running=true;
34 Thread runner=new Thread() {
35 public void run() {
36 while (running) {
37 for (int i = 0; i < delsounds.size();i++)
38 if (! delsounds.get(i).isPlaying()) {
39 delsounds.get(i).destroy();
40 delsounds.remove(delsounds.get(i));
41 i--;
43 try {
44 Thread.sleep(300);} catch(Exception x) {
45 x.printStackTrace();
51 runner.start();
54 public static void setListenerPosition(double x, double y, double z) {
55 bcl.setListenerPosition((float) x, (float) y, (float) z);
59 public void setListenerOrientation(double fx, double fy, double fz, double ux, double uy, double uz) {
60 FloatBuffer ori = BufferUtils.createFloatBuffer(6).put(new float[] {(float) fx,(float) fy,(float) fz,(float) ux,(float) uy,(float) uz});
61 ori.flip();
62 AL10.alListener(AL10.AL_ORIENTATION,ori);
66 public static void removeSound(Sound sound) {
67 delsounds.add(sound);
70 public static void terminate() {
71 bcl.terminateAudio();
72 running = false;