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-17 15:53:58
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23764/src/java/org/lwjgl/test/opengl Added Files: Gears.java Log Message: Gears test added --- NEW FILE: Gears.java --- /* * 3-D gear wheels. This program is in the public domain. * Brian Paul */ package org.lwjgl.test.opengl; import java.nio.FloatBuffer; import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.ARBTransposeMatrix; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GLContext; /** * $Id: Gears.java,v 1.1 2004/10/17 15:53:49 matzon Exp $ * <p> * This is the OpenGL "standard" Gears demo, originally by Brian Paul * </p> * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ public class Gears { private float view_rotx = 20.0f; private float view_roty = 30.0f; private float view_rotz = 0.0f; private int gear1; private int gear2; private int gear3; private float angle = 0.0f; public static void main(String[] args) { new Gears().execute(); } /** * */ private void execute() { try { init(); } catch (LWJGLException le) { le.printStackTrace(); System.out.println("Failed to initialize Gears."); return; } loop(); destroy(); } /** * */ private void destroy() { Display.destroy(); } /** * */ private void loop() { long startTime = System.currentTimeMillis() + 5000; long fps = 0; while (!Display.isCloseRequested()) { angle += 2.0f; GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glPushMatrix(); GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); GL11.glPushMatrix(); GL11.glTranslatef(-3.0f, -2.0f, 0.0f); GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); GL11.glCallList(gear1); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glTranslatef(3.1f, -2.0f, 0.0f); GL11.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f); GL11.glCallList(gear2); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glTranslatef(-3.1f, 4.2f, 0.0f); GL11.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f); GL11.glCallList(gear3); GL11.glPopMatrix(); GL11.glPopMatrix(); Display.update(); if (startTime > System.currentTimeMillis()) { fps++; } else { long timeUsed = 5000 + (startTime - System.currentTimeMillis()); startTime = System.currentTimeMillis() + 5000; System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = " + (fps / (timeUsed / 1000f))); fps = 0; } } } /** * */ private void init() throws LWJGLException { // create Window of size 300x300 Display.setLocation((Display.getDisplayMode().getWidth() - 300) / 2, (Display.getDisplayMode().getHeight() - 300) / 2); Display.setDisplayMode(new DisplayMode(300, 300)); Display.setTitle("Gears"); Display.create(); // setup ogl FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f}); FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f}); FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f}); FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f}); pos.flip(); red.flip(); green.flip(); blue.flip(); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnable(GL11.GL_DEPTH_TEST); /* make the gears */ gear1 = GL11.glGenLists(1); GL11.glNewList(gear1, GL11.GL_COMPILE); GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red); gear(1.0f, 4.0f, 1.0f, 20, 0.7f); GL11.glEndList(); gear2 = GL11.glGenLists(1); GL11.glNewList(gear2, GL11.GL_COMPILE); GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green); gear(0.5f, 2.0f, 2.0f, 10, 0.7f); GL11.glEndList(); gear3 = GL11.glGenLists(1); GL11.glNewList(gear3, GL11.GL_COMPILE); GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue); gear(1.3f, 2.0f, 0.5f, 10, 0.7f); GL11.glEndList(); GL11.glEnable(GL11.GL_NORMALIZE); GL11.glMatrixMode(GL11.GL_PROJECTION); System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR)); System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); System.err.println(); System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.GL_ARB_transpose_matrix); if (!GLContext.GL_ARB_transpose_matrix) { // --- not using extensions GL11.glLoadIdentity(); } else { // --- using extensions final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put( new float[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}); identityTranspose.flip(); ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose); } float h = (float) 300 / (float) 300; GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0f, 0.0f, -40.0f); } /** * Draw a gear wheel. You'll probably want to call this function when * building a display list since we do a lot of trig here. * * @param inner_radius radius of hole at center * @param outer_radius radius at center of teeth * @param width width of gear * @param teeth number of teeth * @param tooth_depth depth of tooth */ private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) { int i; float r0, r1, r2; float angle, da; float u, v, len; r0 = inner_radius; r1 = outer_radius - tooth_depth / 2.0f; r2 = outer_radius + tooth_depth / 2.0f; da = 2.0f * (float) Math.PI / teeth / 4.0f; GL11.glShadeModel(GL11.GL_FLAT); GL11.glNormal3f(0.0f, 0.0f, 1.0f); /* draw front face */ GL11.glBegin(GL11.GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); if (i < teeth) { GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f); } } GL11.glEnd(); /* draw front sides of teeth */ GL11.glBegin(GL11.GL_QUADS); for (i = 0; i < teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); GL11.glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f); GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f); } GL11.glEnd(); /* draw back face */ GL11.glBegin(GL11.GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); } GL11.glEnd(); /* draw back sides of teeth */ GL11.glBegin(GL11.GL_QUADS); for (i = 0; i < teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); } GL11.glEnd(); /* draw outward faces of teeth */ GL11.glBegin(GL11.GL_QUAD_STRIP); for (i = 0; i < teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle); v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle); len = (float) Math.sqrt(u * u + v * v); u /= len; v /= len; GL11.glNormal3f(v, -u, 0.0f); GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f); GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da); v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da); GL11.glNormal3f(v, -u, 0.0f); GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f); GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); } GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f); GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f); GL11.glEnd(); GL11.glShadeModel(GL11.GL_SMOOTH); /* draw inside radius cylinder */ GL11.glBegin(GL11.GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; GL11.glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f); GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); } GL11.glEnd(); } } |
|
From: Elias N. <eli...@us...> - 2004-10-16 21:59:29
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12813/src/native/linux Modified Files: org_lwjgl_input_Keyboard.c Log Message: Linux: Added basic support for Xutf8LookupString, providing better support for international characters Index: org_lwjgl_input_Keyboard.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Keyboard.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- org_lwjgl_input_Keyboard.c 15 Oct 2004 21:31:46 -0000 1.8 +++ org_lwjgl_input_Keyboard.c 16 Oct 2004 21:59:20 -0000 1.9 @@ -44,6 +44,8 @@ #include <X11/Xutil.h> #include <string.h> #include <assert.h> +#include <iconv.h> +#include <errno.h> #include "Window.h" #include "common_tools.h" #include "org_lwjgl_input_Keyboard.h" @@ -62,6 +64,11 @@ static bool translation_enabled; static bool created = false; +// X input manager values +static iconv_t iconv_descriptor; +static XIM xim = NULL; +static XIC xic = NULL; + static void grabKeyboard(void) { if (!keyboard_grabbed) { int result = XGrabKeyboard(getDisplay(), getCurrentWindow(), False, GrabModeAsync, GrabModeAsync, CurrentTime); @@ -87,6 +94,19 @@ } } +static void closeUnicodeStructs() { + if (iconv_descriptor != (iconv_t)-1) + iconv_close(iconv_descriptor); + if (xic != NULL) { + XDestroyIC(xic); + xic = NULL; + } + if (xim != NULL) { + XCloseIM(xim); + xim = NULL; + } +} + JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate (JNIEnv * env, jclass clazz) { @@ -122,11 +142,25 @@ buffer_enabled = false; initEventQueue(&event_queue, 3); updateKeyboardGrab(); + + // Allocate unicode structures + iconv_descriptor = iconv_open("UCS-2", "UTF-8"); + if (iconv_descriptor != (iconv_t)-1) { + xim = XOpenIM(getDisplay(), NULL, NULL, NULL); + if (xim != NULL) { + xic = XCreateIC(xim, XNClientWindow, getCurrentWindow(), XNFocusWindow, getCurrentWindow(), XNInputStyle, XIMPreeditNothing | XIMStatusNothing, NULL); + if (xic == NULL) { + closeUnicodeStructs(); + } + } else + closeUnicodeStructs(); + } } JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nDestroy (JNIEnv * env, jclass clazz) { + closeUnicodeStructs(); ungrabKeyboard(); created = false; decDisplay(); @@ -143,9 +177,56 @@ putEvent(&event_queue, event_list); } -static void translateEvent(XKeyEvent *event, jint keycode, jint state) { +static int lookupStringISO88591(XKeyEvent *event, jint *translation_buffer) { static XComposeStatus status; - char temp_translation_buffer[KEYBOARD_BUFFER_SIZE]; + char char_translation_buffer[KEYBOARD_BUFFER_SIZE]; + int i; + + int num_chars = XLookupString(event, char_translation_buffer, KEYBOARD_BUFFER_SIZE*sizeof(char), NULL, &status); + for (i = 0; i < num_chars; i++) + translation_buffer[i] = ((jint)char_translation_buffer[i]) & 0xff; + return num_chars; +} + +static int lookupStringUnicode(XKeyEvent *event, jint *translation_buffer) { + char utf8_translation_buffer[KEYBOARD_BUFFER_SIZE]; + jchar ucs2_translation_buffer[KEYBOARD_BUFFER_SIZE]; + char *utf8_buf = utf8_translation_buffer; + jchar *ucs2_buf = ucs2_translation_buffer; + size_t ucs2_bytes = KEYBOARD_BUFFER_SIZE*sizeof(jchar); + Status status; + int i; + + XSetICFocus(xic); + size_t utf8_bytes = Xutf8LookupString(xic, event, utf8_translation_buffer, KEYBOARD_BUFFER_SIZE*sizeof(char), NULL, &status); + if (status != XLookupChars && status != XLookupBoth) + return 0; + XUnsetICFocus(xic); + // reset converter + iconv(iconv_descriptor, NULL, NULL, NULL, NULL); + // convert from UTF-8 to UCS-2 + size_t iconv_result = iconv(iconv_descriptor, &utf8_buf, &utf8_bytes, (void *)&ucs2_buf, &ucs2_bytes); + // compute number of characters converted + int num_chars_converted = KEYBOARD_BUFFER_SIZE - ucs2_bytes/sizeof(jchar); + if (iconv_result == (size_t)-1) { + errno = 0; // ignore conversion error and return no chars converted + return 0; + } + for (i = 0; i < num_chars_converted; i++) { + translation_buffer[i] = ((jint)ucs2_translation_buffer[i]) & 0xffff; + } + return num_chars_converted; +} + +static int lookupString(XKeyEvent *event, jint *translation_buffer) { + if (xic != NULL) { + return lookupStringUnicode(event, translation_buffer); + } else + return lookupStringISO88591(event, translation_buffer); +} + +static void translateEvent(XKeyEvent *event, jint keycode, jint state) { + jint temp_translation_buffer[KEYBOARD_BUFFER_SIZE]; int num_chars, i; jint ch; @@ -153,12 +234,12 @@ putKeyboardEvent(keycode, state, 0); return; } - num_chars = XLookupString(event, temp_translation_buffer, KEYBOARD_BUFFER_SIZE, NULL, &status); + num_chars = lookupString(event, temp_translation_buffer); if (num_chars > 0) { - ch = ((jint)temp_translation_buffer[0]) & 0xFF; + ch = temp_translation_buffer[0]; putKeyboardEvent(keycode, state, ch); for (i = 1; i < num_chars; i++) { - ch = ((jint)temp_translation_buffer[i]) & 0xFF; + ch = temp_translation_buffer[i]; putKeyboardEvent(0, 0, ch); } } else { |
|
From: Brian M. <ma...@us...> - 2004-10-16 01:02:50
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23618/src/java/org/lwjgl/test/fmod3 Added Files: TagFieldTest.java Log Message: tagfields implemented --- NEW FILE: TagFieldTest.java --- /* * Copyright (c) 2002-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.IntBuffer; import org.lwjgl.BufferUtils; import org.lwjgl.fmod3.FMOD; import org.lwjgl.fmod3.FMODException; import org.lwjgl.fmod3.FSound; import org.lwjgl.fmod3.FSoundStream; import org.lwjgl.fmod3.FSoundTagField; /** * $Id: TagFieldTest.java,v 1.1 2004/10/16 01:02:34 matzon Exp $ <br> * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ public class TagFieldTest { public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage:\n TagFieldTest <file>"); // 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) { //scratch buffer IntBuffer scratch = BufferUtils.createIntBuffer(16); FSound.FSOUND_Stream_Play(0, stream); // find number of tags FSound.FSOUND_Stream_GetNumTagFields(stream, scratch); int tagCount = scratch.get(0); System.out.println("Found: " + tagCount + " tag fields"); // print each name value pair FSoundTagField field; for(int i=0; i<tagCount; i++) { field = new FSoundTagField(); if(FSound.FSOUND_Stream_GetTagField(stream, i, field)) { System.out.println("Field " + i + ": " + field.getName() + ", " + field.getType() + ", " + field.getValueAsString() + ", " + field.getLength()); } } // trying to find the artist field System.out.println("Looking for tag..."); field = new FSoundTagField(FSound.FSOUND_TAGFIELD_ID3V1, "ARTIST"); if(FSound.FSOUND_Stream_FindTagField(stream, field)) { System.out.println("Found field: " + field.getName() + ", " + field.getType() + ", " + field.getValueAsString() + ", " + field.getLength()); } 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(); } } |
|
From: Brian M. <ma...@us...> - 2004-10-16 01:02:19
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23491 Modified Files: org_lwjgl_fmod3_FSound.c Log Message: tagfields implemented Index: org_lwjgl_fmod3_FSound.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FSound.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_fmod3_FSound.c 10 Sep 2004 21:58:11 -0000 1.2 +++ org_lwjgl_fmod3_FSound.c 16 Oct 2004 01:02:10 -0000 1.3 @@ -1086,10 +1086,22 @@ * Method: nFSOUND_Stream_FindTagField * Signature: (JILjava/lang/String;Lorg/lwjgl/fmod_instance/FSoundTagField;)Z */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Stream_1FindTagField(JNIEnv * env, jclass clazz, jlong p1, jint p2, jstring p3, jobject p4) { - //XXX - throwFMODException(env, "missing implementation"); - return false; +JNIEXPORT jboolean JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Stream_1FindTagField(JNIEnv * env, jclass clazz, jlong stream, jint type, jstring name, jobject tagField) { + const char * nName = (*env)->GetStringUTFChars(env, name, 0); + bool result = false; + void* value; + jint length; + + if(fmod_instance->FSOUND_Stream_FindTagField((FSOUND_STREAM*) stream, type, nName, &value, &length)) { + + // get set method and call it + jclass cls = (*env)->GetObjectClass(env, tagField); + jmethodID mid = (*env)->GetMethodID(env, cls, "set", "(Ljava/lang/String;Ljava/nio/ByteBuffer;I)V"); + (*env)->CallVoidMethod(env, tagField, mid, name, safeNewBuffer(env, value, length), type); + result = true; + } + (*env)->ReleaseStringUTFChars (env, name, nName); + return result; } /* @@ -1195,10 +1207,23 @@ * Method: nFSOUND_Stream_GetTagField * Signature: (JILorg/lwjgl/fmod_instance/FSoundTagField;)Z */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Stream_1GetTagField(JNIEnv * env, jclass clazz, jlong p1, jint p2, jobject p3) { - //XXX - throwFMODException(env, "missing implementation"); - return false; +JNIEXPORT jboolean JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Stream_1GetTagField(JNIEnv * env, jclass clazz, jlong stream, jint num, jobject tagField) { + jint type; + char* name; + void* value; + jint length; + + if(fmod_instance->FSOUND_Stream_GetTagField((FSOUND_STREAM*) stream, num, &type, &name, &value, &length)) { + // create string instance of name + jstring nName = (*env)->NewStringUTF(env, name); + + // get set method and call it + jclass cls = (*env)->GetObjectClass(env, tagField); + jmethodID mid = (*env)->GetMethodID(env, cls, "set", "(Ljava/lang/String;Ljava/nio/ByteBuffer;I)V"); + (*env)->CallVoidMethod(env, tagField, mid, nName, safeNewBuffer(env, value, length), type); + return true; + } + return false; } /* |
|
From: Brian M. <ma...@us...> - 2004-10-16 01:01:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23265/src/java/org/lwjgl/fmod3 Modified Files: FSound.java FSoundTagField.java Log Message: tagfields implemented Index: FSound.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/fmod3/FSound.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- FSound.java 2 Oct 2004 21:06:23 -0000 1.11 +++ FSound.java 16 Oct 2004 01:01:10 -0000 1.12 @@ -2368,7 +2368,6 @@ * Get a tag field associated with an open stream * <p> * <b>Remarks</b> - * Do not attempt to modify or free any pointers returned by this function. * If this function returns successfully, "value" will contain a pointer to a piece of tag-field-specific data - do not assume it will always point to a null-terminated ASCII string. * @param stream The stream to get the tag field from. * @param num The number of the tag field to retrieve. Index: FSoundTagField.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/fmod3/FSoundTagField.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- FSoundTagField.java 12 Jun 2004 20:28:21 -0000 1.2 +++ FSoundTagField.java 16 Oct 2004 01:01:10 -0000 1.3 @@ -55,6 +55,12 @@ /** Type of tagfield */ int type; + + /** + * Creates a new FSoundTagField + */ + public FSoundTagField() { + } /** * Creates a new FSoundTagField @@ -65,36 +71,53 @@ } /** - * Sets the value and length + * Sets the name value and type + * @param name name of tagfield * @param value value of tagfield - * @param lenght length of data + * @param type type of tagfield */ - void set(ByteBuffer value, int lenght) { + void set(String name, ByteBuffer value, int type) { + this.name = name; this.value = value; - this.length = lenght; + this.length = value.capacity(); + this.type = type; } + /** * @return Returns the length. */ public int getLength() { return length; } + /** * @return Returns the name. */ public String getName() { return name; } + /** * @return Returns the type. */ public int getType() { return type; } + /** * @return Returns the value. */ public ByteBuffer getValue() { - return value; + return value.asReadOnlyBuffer(); } + + /** + * @value as string + */ + public String getValueAsString() { + byte[] buffer = new byte[value.capacity()]; + value.get(buffer); + value.rewind(); + return new String(buffer); + } } \ No newline at end of file |
|
From: Elias N. <eli...@us...> - 2004-10-15 21:32:18
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1760/linux Modified Files: org_lwjgl_input_Keyboard.c Log Message: Minor linux keyboard input fixes Index: org_lwjgl_input_Keyboard.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Keyboard.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- org_lwjgl_input_Keyboard.c 27 Sep 2004 13:20:27 -0000 1.7 +++ org_lwjgl_input_Keyboard.c 15 Oct 2004 21:31:46 -0000 1.8 @@ -143,30 +143,27 @@ putEvent(&event_queue, event_list); } -static int translateEvent(XKeyEvent *event, jint keycode, jint state) { - static char temp_translation_buffer[KEYBOARD_BUFFER_SIZE]; +static void translateEvent(XKeyEvent *event, jint keycode, jint state) { static XComposeStatus status; + char temp_translation_buffer[KEYBOARD_BUFFER_SIZE]; int num_chars, i; jint ch; if (!translation_enabled || event->type == KeyRelease) { putKeyboardEvent(keycode, state, 0); - return 0; + return; } num_chars = XLookupString(event, temp_translation_buffer, KEYBOARD_BUFFER_SIZE, NULL, &status); if (num_chars > 0) { - num_chars--; - /* Assume little endian byte order */ - ch = (jint)temp_translation_buffer[0] & 0xFF; + ch = ((jint)temp_translation_buffer[0]) & 0xFF; putKeyboardEvent(keycode, state, ch); - for (i = 0; i < num_chars; i++) { - ch = ((jint)temp_translation_buffer[i + 1]) & 0xFF; + for (i = 1; i < num_chars; i++) { + ch = ((jint)temp_translation_buffer[i]) & 0xFF; putKeyboardEvent(0, 0, ch); } } else { putKeyboardEvent(keycode, state, 0); } - return num_chars; } static unsigned char eventState(XKeyEvent *event) { |
|
From: Elias N. <eli...@us...> - 2004-10-15 07:35:00
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5165/src/java/org/lwjgl Modified Files: BufferUtils.java Log Message: Added BufferUtils.createDoubleBuffer. Fixed comments Index: BufferUtils.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/BufferUtils.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- BufferUtils.java 12 Jun 2004 20:28:20 -0000 1.4 +++ BufferUtils.java 14 Oct 2004 20:59:13 -0000 1.5 @@ -35,6 +35,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; +import java.nio.DoubleBuffer; import java.nio.IntBuffer; import java.nio.ShortBuffer; @@ -69,7 +70,7 @@ } /** - * Construct a direct native-order shortbuffer with the specified number + * Construct a direct native-order intbuffer with the specified number * of elements. * @param size The size, in ints * @return an IntBuffer @@ -79,7 +80,7 @@ } /** - * Construct a direct native-order shortbuffer with the specified number + * Construct a direct native-order floatbuffer with the specified number * of elements. * @param size The size, in floats * @return a FloatBuffer @@ -89,6 +90,16 @@ } /** + * Construct a direct native-order doublebuffer with the specified number + * of elements. + * @param size The size, in floats + * @return a FloatBuffer + */ + public static DoubleBuffer createDoubleBuffer(int size) { + return createByteBuffer(size << 3).asDoubleBuffer(); + } + + /** * A helper function which is used to get the byte offset in an arbitrary buffer * based on its position * @return the position of the buffer, in BYTES |
|
From: Elias N. <eli...@us...> - 2004-10-13 10:56:02
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6695/linux Modified Files: org_lwjgl_input_Mouse.c Log Message: Linux: minor linux fix Index: org_lwjgl_input_Mouse.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- org_lwjgl_input_Mouse.c 30 Sep 2004 12:31:59 -0000 1.15 +++ org_lwjgl_input_Mouse.c 13 Oct 2004 10:55:49 -0000 1.16 @@ -395,7 +395,7 @@ setGrab(new_grab == JNI_TRUE ? true : false); resetCursorToCenter(); + accum_dx = accum_dy = 0; XQueryPointer(getDisplay(), getCurrentWindow(), &root_return, &child_return, &root_x, &root_y, &win_x, &win_y, &mask_return); doHandlePointerMotion(root_x, root_y, win_x, win_y); - accum_dx = accum_dy = 0; } |
Update of /cvsroot/java-game-lib/LWJGL/www/images/projects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22703 Added Files: starship2d_1.jpg starship2d_2.jpg starship2d_3.jpg starship2d_small_1.jpg starship2d_small_2.jpg starship2d_small_3.jpg Log Message: added Starship2D --- NEW FILE: starship2d_2.jpg --- (This appears to be a binary file; contents omitted.) --- NEW FILE: starship2d_small_2.jpg --- (This appears to be a binary file; contents omitted.) --- NEW FILE: starship2d_3.jpg --- (This appears to be a binary file; contents omitted.) --- NEW FILE: starship2d_1.jpg --- (This appears to be a binary file; contents omitted.) --- NEW FILE: starship2d_small_1.jpg --- (This appears to be a binary file; contents omitted.) --- NEW FILE: starship2d_small_3.jpg --- (This appears to be a binary file; contents omitted.) |
|
From: Brian M. <ma...@us...> - 2004-10-11 05:54:25
|
Update of /cvsroot/java-game-lib/LWJGL/www/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22532 Modified Files: projects.php Log Message: added Starship2D Index: projects.php =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/www/include/projects.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- projects.php 4 Apr 2004 10:22:16 -0000 1.1 +++ projects.php 11 Oct 2004 05:54:12 -0000 1.2 @@ -48,7 +48,17 @@ "Free, open source game", "Vermin ExTerminator is a free multiplayer network game. It's a 2D real-time first-person shooter. Little worms (vermins) fight against each other using hand guns, rifles, grenades or rockets. In other words the game is mix of liero and a real-time worms. The game is written in Java with LWJGL as OpenGL and OpenAL interface. The development is open source and still in progress and till now Vermin ExTerminator is only in alpha version.", array ("Vermins", 800, 600, 150, 112), - array ("Vermins", 800, 600, 150, 112)); + array ("Vermins", 800, 600, 150, 112)); + + $projects[4] = array( + "StarShip2D", + "http://www.drx.dk/starship2d.html", + "http://www.drx.dk/starship2d.html", + "Free, open source game", + "StarShip2D is a 2d scroller game, where you shoot incomming enemies with your cannon or powerfull rockets.", + array ("starship2d", 640, 480, 162, 122), + array ("starship2d", 640, 480, 162, 122), + array ("starship2d", 640, 480, 162, 122)); // ------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////////// |
|
From: Brian M. <ma...@us...> - 2004-10-06 20:15:34
|
Update of /cvsroot/java-game-lib/LWJGL/www/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31271 Modified Files: default.php Log Message: no, we dont want any donations! fu paypal! Index: default.php =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/www/include/default.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- default.php 21 Jun 2004 21:53:04 -0000 1.4 +++ default.php 6 Oct 2004 20:15:24 -0000 1.5 @@ -63,8 +63,10 @@ echo " <br><br>\n"; echo " <a href=\"http://java.net\" target=\"blank\"><img src=\"images/javanet_button_90.gif\" width=\"90\" height=\"25\" border=\"0\" alt=\"java.net logo\" title=\"java.net member\"/></a>\n"; echo " <!-- donation -->\n"; + echo " <!--\n"; echo " <br><br>\n"; echo " <a href=\"http://sourceforge.net/donate/index.php?group_id=58488\" target=\"blank\"><img src=\"http://images.sourceforge.net/images/project-support.jpg\" width=\"88\" height=\"32\" border=\"0\" alt=\"Support This Project\" title=\"Donate to LWJGL\"/></a>\n"; + echo " -->\n"; echo " <!-- SF icon -->\n"; echo " <br><br>\n"; echo " <a href=\"http://sourceforge.net\" target=\"blank\"><img src=\"http://sourceforge.net/sflogo.php?group_id=58488&type=1\" width=\"88\" height=\"31\" border=\"0\" alt=\"SourceForge.net Logo\" title=\"SourceForge.net Logo\"/></a>\n"; |
|
From: Brian M. <ma...@us...> - 2004-10-06 20:14:44
|
Update of /cvsroot/java-game-lib/LWJGL/www In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31051 Modified Files: index.php Log Message: no, we dont want any donations! fu paypal! Index: index.php =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/www/index.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- index.php 29 Apr 2004 20:52:24 -0000 1.2 +++ index.php 6 Oct 2004 20:14:34 -0000 1.3 @@ -27,7 +27,7 @@ </p> <p> LWJGL is available under a BSD license, which means it's open source and freely available - at no charge. However, we won't mind a <a href="http://sourceforge.net/donate/index.php?group_id=58488">donation</a>. + at no charge. </p> <p> Please visit us on the Freenode IRC Network: <a href="irc://irc.freenode.net/lwjgl">#LWJGL</a>. Do idle if there is no one to answer any of your questions, we are on different timezones. |
|
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 |
|
From: Brian M. <ma...@us...> - 2004-10-02 21:07:49
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25516/src/java/org/lwjgl/fmod3 Modified Files: FSound.java Log Message: fixed SetPriority/GetActive name mangling Index: FSound.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/fmod3/FSound.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- FSound.java 28 Sep 2004 06:10:46 -0000 1.10 +++ FSound.java 2 Oct 2004 21:06:23 -0000 1.11 @@ -3023,7 +3023,7 @@ * @param unit DSP unit to have its priority changed * @param priority Order in the priority chain. Valid numbers are 0 to 1000, 0 being highest priority (first), with 1000 being lowest priority (last). */ - public static void FSOUND_DSP_GetActive(FSoundDSPUnit unit, int priority) { + public static void FSOUND_DSP_SetPriority(FSoundDSPUnit unit, int priority) { nFSOUND_DSP_SetPriority(unit.dspHandle, priority); } private static native void nFSOUND_DSP_SetPriority(ByteBuffer dspUnitHandle, int priority); |
|
From: Ioannis T. <sp...@us...> - 2004-10-01 16:03:25
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4021 Modified Files: GLContext.java Added Files: ATITextureCompression3DC.java Log Message: Added ATI_texture_compression_3dc Index: GLContext.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GLContext.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- GLContext.java 13 Sep 2004 08:04:33 -0000 1.31 +++ GLContext.java 1 Oct 2004 16:03:14 -0000 1.32 @@ -131,6 +131,7 @@ public static boolean GL_ATI_map_object_buffer; public static boolean GL_ATI_pn_triangles; public static boolean GL_ATI_separate_stencil; + public static boolean GL_ATI_texture_compression_3dc; public static boolean GL_ATI_texture_float; public static boolean GL_ATI_texture_mirror_once; public static boolean GL_ATI_vertex_array_object; --- NEW FILE: ATITextureCompression3DC.java --- /* * Copyright (c) 2002-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.opengl; public final class ATITextureCompression3DC { public static final int GL_COMPRESSED_RGB_3DC_ATI = 0x8837; private ATITextureCompression3DC() { } } |