You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
1
(1) |
2
(1) |
|
3
(6) |
4
|
5
|
6
(2) |
7
|
8
|
9
|
|
10
|
11
(2) |
12
|
13
(1) |
14
|
15
(2) |
16
(4) |
|
17
(4) |
18
(3) |
19
|
20
|
21
|
22
(5) |
23
(14) |
|
24
(9) |
25
|
26
(2) |
27
(6) |
28
(5) |
29
(3) |
30
|
|
31
|
|
|
|
|
|
|
|
From: Brian M. <ma...@us...> - 2004-10-03 09:47:50
|
Update of /cvsroot/java-game-lib/LWJGL/res In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2415 Modified Files: resources.txt Log Message: updated resources Index: resources.txt =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/res/resources.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- resources.txt 6 Sep 2004 20:05:26 -0000 1.2 +++ resources.txt 3 Oct 2004 09:46:21 -0000 1.3 @@ -4,4 +4,6 @@ left.wav - sampled by matzon right.wav - sampled by matzon center.wav - sampled by matzon -Missing_you.mod - Missing You, by Doh (Nicolas Desessart, http://doh.av7.net) \ No newline at end of file +Missing_you.mod - Missing You, by Doh (Nicolas Desessart, http://doh.av7.net) +phero.mp3 - snipped from unreleased Phero track +phero2.ogg - snipped from unreleased Phero track \ No newline at end of file |
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv586/src/java/org/lwjgl/test/fmod3 Modified Files: StreamPlayerMemory.java DSPTest.java StreamPlayer.java MusicPlayer.java SyncTest.java StreamTest.java Log Message: format/reindent using phero resources defaults to a file now Index: DSPTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3/DSPTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- DSPTest.java 20 Aug 2004 06:22:54 -0000 1.3 +++ DSPTest.java 3 Oct 2004 09:35:38 -0000 1.4 @@ -50,14 +50,18 @@ * @version $Revision$ */ public class DSPTest { - - public static int bytesPerSample; - public static int channels; - + + public static int bytesPerSample; + + public static int channels; + public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage:\n DSPTest <file>"); - return; + + // default to phero.mp3 + args = new String[] { "res\\phero.mp3"}; + System.out.println("Using default: " + args[0]); } File file = new File(args[0]); @@ -84,56 +88,54 @@ FSoundStream stream = FSound.FSOUND_Stream_Open(args[0], FSound.FSOUND_NORMAL, 0, 0); if (stream != null) { - System.out.println("Creating dsp unit"); - FSoundDSPUnit unit = FSound.FSOUND_Stream_CreateDSP(stream, new DSPTest().new TestDspCallback("1"), 1); - FSound.FSOUND_DSP_SetActive(unit, true); - FSoundDSPUnit unit2 = FSound.FSOUND_Stream_CreateDSP(stream, new DSPTest().new TestDspCallback("2"), 0); - FSound.FSOUND_DSP_SetActive(unit2, true); - System.out.println("Created: " + unit); - System.out.println("Created: " + unit2); - - switch(FSound.FSOUND_GetMixer()) { - case FSound.FSOUND_MIXER_AUTODETECT: - case FSound.FSOUND_MIXER_BLENDMODE: - case FSound.FSOUND_MIXER_QUALITY_AUTODETECT: - case FSound.FSOUND_MIXER_QUALITY_FPU: - case FSound.FSOUND_MIXER_MONO: - case FSound.FSOUND_MIXER_QUALITY_MONO: - case FSound.FSOUND_MIXER_MAX: - bytesPerSample = 8; - break; - default: - bytesPerSample = 4; - break; - } - - channels = FSound.FSOUND_Stream_GetMode(stream); - if((channels & FSound.FSOUND_STEREO) == FSound.FSOUND_STEREO) { - channels = 2; - } else { - channels = 1; - } - - FSound.FSOUND_Stream_SetEndCallback(stream, new FSoundStreamCallback() { + System.out.println("Creating dsp unit"); + FSoundDSPUnit unit = FSound.FSOUND_Stream_CreateDSP(stream, new DSPTest().new TestDspCallback("1"), 1); + FSound.FSOUND_DSP_SetActive(unit, true); + System.out.println("Created: " + unit); + + switch (FSound.FSOUND_GetMixer()) { + case FSound.FSOUND_MIXER_AUTODETECT: + case FSound.FSOUND_MIXER_BLENDMODE: + case FSound.FSOUND_MIXER_QUALITY_AUTODETECT: + case FSound.FSOUND_MIXER_QUALITY_FPU: + case FSound.FSOUND_MIXER_MONO: + case FSound.FSOUND_MIXER_QUALITY_MONO: + case FSound.FSOUND_MIXER_MAX: + bytesPerSample = 8; + break; + default: + bytesPerSample = 4; + break; + } + + channels = FSound.FSOUND_Stream_GetMode(stream); + if ((channels & FSound.FSOUND_STEREO) == FSound.FSOUND_STEREO) { + channels = 2; + } else { + channels = 1; + } + + FSound.FSOUND_Stream_SetEndCallback(stream, new FSoundStreamCallback() { + public void FSOUND_STREAMCALLBACK(FSoundStream stream, ByteBuffer buff, int len) { - System.out.println("Done"); - } - }); - - FSound.FSOUND_Stream_SetSyncCallback(stream, new FSoundStreamCallback() { - public void FSOUND_STREAMCALLBACK(FSoundStream stream, ByteBuffer buff, int len) { - System.out.println("SYNCPOINT"); - try { - byte[] data = new byte[buff.capacity()]; - buff.get(data); - System.out.println("Syncpoint @ " + len + ": " + new String(data)); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - - + System.out.println("Done"); + } + }); + + FSound.FSOUND_Stream_SetSyncCallback(stream, new FSoundStreamCallback() { + + public void FSOUND_STREAMCALLBACK(FSoundStream stream, ByteBuffer buff, int len) { + System.out.println("SYNCPOINT"); + try { + byte[] data = new byte[buff.capacity()]; + buff.get(data); + System.out.println("Syncpoint @ " + len + ": " + new String(data)); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + FSound.FSOUND_Stream_Play(0, stream); System.out.println("Press enter to stop playing"); @@ -145,8 +147,8 @@ System.out.println("Done playing. Cleaning up"); FSound.FSOUND_Stream_Stop(stream); FSound.FSOUND_Stream_Close(stream); - FSound.FSOUND_DSP_Free(unit); - FSound.FSOUND_DSP_Free(unit2); + FSound.FSOUND_DSP_Free(unit); + //FSound.FSOUND_DSP_Free(unit2); } else { System.out.println("Unable to play: " + args[0]); System.out.println("Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); @@ -155,32 +157,32 @@ FSound.FSOUND_Close(); FMOD.destroy(); } - - public class TestDspCallback implements FSoundDSPCallback { - - private String name; - public TestDspCallback(String name) { - this.name = name; - } + public class TestDspCallback implements FSoundDSPCallback { - /* - * @see org.lwjgl.fmod3.callbacks.FSoundDSPCallback#FSOUND_DSPCALLBACK(java.nio.ByteBuffer, java.nio.ByteBuffer, int) - */ - public ByteBuffer FSOUND_DSPCALLBACK(ByteBuffer originalbuffer, ByteBuffer newbuffer, int length) { - short leftChannel; - short rightChannel; - - for(int i=0; i<length; i++) { - leftChannel = originalbuffer.getShort(); - //rightChannel = originalbuffer.getShort(); - - // keep left, mute right channel - newbuffer.putShort(leftChannel); - //newbuffer.putShort(rightChannel); - } - newbuffer.rewind(); - return newbuffer; - } - } + private String name; + + public TestDspCallback(String name) { + this.name = name; + } + + /* + * @see org.lwjgl.fmod3.callbacks.FSoundDSPCallback#FSOUND_DSPCALLBACK(java.nio.ByteBuffer, java.nio.ByteBuffer, int) + */ + public ByteBuffer FSOUND_DSPCALLBACK(ByteBuffer originalbuffer, ByteBuffer newbuffer, int length) { + short leftChannel; + short rightChannel; + + for (int i = 0; i < length; i++) { + leftChannel = originalbuffer.getShort(); + rightChannel = originalbuffer.getShort(); + + // mute right channel + newbuffer.putShort(leftChannel); + newbuffer.putShort((short) 0); + } + newbuffer.rewind(); + return newbuffer; + } + } } \ No newline at end of file Index: StreamPlayer.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3/StreamPlayer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- StreamPlayer.java 20 Aug 2004 06:17:15 -0000 1.3 +++ StreamPlayer.java 3 Oct 2004 09:35:38 -0000 1.4 @@ -31,12 +31,8 @@ */ 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; @@ -50,45 +46,48 @@ * @version $Revision$ */ public class StreamPlayer { - + public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage:\n StreamPlayer <file>"); - return; + + // default to phero.mp3 + args = new String[] { "res\\phero.mp3"}; + System.out.println("Using default: " + args[0]); } - + 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); @@ -96,47 +95,8 @@ 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; - } } \ No newline at end of file Index: MusicPlayer.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3/MusicPlayer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- MusicPlayer.java 12 Jun 2004 20:28:25 -0000 1.2 +++ MusicPlayer.java 3 Oct 2004 09:35:38 -0000 1.3 @@ -31,12 +31,8 @@ */ 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; @@ -51,104 +47,59 @@ * @version $Revision$ */ 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(); + if (args.length < 1) { + System.out.println("Usage:\n MusicPlayer <file>"); + + // default to Missing_you.mod + args = new String[] { "res\\Missing_you.mod"}; + System.out.println("Using default: " + args[0]); + } + + 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]); + + // using name (path) + FMusicModule module = FMusic.FMUSIC_LoadSong(args[0]); + + 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; - } -} +} \ No newline at end of file Index: StreamPlayerMemory.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3/StreamPlayerMemory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- StreamPlayerMemory.java 24 Sep 2004 15:28:29 -0000 1.2 +++ StreamPlayerMemory.java 3 Oct 2004 09:35:38 -0000 1.3 @@ -48,57 +48,57 @@ * @version $Revision$ */ public class StreamPlayerMemory { - + public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage:\n StreamPlayerMemory <file>"); - - // default to phero-eveningtest.mp3 - args = new String[] { "phero-eveningtest.mp3" }; - System.out.println("Using default: " + args[0]); - } - + + // default to phero.mp3 + args = new String[] { "phero2.ogg"}; + System.out.println("Using default: " + args[0]); + } + 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; } - + ByteBuffer data = getData(args[0]); FSoundStream stream = FSound.FSOUND_Stream_Open(data, FSound.FSOUND_LOADMEMORY, 0, data.capacity()); - + if (stream != null) { FSound.FSOUND_Stream_Play(0, stream); - - // busy wait until done - int length = FSound.FSOUND_Stream_GetLengthMs(stream); - String time = ((length / 1000) / 60) + "m " + ((length / 1000) % 60) + "s"; - System.out.println("Waiting " + time + ", for song to finish"); - - try { - Thread.sleep(length); - } catch (InterruptedException inte) { - } - + + // busy wait until done + int length = FSound.FSOUND_Stream_GetLengthMs(stream); + String time = ((length / 1000) / 60) + "m " + ((length / 1000) % 60) + "s"; + System.out.println("Waiting " + time + ", for song to finish"); + + try { + Thread.sleep(length); + } catch (InterruptedException inte) { + } + 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 * @@ -108,24 +108,25 @@ */ static protected ByteBuffer getData(String filename) { ByteBuffer buffer = null; - + System.out.println("Attempting to load: " + filename); - + try { - BufferedInputStream bis = new BufferedInputStream(StreamPlayerMemory.class.getClassLoader().getResourceAsStream(filename)); + BufferedInputStream bis = new BufferedInputStream(StreamPlayerMemory.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()); Index: SyncTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3/SyncTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SyncTest.java 12 Jun 2004 20:28:25 -0000 1.2 +++ SyncTest.java 3 Oct 2004 09:35:38 -0000 1.3 @@ -51,202 +51,211 @@ * @version $Revision$ */ 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; - + + /** 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(); + 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 - */ + + /** + * + * @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"); + + if (args.length < 1) { + System.out.println("Usage:\n SyncTest <file>"); + + // default to Missing_you.mod + args = new String[] { "res\\Missing_you.mod"}; + System.out.println("Using default: " + args[0]); + } + + // 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(); + + // 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); - } - } - } - - /** + + /** + * 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) { - } + 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(); - } + 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(); + } } \ No newline at end of file Index: StreamTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3/StreamTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- StreamTest.java 21 Jul 2004 14:49:57 -0000 1.1 +++ StreamTest.java 3 Oct 2004 09:35:38 -0000 1.2 @@ -45,41 +45,41 @@ * @version $Revision$ */ public class StreamTest { - - public static void main(String[] args) { - try { - FMOD.create(); - } catch (FMODException fmode) { - fmode.printStackTrace(); - return; - } - - IntBuffer caps = BufferUtils.createIntBuffer(1); - FSound.FSOUND_SetOutput(FSound.FSOUND_OUTPUT_DSOUND); - - int count = FSound.FSOUND_GetNumDrivers(); - System.out.println("Found: " + count + " drivers"); - for(int i=0;i<count; i++) { - FSound.FSOUND_GetDriverCaps(i, caps); - System.out.println(i + " (" + FSound.FSOUND_GetDriverName(i) + ") = " + caps.get(0)); - } - - // init - 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; - } - - IntBuffer mem = BufferUtils.createIntBuffer(2); - FSound.FSOUND_GetMemoryStats(mem); - System.out.println("Allocated: " + mem.get(0) + ", Max: " + mem.get(1)); - - IntBuffer hwChannels = BufferUtils.createIntBuffer(3); - FSound.FSOUND_GetNumHWChannels(hwChannels); - System.out.println("2d: " + hwChannels.get(0) + ", 3d: " + hwChannels.get(1) + ", total: " + hwChannels.get(2)); - - FSound.FSOUND_Close(); - FMOD.destroy(); - } + + public static void main(String[] args) { + try { + FMOD.create(); + } catch (FMODException fmode) { + fmode.printStackTrace(); + return; + } + + IntBuffer caps = BufferUtils.createIntBuffer(1); + FSound.FSOUND_SetOutput(FSound.FSOUND_OUTPUT_DSOUND); + + int count = FSound.FSOUND_GetNumDrivers(); + System.out.println("Found: " + count + " drivers"); + for (int i = 0; i < count; i++) { + FSound.FSOUND_GetDriverCaps(i, caps); + System.out.println(i + " (" + FSound.FSOUND_GetDriverName(i) + ") = " + caps.get(0)); + } + + // init + 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; + } + + IntBuffer mem = BufferUtils.createIntBuffer(2); + FSound.FSOUND_GetMemoryStats(mem); + System.out.println("Allocated: " + mem.get(0) + ", Max: " + mem.get(1)); + + IntBuffer hwChannels = BufferUtils.createIntBuffer(3); + FSound.FSOUND_GetNumHWChannels(hwChannels); + System.out.println("2d: " + hwChannels.get(0) + ", 3d: " + hwChannels.get(1) + ", total: " + hwChannels.get(2)); + + FSound.FSOUND_Close(); + FMOD.destroy(); + } } \ No newline at end of file |
|
From: Brian M. <ma...@us...> - 2004-10-03 09:29:10
|
Update of /cvsroot/java-game-lib/LWJGL/res In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31566 Added Files: phero2.ogg Log Message: some ogg lovin' too --- NEW FILE: phero2.ogg --- (This appears to be a binary file; contents omitted.) |
|
From: Brian M. <ma...@us...> - 2004-10-03 09:25:41
|
Update of /cvsroot/java-game-lib/LWJGL/res In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30744 Added Files: phero.mp3 Log Message: some mp3 to play! --- NEW FILE: phero.mp3 --- (This appears to be a binary file; contents omitted.) |
|
From: Brian M. <ma...@us...> - 2004-10-03 09:02:07
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26302 Modified Files: NetTest.java Log Message: reindent/format Index: NetTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3/NetTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- NetTest.java 3 Oct 2004 02:47:10 -0000 1.5 +++ NetTest.java 3 Oct 2004 09:00:36 -0000 1.6 @@ -67,47 +67,41 @@ * @version $Revision$ */ public class NetTest { - - /** Main frame */ - private Frame frame; - - /** Whether we're initialized */ - private boolean initialized; - - /** Audio thread */ - private Thread fmodThread; - - /** Whether we're running */ - private volatile boolean running; - - /** Channel we'll be playing on */ - private int channel = -1; - - /** Canvas with fancy stuff */ - public static Canvas spectrumCanvas; - - /** Buffer containing the spectrum (512 floats) */ - public static FloatBuffer spectrum; - - /** List of known urls (monkeyradio, di streams) */ - public static String[] urls = new String[] { - "http://207.200.96.227:8038/", - "http://205.188.234.65:8020", - "http://64.236.34.67:80/stream/1006", - "http://64.236.34.67:80/stream/1003", - "http://205.188.234.65:8026", - "http://64.236.34.67:80/stream/2004", - "http://64.236.34.67:80/stream/1019", - "http://64.236.34.67:80/stream/2005"}; - - /** - * Creates a new NetTest - * @param frame parent frame - */ + + /** Main frame */ + private Frame frame; + + /** Whether we're initialized */ + private boolean initialized; + + /** Audio thread */ + private Thread fmodThread; + + /** Whether we're running */ + private volatile boolean running; + + /** Channel we'll be playing on */ + private int channel = -1; + + /** Canvas with fancy stuff */ + public static Canvas spectrumCanvas; + + /** Buffer containing the spectrum (512 floats) */ + public static FloatBuffer spectrum; + + /** List of known urls (monkeyradio, di streams) */ + public static String[] urls = new String[] { "http://207.200.96.227:8038/", "http://205.188.234.65:8020", + "http://64.236.34.67:80/stream/1006", "http://64.236.34.67:80/stream/1003", "http://205.188.234.65:8026", + "http://64.236.34.67:80/stream/2004", "http://64.236.34.67:80/stream/1019", "http://64.236.34.67:80/stream/2005"}; + + /** + * Creates a new NetTest + * @param frame parent frame + */ public NetTest(Frame frame) { this.frame = frame; } - + /** * Disposes NetTest */ @@ -118,14 +112,14 @@ FMOD.destroy(); } } - + /** * Plays the supplied URL - * - * @param url URK to play + * + * @param url URK to play */ protected void play(final String url) { - // do initialize if needed + // do initialize if needed if (!initialized) { frame.setTitle("Initializing..."); if (!initialize()) { @@ -133,54 +127,55 @@ return; } } - - // if already running, stop + + // if already running, stop if (fmodThread != null) { stop(); } - - // actual audi thread that starts playing + + // actual audi thread that starts playing fmodThread = new Thread() { + public void run() { - // Open the url and prepare to play - // ============================================ + // Open the url and prepare to play + // ============================================ frame.setTitle("Opening [" + url + "]"); running = true; FSoundStream stream = FSound.FSOUND_Stream_Open(url, FSound.FSOUND_NORMAL | FSound.FSOUND_NONBLOCKING, 0, 0); - // -------------------------------------------- - - // With a stream in hand, loop untill we're told to stop - // ============================================ + // -------------------------------------------- + + // With a stream in hand, loop untill we're told to stop + // ============================================ if (stream != null) { IntBuffer status = BufferUtils.createIntBuffer(4); while (running) { - - // get channel, if we haven't got one already + + // get channel, if we haven't got one already if (channel < 0) { channel = FSound.FSOUND_Stream_PlayEx(FSound.FSOUND_FREE, stream, null, false); } - - // query open state of stream + + // query open state of stream int openstate = FSound.FSOUND_Stream_GetOpenState(stream); if ((openstate == -1) || (openstate == -3)) { error("failed to open stream!: " + FSound.FSOUND_Stream_Net_GetLastServerStatus()); break; } - - // get status of stream + + // get status of stream FSound.FSOUND_Stream_Net_GetStatus(stream, status); - + frame.setTitle("Playing [state: " + getNameFor(status.get(0)) + ", buffer: " + status.get(1) - + ", bitrate: " + status.get(2) + "]"); - - // repaint spectrum + + ", bitrate: " + status.get(2) + "]"); + + // repaint spectrum spectrumCanvas.repaint(); - - // dont use all resources! + + // dont use all resources! pause(25); } - - // exiting. spin on stop/close since we're non-blocking + + // exiting. spin on stop/close since we're non-blocking while (!FSound.FSOUND_Stream_Stop(stream)) { pause(10); } @@ -191,15 +186,15 @@ } else { error("Unable to play: " + url + ". Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); } - // -------------------------------------------- - - // we're done, nuke leftovers + // -------------------------------------------- + + // we're done, nuke leftovers spectrumCanvas.repaint(); } }; fmodThread.start(); } - + /** * @return enum name for supplied stream open state */ @@ -218,17 +213,17 @@ } return ""; } - + /** * Stops the playing */ protected void stop() { - // update title + // update title if (frame.isVisible()) { frame.setTitle("LWJGL Fmod streaming player: stopping..."); } - - // nuke the thread, but wait for it to finish! + + // nuke the thread, but wait for it to finish! running = false; if (fmodThread != null) { try { @@ -237,21 +232,21 @@ } fmodThread = null; } - - // update title + + // update title if (frame.isVisible()) { frame.setTitle("LWJGL Fmod streaming player"); } } - - /** - * Initializes the test - * - * @return true if initialization was successfull - */ + + /** + * Initializes the test + * + * @return true if initialization was successfull + */ protected boolean initialize() { if (!initialized) { - // create FMOD first! + // create FMOD first! try { FMOD.create(); } catch (FMODException fmode) { @@ -259,28 +254,28 @@ fmode.printStackTrace(); return false; } - - // initialize fsound + + // initialize fsound if (!FSound.FSOUND_Init(44100, 32, 0)) { error("Failed to initialize FMOD: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); return false; } - - // get fft unit and activate it (else, we can't get the spectrum) + + // get fft unit and activate it (else, we can't get the spectrum) FSound.FSOUND_DSP_SetActive(FSound.FSOUND_DSP_GetFFTUnit(), true); - - // get the spectrum - spectrum = FSound.FSOUND_DSP_GetSpectrum(); - + + // get the spectrum + spectrum = FSound.FSOUND_DSP_GetSpectrum(); + // setup buffers FSound.FSOUND_Stream_SetBufferSize(100); FSound.FSOUND_Stream_Net_SetBufferProperties(64000, 95, 95); - + initialized = true; } return initialized; } - + /** * @param string */ @@ -288,23 +283,24 @@ final Dialog dialog = new Dialog(frame, "Error", true); dialog.add(new Label(string)); dialog.pack(); - + dialog.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { dialog.dispose(); } }); - + // setup dialog int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - dialog.getWidth()) / 2; int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - dialog.getHeight()) / 2; dialog.setLocation(x, y); dialog.setVisible(true); } - + /** - * Pause calling thread for i milliseconds - * + * Pause calling thread for i milliseconds + * * @param i how long time to pause */ private static void pause(long i) { @@ -313,135 +309,135 @@ } catch (InterruptedException inte) { } } - - /** - * Executes the NetTest - * @param args - */ - public static void main(String[] args) { - - // UI and instance stuff - final Frame frame = new Frame("LWJGL Fmod streaming player"); - final Choice choice; - final Button btnPlay; - final Button btnStop; - final boolean playing = false; - final NetTest netTest = new NetTest(frame); - - // main panel - frame.setLayout(new BoxLayout(frame, BoxLayout.PAGE_AXIS)); - final Panel panel[] = { new Panel(), new Panel()}; - panel[0].setLayout(new FlowLayout()); - panel[0].add(new Label("URL:")); - panel[0].add(choice = new Choice()); - panel[0].add(btnPlay = new Button("Play")); - panel[0].add(btnStop = new Button("Stop")); - panel[1].add(spectrumCanvas = netTest.new SpectrumCanvas()); - panel[0].setBackground(new Color(0x99, 0x99, 0x99)); - panel[1].setBackground(new Color(0x99, 0x99, 0x99)); - - // add list of known urls - for(int i=0; i<urls.length; i++) { - choice.add(urls[i]); - } - - // add spectrum panel, set size and pack - frame.add(panel[0]); - spectrumCanvas.setSize(512, 100); - frame.pack(); - - // Add listeners - // ===================================================== - frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - frame.dispose(); - netTest.dispose(); - } - }); - - btnPlay.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - frame.add(panel[1]); - frame.pack(); - netTest.play(choice.getSelectedItem()); - } - }); - - btnStop.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - frame.remove(panel[1]); - frame.pack(); - netTest.stop(); - } - }); - // ----------------------------------------------------- - - // setup frame - int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - frame.getWidth()) / 2; - int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - frame.getHeight()) / 2; - frame.setLocation(x, y); - frame.setResizable(false); - frame.setVisible(true); - } - - - /** - * Simplish spectrum - * @author Brian Matzon <br...@ma...> - * @version $Revision$ - */ - class SpectrumCanvas extends Canvas { - - /** Offscreen image for that flickerless feel! (TM) */ - Image bufferImage; - - /** Graphics context for buffer */ - Graphics2D bufferGraphics; - - /** Background color */ - Color bgColor = new Color(0x99, 0x99, 0x99); - - /** Gradient paint */ - GradientPaint gp; - - /** - * Called to paint the canvas - */ + + /** + * Executes the NetTest + * @param args + */ + public static void main(String[] args) { + + // UI and instance stuff + final Frame frame = new Frame("LWJGL Fmod streaming player"); + final Choice choice; + final Button btnPlay; + final Button btnStop; + final boolean playing = false; + final NetTest netTest = new NetTest(frame); + + // main panel + frame.setLayout(new BoxLayout(frame, BoxLayout.PAGE_AXIS)); + final Panel panel[] = { new Panel(), new Panel()}; + panel[0].setLayout(new FlowLayout()); + panel[0].add(new Label("URL:")); + panel[0].add(choice = new Choice()); + panel[0].add(btnPlay = new Button("Play")); + panel[0].add(btnStop = new Button("Stop")); + panel[1].add(spectrumCanvas = netTest.new SpectrumCanvas()); + panel[0].setBackground(new Color(0x99, 0x99, 0x99)); + panel[1].setBackground(new Color(0x99, 0x99, 0x99)); + + // add list of known urls + for (int i = 0; i < urls.length; i++) { + choice.add(urls[i]); + } + + // add spectrum panel, set size and pack + frame.add(panel[0]); + spectrumCanvas.setSize(512, 100); + frame.pack(); + + // Add listeners + // ===================================================== + frame.addWindowListener(new WindowAdapter() { + + public void windowClosing(WindowEvent e) { + frame.dispose(); + netTest.dispose(); + } + }); + + btnPlay.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + frame.add(panel[1]); + frame.pack(); + netTest.play(choice.getSelectedItem()); + } + }); + + btnStop.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + frame.remove(panel[1]); + frame.pack(); + netTest.stop(); + } + }); + // ----------------------------------------------------- + + // setup frame + int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - frame.getWidth()) / 2; + int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - frame.getHeight()) / 2; + frame.setLocation(x, y); + frame.setResizable(false); + frame.setVisible(true); + } + + /** + * Simplish spectrum + * @author Brian Matzon <br...@ma...> + * @version $Revision$ + */ + class SpectrumCanvas extends Canvas { + + /** Offscreen image for that flickerless feel! (TM) */ + Image bufferImage; + + /** Graphics context for buffer */ + Graphics2D bufferGraphics; + + /** Background color */ + Color bgColor = new Color(0x99, 0x99, 0x99); + + /** Gradient paint */ + GradientPaint gp; + + /** + * Called to paint the canvas + */ public void paint(Graphics g) { // create offscreen if (bufferImage == null) { - gp = new GradientPaint(0, 0, Color.RED, 0, getHeight(), Color.GREEN); + gp = new GradientPaint(0, 0, Color.RED, 0, getHeight(), Color.GREEN); bufferImage = createImage(getWidth(), getHeight()); bufferGraphics = (Graphics2D) bufferImage.getGraphics(); } - + // clear old bufferGraphics.setColor(bgColor); bufferGraphics.fillRect(0, 0, getWidth(), getHeight()); - - // if we have a spectrum, draw it + + // if we have a spectrum, draw it if (spectrum != null && NetTest.this.fmodThread != null) { - int x = 0; - - // for each spectrum value, draw a line according to its - // value (times 4, since we want higher frequencies to show up) - bufferGraphics.setPaint(gp); + int x = 0; + + // for each spectrum value, draw a line according to its + // value (times 4, since we want higher frequencies to show up) + bufferGraphics.setPaint(gp); for (int i = 0; i < 256; i++) { - int height = (int) (getHeight() * 4.0 * spectrum.get(i)); + int height = (int) (getHeight() * 4.0 * spectrum.get(i)); bufferGraphics.fillRect(x, getHeight() - height, 2, height); - x+=2; + x += 2; } } - - // map offscreen onscreen + + // map offscreen onscreen g.drawImage(bufferImage, 0, 0, this); } - - /** - * Just draw the sucker instead of default update - */ + + /** + * Just draw the sucker instead of default update + */ public void update(Graphics g) { paint(g); } |
|
From: Brian M. <ma...@us...> - 2004-10-03 02:49:31
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27128/src/java/org/lwjgl/test/fmod3 Modified Files: NetTest.java Log Message: got boredm spiced it up Index: NetTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3/NetTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- NetTest.java 16 Sep 2004 22:38:31 -0000 1.4 +++ NetTest.java 3 Oct 2004 02:47:10 -0000 1.5 @@ -32,20 +32,28 @@ package org.lwjgl.test.fmod3; import java.awt.Button; +import java.awt.Canvas; +import java.awt.Choice; import java.awt.Color; import java.awt.Dialog; import java.awt.FlowLayout; import java.awt.Frame; +import java.awt.GradientPaint; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; import java.awt.Label; import java.awt.Panel; -import java.awt.TextField; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.nio.FloatBuffer; import java.nio.IntBuffer; +import javax.swing.BoxLayout; + import org.lwjgl.BufferUtils; import org.lwjgl.fmod3.FMOD; import org.lwjgl.fmod3.FMODException; @@ -60,243 +68,382 @@ */ public class NetTest { - private Frame frame; - private boolean initialized; - private Thread fmodThread; - private volatile boolean running; - private int channel = -1; - private boolean paused = true; - - public NetTest(Frame frame) { - this.frame = frame; - } - - public static void main(String[] args) { - - final Frame frame = new Frame("LWJGL Fmod streaming player"); - final NetTest netTest = new NetTest(frame); - final boolean playing = false; - - final TextField txtField; - final Button btnPlay; - final Button btnStop; - - // main panel - Panel panel = new Panel(); - panel.setLayout(new FlowLayout()); - panel.add(new Label("URL:")); - panel.add(txtField = new TextField("http://207.200.96.227:8038/", 60)); - panel.add(btnPlay = new Button("Play")); - panel.add(btnStop = new Button("Stop")); - panel.setBackground(new Color(0x99, 0x99, 0x99)); - - frame.add(panel); - frame.pack(); - - frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - frame.dispose(); - netTest.dispose(); - } - }); - - btnPlay.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - netTest.play(txtField.getText()); - } - }); - - btnStop.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - netTest.stop(); - } - }); + /** Main frame */ + private Frame frame; - // setup frame - int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - frame.getWidth()) / 2; - int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - frame.getHeight()) / 2; - frame.setLocation(x, y); - frame.setResizable(false); - frame.setVisible(true); - } + /** Whether we're initialized */ + private boolean initialized; + + /** Audio thread */ + private Thread fmodThread; + + /** Whether we're running */ + private volatile boolean running; + + /** Channel we'll be playing on */ + private int channel = -1; + + /** Canvas with fancy stuff */ + public static Canvas spectrumCanvas; + + /** Buffer containing the spectrum (512 floats) */ + public static FloatBuffer spectrum; + /** List of known urls (monkeyradio, di streams) */ + public static String[] urls = new String[] { + "http://207.200.96.227:8038/", + "http://205.188.234.65:8020", + "http://64.236.34.67:80/stream/1006", + "http://64.236.34.67:80/stream/1003", + "http://205.188.234.65:8026", + "http://64.236.34.67:80/stream/2004", + "http://64.236.34.67:80/stream/1019", + "http://64.236.34.67:80/stream/2005"}; + /** - * - */ - private void dispose() { - if(initialized) { - stop(); - FSound.FSOUND_Close(); - FMOD.destroy(); - } + * Creates a new NetTest + * @param frame parent frame + */ + public NetTest(Frame frame) { + this.frame = frame; } /** - * + * Disposes NetTest */ - protected void pause() { - if(running && channel > 0) { - FSound.FSOUND_SetPaused(channel, paused = !paused); - - if(paused) { - frame.setTitle("LWJGL Fmod streaming player: Paused"); - } - } + private void dispose() { + if (initialized) { + stop(); + FSound.FSOUND_Close(); + FMOD.destroy(); + } } /** - * + * Plays the supplied URL + * + * @param url URK to play */ protected void play(final String url) { - if(!initialized) { - frame.setTitle("Initializing..."); - if(!initialize()) { - frame.setTitle("LWJGL Fmod streaming player"); - return; - } - } - - if(fmodThread != null) { - stop(); - } - - - fmodThread = new Thread() { - public void run() { - frame.setTitle("Opening [" + url + "]"); - running = true; - FSoundStream stream = FSound.FSOUND_Stream_Open(url, FSound.FSOUND_NORMAL | FSound.FSOUND_NONBLOCKING, 0, 0); - - if (stream != null) { - IntBuffer status = BufferUtils.createIntBuffer(4); - while(running) { - if(channel < 0) { - channel = FSound.FSOUND_Stream_PlayEx(FSound.FSOUND_FREE, stream, null, true); - FSound.FSOUND_SetPaused(channel, false); - paused = false; - } - - int openstate = FSound.FSOUND_Stream_GetOpenState(stream); - if ((openstate == -1) || (openstate == -3)) { - error("failed to open stream!: " + FSound.FSOUND_Stream_Net_GetLastServerStatus()); - break; - } - - FSound.FSOUND_Stream_Net_GetStatus(stream, status); - - if(!paused) { - frame.setTitle("Playing [state: " + getNameFor(status.get(0)) + ", buffer: " + status.get(1) + ", bitrate: " + status.get(2) + "]"); - } - pause(10); - } - - while(!FSound.FSOUND_Stream_Stop(stream)) { - pause(10); - } - while(!FSound.FSOUND_Stream_Close(stream)) { - pause(10); - } - channel = -1; - } else { - error("Unable to play: " + url + ". Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); - } - } - }; - fmodThread.start(); + // do initialize if needed + if (!initialized) { + frame.setTitle("Initializing..."); + if (!initialize()) { + frame.setTitle("LWJGL Fmod streaming player"); + return; + } + } + + // if already running, stop + if (fmodThread != null) { + stop(); + } + + // actual audi thread that starts playing + fmodThread = new Thread() { + public void run() { + // Open the url and prepare to play + // ============================================ + frame.setTitle("Opening [" + url + "]"); + running = true; + FSoundStream stream = FSound.FSOUND_Stream_Open(url, FSound.FSOUND_NORMAL | FSound.FSOUND_NONBLOCKING, 0, 0); + // -------------------------------------------- + + // With a stream in hand, loop untill we're told to stop + // ============================================ + if (stream != null) { + IntBuffer status = BufferUtils.createIntBuffer(4); + while (running) { + + // get channel, if we haven't got one already + if (channel < 0) { + channel = FSound.FSOUND_Stream_PlayEx(FSound.FSOUND_FREE, stream, null, false); + } + + // query open state of stream + int openstate = FSound.FSOUND_Stream_GetOpenState(stream); + if ((openstate == -1) || (openstate == -3)) { + error("failed to open stream!: " + FSound.FSOUND_Stream_Net_GetLastServerStatus()); + break; + } + + // get status of stream + FSound.FSOUND_Stream_Net_GetStatus(stream, status); + + frame.setTitle("Playing [state: " + getNameFor(status.get(0)) + ", buffer: " + status.get(1) + + ", bitrate: " + status.get(2) + "]"); + + // repaint spectrum + spectrumCanvas.repaint(); + + // dont use all resources! + pause(25); + } + + // exiting. spin on stop/close since we're non-blocking + while (!FSound.FSOUND_Stream_Stop(stream)) { + pause(10); + } + while (!FSound.FSOUND_Stream_Close(stream)) { + pause(10); + } + channel = -1; + } else { + error("Unable to play: " + url + ". Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); + } + // -------------------------------------------- + + // we're done, nuke leftovers + spectrumCanvas.repaint(); + } + }; + fmodThread.start(); } /** - * @param i - * @return + * @return enum name for supplied stream open state */ protected String getNameFor(int i) { - switch(i) { - case FSound.FSOUND_STREAM_NET_NOTCONNECTED: - return "FSOUND_STREAM_NET_NOTCONNECTED"; - case FSound.FSOUND_STREAM_NET_CONNECTING: - return "FSOUND_STREAM_NET_CONNECTING"; - case FSound.FSOUND_STREAM_NET_BUFFERING: - return "FSOUND_STREAM_NET_BUFFERING"; - case FSound.FSOUND_STREAM_NET_READY: - return "FSOUND_STREAM_NET_READY"; - case FSound.FSOUND_STREAM_NET_ERROR: - return "FSOUND_STREAM_NET_ERROR"; - } + switch (i) { + case FSound.FSOUND_STREAM_NET_NOTCONNECTED: + return "FSOUND_STREAM_NET_NOTCONNECTED"; + case FSound.FSOUND_STREAM_NET_CONNECTING: + return "FSOUND_STREAM_NET_CONNECTING"; + case FSound.FSOUND_STREAM_NET_BUFFERING: + return "FSOUND_STREAM_NET_BUFFERING"; + case FSound.FSOUND_STREAM_NET_READY: + return "FSOUND_STREAM_NET_READY"; + case FSound.FSOUND_STREAM_NET_ERROR: + return "FSOUND_STREAM_NET_ERROR"; + } return ""; } /** - * + * Stops the playing */ protected void stop() { - if(frame.isVisible()) { - frame.setTitle("LWJGL Fmod streaming player: stopping..."); - } - - running = false; - if(fmodThread != null) { - try { - fmodThread.join(); - } catch (InterruptedException inte) { - } - fmodThread = null; - } - - if(frame.isVisible()) { - frame.setTitle("LWJGL Fmod streaming player"); - } + // update title + if (frame.isVisible()) { + frame.setTitle("LWJGL Fmod streaming player: stopping..."); + } + + // nuke the thread, but wait for it to finish! + running = false; + if (fmodThread != null) { + try { + fmodThread.join(); + } catch (InterruptedException inte) { + } + fmodThread = null; + } + + // update title + if (frame.isVisible()) { + frame.setTitle("LWJGL Fmod streaming player"); + } } - - protected boolean initialize() { - if(!initialized) { - try { - FMOD.create(); - } catch (FMODException fmode) { - error(fmode.getMessage()); - fmode.printStackTrace(); - return false; - } + + /** + * Initializes the test + * + * @return true if initialization was successfull + */ + protected boolean initialize() { + if (!initialized) { + // create FMOD first! + try { + FMOD.create(); + } catch (FMODException fmode) { + error(fmode.getMessage()); + fmode.printStackTrace(); + return false; + } + + // initialize fsound + if (!FSound.FSOUND_Init(44100, 32, 0)) { + error("Failed to initialize FMOD: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); + return false; + } + + // get fft unit and activate it (else, we can't get the spectrum) + FSound.FSOUND_DSP_SetActive(FSound.FSOUND_DSP_GetFFTUnit(), true); - if (!FSound.FSOUND_Init(44100, 32, 0)) { - error("Failed to initialize FMOD: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); - return false; - } + // get the spectrum + spectrum = FSound.FSOUND_DSP_GetSpectrum(); - FSound.FSOUND_Stream_SetBufferSize(500); - FSound.FSOUND_Stream_Net_SetBufferProperties(64000, 60, 80); - initialized = true; - } - return initialized; - } + // setup buffers + FSound.FSOUND_Stream_SetBufferSize(100); + FSound.FSOUND_Stream_Net_SetBufferProperties(64000, 95, 95); + + initialized = true; + } + return initialized; + } /** * @param string */ private void error(String string) { - final Dialog dialog = new Dialog(frame, "Error", true); - dialog.add(new Label(string)); - dialog.pack(); + final Dialog dialog = new Dialog(frame, "Error", true); + dialog.add(new Label(string)); + dialog.pack(); + + dialog.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dialog.dispose(); + } + }); + + // setup dialog + int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - dialog.getWidth()) / 2; + int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - dialog.getHeight()) / 2; + dialog.setLocation(x, y); + dialog.setVisible(true); + } + + /** + * Pause calling thread for i milliseconds + * + * @param i how long time to pause + */ + private static void pause(long i) { + try { + Thread.sleep(i); + } catch (InterruptedException inte) { + } + } + + /** + * Executes the NetTest + * @param args + */ + public static void main(String[] args) { + + // UI and instance stuff + final Frame frame = new Frame("LWJGL Fmod streaming player"); + final Choice choice; + final Button btnPlay; + final Button btnStop; + final boolean playing = false; + final NetTest netTest = new NetTest(frame); + + // main panel + frame.setLayout(new BoxLayout(frame, BoxLayout.PAGE_AXIS)); + final Panel panel[] = { new Panel(), new Panel()}; + panel[0].setLayout(new FlowLayout()); + panel[0].add(new Label("URL:")); + panel[0].add(choice = new Choice()); + panel[0].add(btnPlay = new Button("Play")); + panel[0].add(btnStop = new Button("Stop")); + panel[1].add(spectrumCanvas = netTest.new SpectrumCanvas()); + panel[0].setBackground(new Color(0x99, 0x99, 0x99)); + panel[1].setBackground(new Color(0x99, 0x99, 0x99)); - dialog.addWindowListener(new WindowAdapter() { + // add list of known urls + for(int i=0; i<urls.length; i++) { + choice.add(urls[i]); + } + + // add spectrum panel, set size and pack + frame.add(panel[0]); + spectrumCanvas.setSize(512, 100); + frame.pack(); + + // Add listeners + // ===================================================== + frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - dialog.dispose(); + frame.dispose(); + netTest.dispose(); } }); - - // setup dialog - int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - dialog.getWidth()) / 2; - int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - dialog.getHeight()) / 2; - dialog.setLocation(x, y); - dialog.setVisible(true); - } - /** - * @param i + btnPlay.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + frame.add(panel[1]); + frame.pack(); + netTest.play(choice.getSelectedItem()); + } + }); + + btnStop.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + frame.remove(panel[1]); + frame.pack(); + netTest.stop(); + } + }); + // ----------------------------------------------------- + + // setup frame + int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - frame.getWidth()) / 2; + int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - frame.getHeight()) / 2; + frame.setLocation(x, y); + frame.setResizable(false); + frame.setVisible(true); + } + + + /** + * Simplish spectrum + * @author Brian Matzon <br...@ma...> + * @version $Revision$ */ - private static void pause(long i) { - try { - Thread.sleep(i); - } catch (InterruptedException inte) { - } - } + class SpectrumCanvas extends Canvas { + + /** Offscreen image for that flickerless feel! (TM) */ + Image bufferImage; + + /** Graphics context for buffer */ + Graphics2D bufferGraphics; + + /** Background color */ + Color bgColor = new Color(0x99, 0x99, 0x99); + + /** Gradient paint */ + GradientPaint gp; + + /** + * Called to paint the canvas + */ + public void paint(Graphics g) { + // create offscreen + if (bufferImage == null) { + gp = new GradientPaint(0, 0, Color.RED, 0, getHeight(), Color.GREEN); + bufferImage = createImage(getWidth(), getHeight()); + bufferGraphics = (Graphics2D) bufferImage.getGraphics(); + } + + // clear old + bufferGraphics.setColor(bgColor); + bufferGraphics.fillRect(0, 0, getWidth(), getHeight()); + + // if we have a spectrum, draw it + if (spectrum != null && NetTest.this.fmodThread != null) { + int x = 0; + + // for each spectrum value, draw a line according to its + // value (times 4, since we want higher frequencies to show up) + bufferGraphics.setPaint(gp); + for (int i = 0; i < 256; i++) { + int height = (int) (getHeight() * 4.0 * spectrum.get(i)); + bufferGraphics.fillRect(x, getHeight() - height, 2, height); + x+=2; + } + } + + // map offscreen onscreen + g.drawImage(bufferImage, 0, 0, this); + } + + /** + * Just draw the sucker instead of default update + */ + public void update(Graphics g) { + paint(g); + } + } } \ No newline at end of file |