|
From: Brian M. <ma...@us...> - 2004-06-09 19:50:18
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4708/test/fmod3 Added Files: CDDAPlayer.java CDPlayer.java MusicPlayer.java StreamPlayer.java SyncTest.java Log Message: fmod -> fmod3 --- NEW FILE: MusicPlayer.java --- /* * Copyright (c) 2004 LWJGL Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of 'LWJGL' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.lwjgl.test.fmod3; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import org.lwjgl.fmod3.FMOD; import org.lwjgl.fmod3.FMODException; import org.lwjgl.fmod3.FMusic; import org.lwjgl.fmod3.FMusicModule; import org.lwjgl.fmod3.FSound; /** * $Id: MusicPlayer.java,v 1.1 2004/06/09 19:50:09 matzon Exp $ * <br> * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ public class MusicPlayer { public static void main(String[] args) { if(args.length < 1) { System.out.println("Usage:\n MusicPlayer <file>"); return; } File file = new File(args[0]); if (!file.exists()) { System.out.println("No such file: " + args[0]); return; } try { FMOD.create(); } catch (FMODException fmode) { fmode.printStackTrace(); return; } System.out.println("Initializing FMOD"); if(!FSound.FSOUND_Init(44100, 32, 0)) { System.out.println("Failed to initialize FMOD"); return; } System.out.println("Loading " + args[0]); // choose either way of loading... // using name (path) FMusicModule module = FMusic.FMUSIC_LoadSong(args[0]); // using name (path), extended mode //FMusicModule module = FMusic.FMUSIC_LoadSongEx(args[0], 0, 0, 0, null); // using memory buffers //ByteBuffer data = getData(args[0]); //FMusicModule module = FMusic.FMUSIC_LoadSongEx(data, 0, data.remaining(), FSound.FSOUND_LOADMEMORY, null); if(module != null) { System.out.println("Loaded. Playing module of type: " + FMusic.FMUSIC_GetType(module)); FMusic.FMUSIC_PlaySong(module); System.out.println("Press enter to stop playing"); try { System.in.read(); } catch (IOException ioe) { } FMusic.FMUSIC_StopSong(module); System.out.println("Done playing. Cleaning up"); FMusic.FMUSIC_FreeSong(module); } else { System.out.println("Unable to play: " + args[0]); System.out.println("Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); } FSound.FSOUND_Close(); FMOD.destroy(); } /** * Reads the file into a ByteBuffer * * @param filename * Name of file to load * @return ByteBuffer containing file data */ static protected ByteBuffer getData(String filename) { ByteBuffer buffer = null; System.out.println("Attempting to load: " + filename); try { BufferedInputStream bis = new BufferedInputStream(StreamPlayer.class.getClassLoader().getResourceAsStream(filename)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int bufferLength = 4096; byte[] readBuffer = new byte[bufferLength]; int read = -1; while ((read = bis.read(readBuffer, 0, bufferLength)) != -1) { baos.write(readBuffer, 0, read); } //done reading, close bis.close(); // if ogg vorbis data, we need to pass it unmodified to alBufferData buffer = ByteBuffer.allocateDirect(baos.size()); buffer.order(ByteOrder.nativeOrder()); buffer.put(baos.toByteArray()); buffer.flip(); System.out.println("loaded " + buffer.remaining() + " bytes"); } catch (Exception ioe) { ioe.printStackTrace(); } return buffer; } } --- NEW FILE: StreamPlayer.java --- /* * Copyright (c) 2004 LWJGL Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of 'LWJGL' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.lwjgl.test.fmod3; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import org.lwjgl.fmod3.FMOD; import org.lwjgl.fmod3.FMODException; import org.lwjgl.fmod3.FSound; import org.lwjgl.fmod3.FSoundStream; /** * $Id: StreamPlayer.java,v 1.1 2004/06/09 19:50:09 matzon Exp $ <br> * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ public class StreamPlayer { public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage:\n StreamPlayer <file>"); return; } File file = new File(args[0]); if (!file.exists()) { System.out.println("No such file: " + args[0]); return; } try { FMOD.create(); } catch (FMODException fmode) { fmode.printStackTrace(); return; } System.out.println("Initializing FMOD"); if (!FSound.FSOUND_Init(44100, 32, 0)) { System.out.println("Failed to initialize FMOD"); System.out.println("Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); return; } System.out.println("Loading " + args[0]); FSoundStream stream = FSound.FSOUND_Stream_Open(args[0], FSound.FSOUND_NORMAL, 0, 0); if (stream != null) { FSound.FSOUND_Stream_Play(0, stream); System.out.println("Press enter to stop playing"); try { System.in.read(); } catch (IOException ioe) { } System.out.println("Done playing. Cleaning up"); FSound.FSOUND_Stream_Stop(stream); FSound.FSOUND_Stream_Close(stream); } else { System.out.println("Unable to play: " + args[0]); System.out.println("Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); } FSound.FSOUND_Close(); FMOD.destroy(); } /** * Reads the file into a ByteBuffer * * @param filename * Name of file to load * @return ByteBuffer containing file data */ static protected ByteBuffer getData(String filename) { ByteBuffer buffer = null; System.out.println("Attempting to load: " + filename); try { BufferedInputStream bis = new BufferedInputStream(StreamPlayer.class.getClassLoader().getResourceAsStream(filename)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int bufferLength = 4096; byte[] readBuffer = new byte[bufferLength]; int read = -1; while ((read = bis.read(readBuffer, 0, bufferLength)) != -1) { baos.write(readBuffer, 0, read); } //done reading, close bis.close(); // if ogg vorbis data, we need to pass it unmodified to alBufferData buffer = ByteBuffer.allocateDirect(baos.size()); buffer.order(ByteOrder.nativeOrder()); buffer.put(baos.toByteArray()); buffer.flip(); System.out.println("loaded " + buffer.remaining() + " bytes"); } catch (Exception ioe) { ioe.printStackTrace(); } return buffer; } /** * Creates a ByteBuffer buffer to hold specified bytes - strictly a utility * method * * @param size * how many bytes to contain * @return created ByteBuffer */ protected static ByteBuffer createByteBuffer(int size) { ByteBuffer temp = ByteBuffer.allocateDirect(4 * size); temp.order(ByteOrder.nativeOrder()); return temp; } } --- NEW FILE: CDDAPlayer.java --- /* * Copyright (c) 2004 LWJGL Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of 'LWJGL' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.lwjgl.test.fmod3; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; import org.lwjgl.fmod3.FMOD; import org.lwjgl.fmod3.FMODException; import org.lwjgl.fmod3.FSound; import org.lwjgl.fmod3.FSoundStream; /** * $Id: CDDAPlayer.java,v 1.1 2004/06/09 19:50:09 matzon Exp $ * <br> * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ public class CDDAPlayer { public static void main(String[] args) { try { FMOD.create(); } catch (FMODException fmode) { fmode.printStackTrace(); return; } System.out.println("Initializing FMOD"); if (!FSound.FSOUND_Init(44100, 32, 0)) { System.out.println("Failed to initialize FMOD"); return; } boolean running = true; String token = null; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); FSoundStream stream = null; do { System.out.println(FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); System.out.println("FMOD CD Player test. Press a key corresponding to action"); System.out.println("1: FSOUND_Stream_Open \"<drive>:\""); System.out.println("2: FSOUND_Stream_Open \"<drive>:?\""); System.out.println("3: FSOUND_Stream_Open \"<drive>:!\""); System.out.println("4: FSOUND_Stream_SetSubStream <position>"); System.out.println("5: FSOUND_Stream_GetNumSubStreams"); System.out.println("6: Enumerate tag fields"); System.out.println("0: Exit"); try { StringTokenizer st = new StringTokenizer(br.readLine().trim()); token = st.nextToken(); switch (Integer.parseInt(token)) { case 0: running = false; break; case 1: stream = FSound.FSOUND_Stream_Open(st.nextToken() + ":", FSound.FSOUND_NORMAL, 0, 0); break; case 2: stream = FSound.FSOUND_Stream_Open(st.nextToken() + ":*?", 0, 0, 0); break; case 3: stream = FSound.FSOUND_Stream_Open(st.nextToken() + ":*!", 0, 0, 0); break; case 4: FSound.FSOUND_Stream_SetSubStream(stream, Integer.parseInt(st.nextToken())); break; case 5: System.out.println(FSound.FSOUND_Stream_GetNumSubStreams(stream)); break; case 6: // break; default: System.out.println("No entry"); } System.out.println("Stream: " + stream); } catch (Exception e) { } } while (running); if(stream != null) { FSound.FSOUND_Stream_Close(stream); } FSound.FSOUND_Close(); FMOD.destroy(); } } --- NEW FILE: SyncTest.java --- /* * Copyright (c) 2004 LWJGL Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of 'LWJGL' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.lwjgl.test.fmod3; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; import org.lwjgl.BufferUtils; import org.lwjgl.Sys; import org.lwjgl.fmod3.FMOD; import org.lwjgl.fmod3.FMODException; import org.lwjgl.fmod3.FMusic; import org.lwjgl.fmod3.FMusicModule; import org.lwjgl.fmod3.FSound; import org.lwjgl.fmod3.callbacks.FMusicCallback; /** * $Id: SyncTest.java,v 1.1 2004/06/09 19:50:09 matzon Exp $ <br> * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ public class SyncTest { /** Path to file to play */ private String filePath; /** Module instance loaded */ private FMusicModule module; /** Whether test is running */ private boolean running = true; /** Current row */ private int row; /** Current order */ private int order; /** Number of orders in the song */ private int numOrders; /** * Creates a new SyncTest * @param string */ public SyncTest(String filePath) { this.filePath = filePath; // create thread to exit when a key has been pressed Thread t = new Thread() { public void run() { try { System.in.read(); } catch (IOException ioe) { } running = false; } }; t.setDaemon(true); t.start(); } /** * * @param args */ public static void main(String[] args) { // check for file existance File file = new File(args[0]); if (!file.exists()) { System.out.println("No such file: " + args[0]); return; } // initialize FMOD try { System.out.println("Initializing FMOD"); FMOD.create(); } catch (FMODException fmode) { fmode.printStackTrace(); return; } // start actual test SyncTest sync = new SyncTest(args[0]); sync.executeTest(); } /** * Executes the test */ public void executeTest() { // do setup setup(); // if we have a module - get going if (module != null) { // high priority... - might otherwise skip Sys.setProcessPriority(Sys.HIGH_PRIORITY); // go go go! run(); } // we're done - clean up destroy(); } /** * Setup FMOD */ private void setup() { if (!FSound.FSOUND_Init(44100, 32, 0)) { System.out.println("Failed to initialize FMOD"); System.out.println("Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); return; } // load module System.out.println("Loading " + filePath); module = FMusic.FMUSIC_LoadSong(filePath); if (module == null) { System.out.println("Unable to load " + filePath + ": " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); return; } // get number of orders numOrders = FMusic.FMUSIC_GetNumOrders(module); // install order callback FMusic.FMUSIC_SetOrderCallback(module, new FMusicCallback() { public void FMUSIC_CALLBACK(FMusicModule module, int param) { order = param; } }, 1); // install row callback // will be called once PER CHANNEL! - but since we only set the row // no harm is done :) FMusic.FMUSIC_SetRowCallback(module, new FMusicCallback() { public void FMUSIC_CALLBACK(FMusicModule module, int param) { row = param; } }, 1); // try to add some userdata ByteBuffer buffer = BufferUtils.createByteBuffer(24); buffer.putInt(1).putInt(2).putInt(3).putInt(4).putInt(5).putInt(6).rewind(); FMusic.FMUSIC_SetUserData(module, buffer); } /** * Update status of module - spew it out in console */ private void update() { // mark as not running when finished if(FMusic.FMUSIC_IsFinished(module)) { running = false; } int patternLength = FMusic.FMUSIC_GetPatternLength(module, order); int time = FMusic.FMUSIC_GetTime(module) / 1000; int time2 = FMusic.FMUSIC_GetTime(module) % 1000 / 10; double cpu = Math.round(FSound.FSOUND_GetCPUUsage() * 100.0) / 100.0; System.out.println("O: " + ((order < 10) ? "0" : "") + order + "/" + numOrders + " | R: " + ((row < 10) ? "0" : "") + row + "/" + patternLength + " | T: " + time + "." + ((time2 < 10) ? "0" : "") + time2 + " | BPM: " + FMusic.FMUSIC_GetBPM(module) + " | Play: " + FMusic.FMUSIC_IsFinished(module) + " | C: " + FSound.FSOUND_GetChannelsPlaying() + " | CPU: " + cpu); } /** * Runs the actual test - that is, play | update ad nausea */ private void run() { // play FMusic.FMUSIC_PlaySong(module); // loop, printing update, if we actually changed row int lastRow = row; while(running) { if(lastRow != row) { lastRow = row; update(); } else { pause(5); } } } /** * @param i */ private void pause(long i) { try { Thread.sleep(i); } catch (InterruptedException inte) { } } // clean up our own mess private void destroy() { if(module != null) { // retrieve userdata ByteBuffer buffer = FMusic.FMUSIC_GetUserData(module, 24); // should contain 1,2,3,4,5,6 for(int i=0; i<6; i++) { System.out.println(buffer.getInt()); } FMusic.FMUSIC_FreeSong(module); } FSound.FSOUND_Close(); FMOD.destroy(); } } --- NEW FILE: CDPlayer.java --- /* * Copyright (c) 2004 LWJGL Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of 'LWJGL' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.lwjgl.test.fmod3; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; import org.lwjgl.fmod3.FMOD; import org.lwjgl.fmod3.FMODException; import org.lwjgl.fmod3.FSound; /** * $Id: CDPlayer.java,v 1.1 2004/06/09 19:50:09 matzon Exp $ * <br> * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ public class CDPlayer { public static void main(String[] args) { try { FMOD.create(); } catch (FMODException fmode) { fmode.printStackTrace(); return; } System.out.println("Initializing FMOD"); if (!FSound.FSOUND_Init(44100, 32, 0)) { System.out.println("Failed to initialize FMOD"); return; } boolean running = true; String token = null; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); do { System.out.println("FMOD CD Player test. Press a key corresponding to action"); System.out.println("1: FSOUND_CD_Eject <drive>"); System.out.println("2: FSOUND_CD_Play <drive> <track>"); System.out.println("3: FSOUND_CD_Stop <drive>"); System.out.println("4: FSOUND_CD_GetNumTracks <drive>"); System.out.println("5: FSOUND_CD_GetPaused <drive>"); System.out.println("6: FSOUND_CD_GetTrack <drive>"); System.out.println("7: FSOUND_CD_GetTrackLength <drive> <track>"); System.out.println("8: FSOUND_CD_GetTrackTime <drive>"); System.out.println("9: FSOUND_CD_SetPaused <drive>"); System.out.println("10: FSOUND_CD_SetPlayMode <drive> <mode>"); System.out.println("11: FSOUND_CD_SetTrackTime <drive> <milliseconds>"); System.out.println("12: FSOUND_CD_SetVolume <drive> <volume>"); System.out.println("0: Exit"); try { StringTokenizer st = new StringTokenizer(br.readLine().trim()); token = st.nextToken(); switch (Integer.parseInt(token)) { case 0: running = false; break; case 1: FSound.FSOUND_CD_OpenTray(st.nextToken().charAt(0), true); break; case 2: FSound.FSOUND_CD_Play(st.nextToken().charAt(0), Integer.parseInt(st.nextToken())); break; case 3: FSound.FSOUND_CD_Stop(st.nextToken().charAt(0)); break; case 4: System.out.println(FSound.FSOUND_CD_GetNumTracks(st.nextToken().charAt(0))); break; case 5: System.out.println(FSound.FSOUND_CD_GetPaused(st.nextToken().charAt(0))); break; case 6: System.out.println(FSound.FSOUND_CD_GetTrack(st.nextToken().charAt(0))); break; case 7: System.out.println(FSound.FSOUND_CD_GetTrackLength(st.nextToken().charAt(0), Integer.parseInt(st.nextToken()))); break; case 8: System.out.println(FSound.FSOUND_CD_GetTrackTime(st.nextToken().charAt(0))); break; case 9: FSound.FSOUND_CD_SetPaused(st.nextToken().charAt(0), Boolean.valueOf(st.nextToken()).booleanValue()); break; case 10: FSound.FSOUND_CD_SetPlayMode(st.nextToken().charAt(0), Integer.parseInt(st.nextToken())); break; case 11: FSound.FSOUND_CD_SetTrackTime(st.nextToken().charAt(0), Integer.parseInt(st.nextToken())); break; case 12: FSound.FSOUND_CD_SetVolume(st.nextToken().charAt(0), Integer.parseInt(st.nextToken())); break; default: System.out.println("No entry"); } } catch (Exception e) { } } while (running); FSound.FSOUND_Close(); FMOD.destroy(); } } |