mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-05 06:25:46 +00:00
Removed devil and fmod support. yay.
This commit is contained in:
parent
7fe1db23ec
commit
dc3999b075
72 changed files with 3 additions and 16618 deletions
|
|
@ -1,610 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2005 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.devil;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.BufferChecks;
|
||||
import org.lwjgl.LWJGLException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The core DevIL API.
|
||||
* </p>
|
||||
*
|
||||
* @author captainjester <captainjester@users.sourceforge.net>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class IL {
|
||||
|
||||
public static final int IL_FALSE = 0;
|
||||
public static final int IL_TRUE = 1;
|
||||
|
||||
// Matches OpenGL's right now.
|
||||
public static final int IL_COLOUR_INDEX = 0x1900;
|
||||
public static final int IL_COLOR_INDEX = 0x1900;
|
||||
public static final int IL_RGB = 0x1907;
|
||||
public static final int IL_RGBA = 0x1908;
|
||||
public static final int IL_BGR = 0x80E0;
|
||||
public static final int IL_BGRA = 0x80E1;
|
||||
public static final int IL_LUMINANCE = 0x1909;
|
||||
public static final int IL_BYTE = 0x1400;
|
||||
|
||||
public static final int IL_UNSIGNED_BYTE = 0x1401;
|
||||
public static final int IL_SHORT = 0x1402;
|
||||
public static final int IL_UNSIGNED_SHORT = 0x1403;
|
||||
public static final int IL_INT = 0x1404;
|
||||
public static final int IL_UNSIGNED_INT = 0x1405;
|
||||
public static final int IL_FLOAT = 0x1406;
|
||||
public static final int IL_DOUBLE = 0x140A;
|
||||
public static final int IL_VENDOR = 0x1F00;
|
||||
|
||||
// IL-specific public const's
|
||||
public static final int IL_LOAD_EXT = 0x1F01;
|
||||
public static final int IL_SAVE_EXT = 0x1F02;
|
||||
|
||||
// Attribute Bits
|
||||
public static final int IL_ORIGIN_BIT = 0x1;
|
||||
public static final int IL_FILE_BIT = 0x2;
|
||||
public static final int IL_PAL_BIT = 0x4;
|
||||
public static final int IL_FORMAT_BIT = 0x8;
|
||||
public static final int IL_TYPE_BIT = 0x10;
|
||||
public static final int IL_COMPRESS_BIT = 0x20;
|
||||
public static final int IL_LOADFAIL_BIT = 0x40;
|
||||
public static final int IL_FORMAT_SPECIFIC_BIT = 0x80;
|
||||
public static final int IL_ALL_ATTRIB_BITS = 0xFFFFF;
|
||||
|
||||
// Palette types
|
||||
public static final int IL_PAL_NONE = 0x400;
|
||||
public static final int IL_PAL_RGB24 = 0x401;
|
||||
public static final int IL_PAL_RGB32 = 0x402;
|
||||
public static final int IL_PAL_RGBA32 = 0x403;
|
||||
public static final int IL_PAL_BGR24 = 0x404;
|
||||
public static final int IL_PAL_BGR32 = 0x405;
|
||||
public static final int IL_PAL_BGRA32 = 0x406;
|
||||
|
||||
// Image types
|
||||
public static final int IL_TYPE_UNKNOWN = 0x0;
|
||||
public static final int IL_BMP = 0x420;
|
||||
public static final int IL_CUT = 0x421;
|
||||
public static final int IL_DOOM = 0x422;
|
||||
public static final int IL_DOOM_FLAT = 0x423;
|
||||
public static final int IL_ICO = 0x424;
|
||||
public static final int IL_JPG = 0x425;
|
||||
public static final int IL_LBM = 0x426;
|
||||
public static final int IL_PCD = 0x427;
|
||||
public static final int IL_PCX = 0x428;
|
||||
public static final int IL_PIC = 0x429;
|
||||
public static final int IL_PNG = 0x42A;
|
||||
public static final int IL_PNM = 0x42B;
|
||||
public static final int IL_SGI = 0x42C;
|
||||
public static final int IL_TGA = 0x42D;
|
||||
public static final int IL_TIF = 0x42E;
|
||||
public static final int IL_CHEAD = 0x42F;
|
||||
public static final int IL_RAW = 0x430;
|
||||
public static final int IL_MDL = 0x431;
|
||||
public static final int IL_WAL = 0x432;
|
||||
public static final int IL_OIL = 0x433;
|
||||
public static final int IL_LIF = 0x434;
|
||||
public static final int IL_MNG = 0x435;
|
||||
public static final int IL_JNG = 0x435;
|
||||
public static final int IL_GIF = 0x436;
|
||||
public static final int IL_DDS = 0x437;
|
||||
public static final int IL_DCX = 0x438;
|
||||
public static final int IL_PSD = 0x439;
|
||||
public static final int IL_EXIF = 0x43A;
|
||||
public static final int IL_PSP = 0x43B;
|
||||
public static final int IL_PIX = 0x43C;
|
||||
public static final int IL_PXR = 0x43D;
|
||||
public static final int IL_XPM = 0x43E;
|
||||
public static final int IL_JASC_PAL = 0x475;
|
||||
|
||||
// Error Types
|
||||
public static final int IL_NO_ERROR = 0x0;
|
||||
public static final int IL_INVALID_ENUM = 0x501;
|
||||
public static final int IL_OUT_OF_MEMORY = 0x502;
|
||||
public static final int IL_FORMAT_NOT_SUPPORTED = 0x503;
|
||||
public static final int IL_INTERNAL_ERROR = 0x504;
|
||||
public static final int IL_INVALID_VALUE = 0x505;
|
||||
public static final int IL_ILLEGAL_OPERATION = 0x506;
|
||||
public static final int IL_ILLEGAL_FILE_VALUE = 0x507;
|
||||
public static final int IL_INVALID_FILE_HEADER = 0x508;
|
||||
public static final int IL_INVALID_PARAM = 0x509;
|
||||
public static final int IL_COULD_NOT_OPEN_FILE = 0x50A;
|
||||
public static final int IL_INVALID_EXTENSION = 0x50B;
|
||||
public static final int IL_FILE_ALREADY_EXISTS = 0x50C;
|
||||
public static final int IL_OUT_FORMAT_SAME = 0x50D;
|
||||
public static final int IL_STACK_OVERFLOW = 0x50E;
|
||||
public static final int IL_STACK_UNDERFLOW = 0x50F;
|
||||
public static final int IL_INVALID_CONVERSION = 0x510;
|
||||
public static final int IL_BAD_DIMENSIONS = 0x511;
|
||||
public static final int IL_FILE_READ_ERROR = 0x512;
|
||||
public static final int IL_LIB_GIF_ERROR = 0x5E1;
|
||||
public static final int IL_LIB_JPEG_ERROR = 0x5E2;
|
||||
public static final int IL_LIB_PNG_ERROR = 0x5E3;
|
||||
public static final int IL_LIB_TIFF_ERROR = 0x5E4;
|
||||
public static final int IL_LIB_MNG_ERROR = 0x5E5;
|
||||
public static final int IL_UNKNOWN_ERROR = 0x5FF;
|
||||
|
||||
// Origin Definitions
|
||||
public static final int IL_ORIGIN_SET = 0x600;
|
||||
public static final int IL_ORIGIN_LOWER_LEFT = 0x601;
|
||||
public static final int IL_ORIGIN_UPPER_LEFT = 0x602;
|
||||
public static final int IL_ORIGIN_MODE = 0x603;
|
||||
|
||||
// Format and Type Mode Definitions
|
||||
public static final int IL_FORMAT_SET = 0x610;
|
||||
public static final int IL_FORMAT_MODE = 0x611;
|
||||
public static final int IL_TYPE_SET = 0x612;
|
||||
public static final int IL_TYPE_MODE = 0x613;
|
||||
|
||||
// File definitions
|
||||
public static final int IL_FILE_OVERWRITE = 0x620;
|
||||
public static final int IL_FILE_MODE = 0x621;
|
||||
|
||||
// Palette definitions
|
||||
public static final int IL_CONV_PAL = 0x630;
|
||||
|
||||
// Load fail definitions
|
||||
public static final int IL_DEFAULT_ON_FAIL = 0x632;
|
||||
|
||||
// Key colour definitions
|
||||
public static final int IL_USE_KEY_COLOUR = 0x635;
|
||||
public static final int IL_USE_KEY_COLOR = 0x635;
|
||||
|
||||
// Interlace definitions
|
||||
public static final int IL_SAVE_INTERLACED = 0x639;
|
||||
public static final int IL_INTERLACE_MODE = 0x63A;
|
||||
|
||||
// Quantization definitions
|
||||
public static final int IL_QUANTIZATION_MODE = 0x640;
|
||||
public static final int IL_WU_QUANT = 0x641;
|
||||
public static final int IL_NEU_QUANT = 0x642;
|
||||
public static final int IL_NEU_QUANT_SAMPLE = 0x643;
|
||||
|
||||
// Hints
|
||||
public static final int IL_FASTEST = 0x660;
|
||||
public static final int IL_LESS_MEM = 0x661;
|
||||
public static final int IL_DONT_CARE = 0x662;
|
||||
public static final int IL_MEM_SPEED_HINT = 0x665;
|
||||
public static final int IL_USE_COMPRESSION = 0x666;
|
||||
public static final int IL_NO_COMPRESSION = 0x667;
|
||||
public static final int IL_COMPRESSION_HINT = 0x668;
|
||||
|
||||
// Subimage types
|
||||
public static final int IL_SUB_NEXT = 0x680;
|
||||
public static final int IL_SUB_MIPMAP = 0x681;
|
||||
public static final int IL_SUB_LAYER = 0x682;
|
||||
|
||||
// Compression definitions (mostly for .oil)
|
||||
public static final int IL_COMPRESS_MODE = 0x700;
|
||||
public static final int IL_COMPRESS_NONE = 0x701;
|
||||
public static final int IL_COMPRESS_RLE = 0x702;
|
||||
public static final int IL_COMPRESS_LZO = 0x703;
|
||||
public static final int IL_COMPRESS_ZLIB = 0x704;
|
||||
|
||||
// File format-specific values
|
||||
public static final int IL_TGA_CREATE_STAMP = 0x710;
|
||||
public static final int IL_JPG_QUALITY = 0x711;
|
||||
public static final int IL_PNG_INTERLACE = 0x712;
|
||||
public static final int IL_TGA_RLE = 0x713;
|
||||
public static final int IL_BMP_RLE = 0x714;
|
||||
public static final int IL_SGI_RLE = 0x715;
|
||||
public static final int IL_TGA_ID_STRING = 0x717;
|
||||
public static final int IL_TGA_AUTHNAME_STRING = 0x718;
|
||||
public static final int IL_TGA_AUTHCOMMENT_STRING = 0x719;
|
||||
public static final int IL_PNG_AUTHNAME_STRING = 0x71A;
|
||||
public static final int IL_PNG_TITLE_STRING = 0x71B;
|
||||
public static final int IL_PNG_DESCRIPTION_STRING = 0x71C;
|
||||
public static final int IL_TIF_DESCRIPTION_STRING = 0x71D;
|
||||
public static final int IL_TIF_HOSTCOMPUTER_STRING = 0x71E;
|
||||
public static final int IL_TIF_DOCUMENTNAME_STRING = 0x71F;
|
||||
public static final int IL_TIF_AUTHNAME_STRING = 0x720;
|
||||
public static final int IL_JPG_SAVE_FORMAT = 0x721;
|
||||
public static final int IL_CHEAD_HEADER_STRING = 0x722;
|
||||
public static final int IL_PCD_PICNUM = 0x723;
|
||||
|
||||
// DXTC definitions
|
||||
public static final int IL_DXTC_FORMAT = 0x705;
|
||||
public static final int IL_DXT1 = 0x706;
|
||||
public static final int IL_DXT2 = 0x707;
|
||||
public static final int IL_DXT3 = 0x708;
|
||||
public static final int IL_DXT4 = 0x709;
|
||||
public static final int IL_DXT5 = 0x70A;
|
||||
public static final int IL_DXT_NO_COMP = 0x70B;
|
||||
public static final int IL_KEEP_DXTC_DATA = 0x70C;
|
||||
public static final int IL_DXTC_DATA_FORMAT = 0x70D;
|
||||
|
||||
// Cube map definitions
|
||||
public static final int IL_CUBEMAP_POSITIVEX = 0x400;
|
||||
public static final int IL_CUBEMAP_NEGATIVEX = 0x800;
|
||||
public static final int IL_CUBEMAP_POSITIVEY = 0x1000;
|
||||
public static final int IL_CUBEMAP_NEGATIVEY = 0x2000;
|
||||
public static final int IL_CUBEMAP_POSITIVEZ = 0x4000;
|
||||
public static final int IL_CUBEMAP_NEGATIVEZ = 0x8000;
|
||||
|
||||
// Values
|
||||
public static final int IL_VERSION_NUM = 0xDE2;
|
||||
public static final int IL_IMAGE_WIDTH = 0xDE4;
|
||||
public static final int IL_IMAGE_HEIGHT = 0xDE5;
|
||||
public static final int IL_IMAGE_DEPTH = 0xDE6;
|
||||
public static final int IL_IMAGE_SIZE_OF_DATA = 0xDE7;
|
||||
public static final int IL_IMAGE_BPP = 0xDE8;
|
||||
public static final int IL_IMAGE_BYTES_PER_PIXEL = 0xDE8;
|
||||
public static final int IL_IMAGE_BITS_PER_PIXEL = 0xDE9;
|
||||
public static final int IL_IMAGE_FORMAT = 0xDEA;
|
||||
public static final int IL_IMAGE_TYPE = 0xDEB;
|
||||
public static final int IL_PALETTE_TYPE = 0xDEC;
|
||||
public static final int IL_PALETTE_SIZE = 0xDED;
|
||||
public static final int IL_PALETTE_BPP = 0xDEE;
|
||||
public static final int IL_PALETTE_NUM_COLS = 0xDEF;
|
||||
public static final int IL_PALETTE_BASE_TYPE = 0xDF0;
|
||||
public static final int IL_NUM_IMAGES = 0xDF1;
|
||||
public static final int IL_NUM_MIPMAPS = 0xDF2;
|
||||
public static final int IL_NUM_LAYERS = 0xDF3;
|
||||
public static final int IL_ACTIVE_IMAGE = 0xDF4;
|
||||
public static final int IL_ACTIVE_MIPMAP = 0xDF5;
|
||||
public static final int IL_ACTIVE_LAYER = 0xDF6;
|
||||
public static final int IL_CUR_IMAGE = 0xDF7;
|
||||
public static final int IL_IMAGE_DURATION = 0xDF8;
|
||||
public static final int IL_IMAGE_PLANESIZE = 0xDF9;
|
||||
public static final int IL_IMAGE_BPC = 0xDFA;
|
||||
public static final int IL_IMAGE_OFFX = 0xDFB;
|
||||
public static final int IL_IMAGE_OFFY = 0xDFC;
|
||||
public static final int IL_IMAGE_CUBEFLAGS = 0xDFD;
|
||||
public static final int IL_SEEK_SET = 0;
|
||||
public static final int IL_SEEK_CUR = 1;
|
||||
public static final int IL_SEEK_END = 2;
|
||||
public static final int IL_EOF = -1;
|
||||
|
||||
/**
|
||||
* Return the version of the DevIL-LWJGL binding as a String.
|
||||
*/
|
||||
public static String getVersion() {
|
||||
return ILNative.VERSION;
|
||||
}
|
||||
|
||||
public static native boolean ilActiveImage(int Number);
|
||||
public static native boolean ilActiveLayer(int Number);
|
||||
public static native boolean ilActiveMipmap(int Number);
|
||||
public static native boolean ilApplyPal(String FileName);
|
||||
public static native boolean ilApplyProfile(String InProfile, String OutProfile);
|
||||
public static native void ilBindImage(int image);
|
||||
public static native boolean ilBlit(int Source, int DestX, int DestY,
|
||||
int DestZ, int SrcX, int SrcY, int SrcZ,
|
||||
int Width, int Height, int Depth);
|
||||
public static native void ilClearColour(float Red, float Green, float Blue, float Alpha);
|
||||
public static native boolean ilClearImage();
|
||||
public static native int ilCloneCurImage();
|
||||
public static native boolean ilCompressFunc(int Mode);
|
||||
public static native boolean ilConvertImage(int DestFormat, int DestType);
|
||||
public static native boolean ilConvertPal(int DestFormat);
|
||||
public static native boolean ilCopyImage(int Src);
|
||||
public static int ilCopyPixels( int XOff, int YOff, int ZOff,
|
||||
int Width, int Height, int Depth,
|
||||
int Format, int Type, ByteBuffer Data) {
|
||||
BufferChecks.checkDirect(Data);
|
||||
return nilCopyPixels(XOff, YOff, ZOff, Width, Height, Depth, Format, Type, Data, Data.position());
|
||||
}
|
||||
|
||||
private static native int nilCopyPixels(int XOff, int YOff, int ZOff, int Width,
|
||||
int Height, int Depth, int Format,
|
||||
int Type, ByteBuffer Data, int data_offset);
|
||||
|
||||
public static native int ilCreateSubImage(int Type, int Num);
|
||||
public static native boolean ilDefaultImage();
|
||||
public static void ilDeleteImages(IntBuffer images) {
|
||||
BufferChecks.checkDirect(images);
|
||||
nilDeleteImages(images.remaining(), images, images.position());
|
||||
}
|
||||
|
||||
private static native void nilDeleteImages(int num, IntBuffer images, int images_offset);
|
||||
public static native boolean ilDisable(int Mode);
|
||||
public static native boolean ilEnable(int Mode);
|
||||
public static native boolean ilFormatFunc(int Mode);
|
||||
public static void ilGenImages(IntBuffer images) {
|
||||
BufferChecks.checkDirect(images);
|
||||
nilGenImages(images.remaining(), images, images.position());
|
||||
}
|
||||
private static native void nilGenImages(int num, IntBuffer images, int images_offset);
|
||||
|
||||
public static native ByteBuffer ilGetAlpha(int Type);
|
||||
public static native void ilModAlpha(int AlphaValue);
|
||||
public static native void ilSetAlpha(int AlphaValue);
|
||||
public static native boolean ilGetBoolean(int Mode);
|
||||
public static void ilGetBooleanv(int mode, ByteBuffer param) {
|
||||
nilGetBooleanv(mode, param, param.position());
|
||||
}
|
||||
private static native void nilGetBooleanv(int mode, ByteBuffer param, int position);
|
||||
public static void ilGetIntegerv(int mode, IntBuffer param) {
|
||||
nilGetIntegerv(mode, param, param.position());
|
||||
}
|
||||
private static native void nilGetIntegerv(int mode, IntBuffer param, int position);
|
||||
|
||||
public static native ByteBuffer ilGetData();
|
||||
public static native int ilGetError();
|
||||
public static native int ilGetInteger(int mode);
|
||||
public static native int ilGetLumpPos();
|
||||
public static native ByteBuffer ilGetPalette();
|
||||
public static native String ilGetString(int StringName);
|
||||
public static native void ilHint(int Target, int Mode);
|
||||
static native void ilInit();
|
||||
public static native boolean ilIsDisabled(int Mode);
|
||||
public static native boolean ilIsEnabled(int Mode);
|
||||
public static native boolean ilIsImage(int Image);
|
||||
public static native boolean ilIsValid(int Type, String FileName);
|
||||
public static boolean ilIsValidL(int Type, ByteBuffer Lump) {
|
||||
BufferChecks.checkDirect(Lump);
|
||||
return nilIsValidL(Type, Lump, Lump.position(), Lump.remaining());
|
||||
}
|
||||
private static native boolean nilIsValidL(int Type, ByteBuffer Lump, int lump_offset, int Size);
|
||||
|
||||
public static native void ilKeyColour(float Red, float Green, float Blue, float Alpha);
|
||||
public static native boolean ilLoad(int Type, String FileName);
|
||||
public static native boolean ilLoadImage(String fileName);
|
||||
public static boolean ilLoadL(int Type, ByteBuffer Lump) {
|
||||
BufferChecks.checkDirect(Lump);
|
||||
return nilLoadL(Type, Lump, Lump.position(), Lump.remaining());
|
||||
}
|
||||
|
||||
private static native boolean nilLoadL(int Type, ByteBuffer Lump, int lump_offset, int Size);
|
||||
public static native boolean ilLoadPal(String FileName);
|
||||
public static native boolean ilOriginFunc(int Mode);
|
||||
public static native boolean ilOverlayImage(int Source, int XCoord, int YCoord, int ZCoord);
|
||||
public static native void ilPopAttrib();
|
||||
public static native void ilPushAttrib(int Bits);
|
||||
public static native boolean ilRemoveLoad(String Ext);
|
||||
public static native boolean ilRemoveSave(String Ext);
|
||||
public static native void ilResetMemory();
|
||||
public static native void ilResetRead();
|
||||
public static native void ilResetWrite();
|
||||
public static native boolean ilSave(int Type, String FileName);
|
||||
public static native boolean ilSaveImage(String FileName);
|
||||
public static int ilSaveL(int Type, ByteBuffer Lump) {
|
||||
BufferChecks.checkDirect(Lump);
|
||||
return nilSaveL(Type, Lump, Lump.position(), Lump.remaining());
|
||||
}
|
||||
private static native int nilSaveL(int Type, ByteBuffer Lump, int lump_offset, int Size);
|
||||
|
||||
public static native boolean ilSavePal(String FileName);
|
||||
public static boolean ilSetData(ByteBuffer Data) {
|
||||
BufferChecks.checkDirect(Data);
|
||||
return nilSetData(Data, Data.position());
|
||||
}
|
||||
private static native boolean nilSetData(ByteBuffer Data, int data_offset);
|
||||
|
||||
public static native boolean ilSetDuration(int Duration);
|
||||
public static native void ilSetInteger(int Mode, int Param);
|
||||
public static void ilSetPixels( int XOff, int YOff, int ZOff, int Width,
|
||||
int Height, int Depth, int Format, int Type, ByteBuffer Data) {
|
||||
BufferChecks.checkDirect(Data);
|
||||
nilSetPixels(XOff, YOff, ZOff, Width, Height, Depth, Format, Type, Data, Data.position());
|
||||
}
|
||||
private static native void nilSetPixels(int XOff, int YOff, int ZOff, int Width,
|
||||
int Height, int Depth, int Format,
|
||||
int Type, ByteBuffer Data, int data_offset);
|
||||
|
||||
public static native void ilSetString(int Mode, String string);
|
||||
public static native void ilShutDown();
|
||||
public static boolean ilTexImage( int Width, int Height, int Depth, byte Bpp,
|
||||
int Format, int Type, ByteBuffer Data) {
|
||||
BufferChecks.checkDirect(Data);
|
||||
return nilTexImage(Width, Height, Depth, Bpp, Format, Type, Data, Data.position());
|
||||
}
|
||||
|
||||
private static native boolean nilTexImage(int Width, int Height, int Depth, byte Bpp,
|
||||
int Format, int Type, ByteBuffer Data, int data_offset);
|
||||
|
||||
public static native boolean ilTypeFunc(int Mode);
|
||||
public static native boolean ilLoadData(String FileName, int Width, int Height, int Depth, byte Bpp);
|
||||
|
||||
public static boolean ilLoadDataL(ByteBuffer Lump, int Size, int Width, int Height, int Depth, byte Bpp) {
|
||||
BufferChecks.checkDirect(Lump);
|
||||
return nilLoadDataL(Lump, Lump.position(), Size, Width, Height, Depth, Bpp);
|
||||
}
|
||||
private static native boolean nilLoadDataL(ByteBuffer Lump, int lump_offset, int Size, int Width, int Height,
|
||||
int Depth, byte Bpp);
|
||||
|
||||
public static native boolean ilSaveData(String FileName);
|
||||
|
||||
/**
|
||||
* Determines the IL type for file passed
|
||||
*
|
||||
* @param filename File to determine type for
|
||||
* @return IL type, or IL_TYPE_UNKNOWN if undeterminable
|
||||
*/
|
||||
public static int ilGetType(String extension) {
|
||||
// Save having to use equalsIgnoreCase all the time
|
||||
extension = extension.toLowerCase();
|
||||
int type = IL_TYPE_UNKNOWN;
|
||||
|
||||
if (extension.equals("bmp")) {
|
||||
type = IL_BMP;
|
||||
} else if (extension.equals("cut")) {
|
||||
type = IL_CUT;
|
||||
} else if (extension.equals("gif")) {
|
||||
type = IL_GIF;
|
||||
} else if (extension.equals("ico")) {
|
||||
type = IL_ICO;
|
||||
} else if (extension.equals("jpg")) {
|
||||
type = IL_JPG;
|
||||
} else if (extension.equals("lif")) {
|
||||
type = IL_LIF;
|
||||
} else if (extension.equals("mng")) {
|
||||
type = IL_MNG;
|
||||
} else if (extension.equals("pcd")) {
|
||||
type = IL_PCD;
|
||||
} else if (extension.equals("pcx")) {
|
||||
type = IL_PCX;
|
||||
} else if (extension.equals("pic")) {
|
||||
type = IL_PIC;
|
||||
} else if (extension.equals("png")) {
|
||||
type = IL_PNG;
|
||||
} else if (extension.equals("pbm") || extension.equals("pgm")
|
||||
|| extension.equals("ppm")) {
|
||||
type = IL_PNM;
|
||||
} else if (extension.equals("psd")) {
|
||||
type = IL_PSD;
|
||||
} else if (extension.equals("psp")) {
|
||||
type = IL_PSP;
|
||||
} else if (extension.equals("bw") || extension.equals("rgb")
|
||||
|| extension.equals("rgba") || extension.equals("sgi")) {
|
||||
type = IL_SGI;
|
||||
} else if (extension.equals("tga")) {
|
||||
type = IL_TGA;
|
||||
} else if (extension.equals("tif") || extension.equals("tiff")) {
|
||||
type = IL_TIF;
|
||||
} else if (extension.equals("dds")) {
|
||||
type = IL_DDS;
|
||||
} else if (extension.equals("raw")) {
|
||||
type = IL_RAW;
|
||||
} else if (extension.equals("lbm")) {
|
||||
type = IL_LBM;
|
||||
} else if (extension.equals("jng")) {
|
||||
type = IL_JNG;
|
||||
} else if (extension.equals("wal")) {
|
||||
type = IL_WAL;
|
||||
} else if (extension.equals("pix")) {
|
||||
type = IL_PIX;
|
||||
} else if (extension.equals("mdl")) {
|
||||
type = IL_MDL;
|
||||
} else if (extension.equals("exif")) {
|
||||
type = IL_EXIF;
|
||||
} else if (extension.equals("oil")) {
|
||||
type = IL_OIL;
|
||||
} else if (extension.equals("dcx")) {
|
||||
type = IL_DCX;
|
||||
} else if (extension.equals("pxr")) {
|
||||
type = IL_PXR;
|
||||
} else if (extension.equals("xpm")) {
|
||||
type = IL_XPM;
|
||||
} else if (extension.equals("pal")) {
|
||||
type = IL_JASC_PAL;
|
||||
} else if (extension.equals("h")) {
|
||||
type = IL_CHEAD;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads an image from the specified url
|
||||
*
|
||||
* @param url URL to load from
|
||||
* @return true if image was loaded
|
||||
*/
|
||||
public static boolean ilLoadFromURL(URL url) throws IOException {
|
||||
int type = IL_TYPE_UNKNOWN;
|
||||
|
||||
String file = url.toString();
|
||||
int index = file.lastIndexOf('.');
|
||||
if (index != -1) {
|
||||
String extension = file.substring(index + 1);
|
||||
type = ilGetType(extension);
|
||||
}
|
||||
return ilLoadFromStream(url.openStream(), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an image from an inputstream
|
||||
*
|
||||
* @param stream Stream to read from
|
||||
* @param type Type of image to expect
|
||||
* @return true if image was loaded
|
||||
*/
|
||||
public static boolean ilLoadFromStream(InputStream stream, int type) throws IOException {
|
||||
boolean result = false;
|
||||
int lastRead = 0;
|
||||
byte[] buffer = new byte[4096];
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
BufferedInputStream buf = new BufferedInputStream(stream);
|
||||
|
||||
try {
|
||||
while((lastRead = buf.read(buffer, 0, buffer.length)) != -1) {
|
||||
baos.write(buffer, 0, lastRead);
|
||||
}
|
||||
|
||||
buffer = baos.toByteArray();
|
||||
ByteBuffer lump = ByteBuffer.allocateDirect(buffer.length);
|
||||
lump.put(buffer);
|
||||
lump.flip();
|
||||
result = ilLoadL(type, lump);
|
||||
} catch (IOException e) {
|
||||
try {
|
||||
buf.close();
|
||||
} catch (IOException f ) {}
|
||||
throw e;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Have we been created? */
|
||||
protected static boolean created;
|
||||
|
||||
/**
|
||||
* Creates a new instance of IL.
|
||||
*/
|
||||
public static void create() throws LWJGLException {
|
||||
if (created) {
|
||||
return;
|
||||
}
|
||||
|
||||
ILNative.createIL();
|
||||
created = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit cleanly by calling destroy.
|
||||
*/
|
||||
public static void destroy() {
|
||||
if (created) {
|
||||
ILNative.destroyIL();
|
||||
created = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if DevIL has been created
|
||||
*/
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,214 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2005 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.devil;
|
||||
|
||||
import java.io.File;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Native interface for DevIL
|
||||
* </p>
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
class ILNative {
|
||||
|
||||
/** The native JNI library name */
|
||||
private static String JNI_LIBRARY_NAME = "lwjgl-devil";
|
||||
|
||||
/** Version of IL */
|
||||
static final String VERSION = "1.1.4";
|
||||
|
||||
/** Current version of the JNI library */
|
||||
static final int JNI_VERSION = 2;
|
||||
|
||||
private static void loadLibrary(final String lib_name) {
|
||||
AccessController.doPrivileged(new PrivilegedAction() {
|
||||
public Object run() {
|
||||
String library_path = System.getProperty("org.lwjgl.librarypath");
|
||||
if (library_path != null) {
|
||||
System.load(library_path + File.separator +
|
||||
System.mapLibraryName(lib_name));
|
||||
} else {
|
||||
System.loadLibrary(lib_name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
loadLibrary(JNI_LIBRARY_NAME);
|
||||
|
||||
// check for mismatch
|
||||
int nativeVersion = getNativeLibraryVersion();
|
||||
if (nativeVersion != JNI_VERSION) {
|
||||
throw new LinkageError(
|
||||
"Version mismatch: jar version is '" + JNI_VERSION +
|
||||
"', native libary version is '" + nativeVersion + "'");
|
||||
}
|
||||
}
|
||||
|
||||
// IL
|
||||
// ===========================================================
|
||||
static native void initNativeStubsIL(Class clazz) throws LWJGLException;
|
||||
static native void resetNativeStubsIL(Class clazz);
|
||||
static native void nCreateIL(String[] ilPaths) throws LWJGLException;
|
||||
static native void nDestroyIL();
|
||||
private static native int getNativeLibraryVersion();
|
||||
|
||||
static void createIL() throws LWJGLException {
|
||||
String libname;
|
||||
String platform_libname;
|
||||
switch (LWJGLUtil.getPlatform()) {
|
||||
case LWJGLUtil.PLATFORM_WINDOWS:
|
||||
libname = "DevIL";
|
||||
platform_libname = "DevIL.dll";
|
||||
break;
|
||||
case LWJGLUtil.PLATFORM_LINUX:
|
||||
libname = "IL";
|
||||
platform_libname = "libIL.so";
|
||||
break;
|
||||
case LWJGLUtil.PLATFORM_MACOSX:
|
||||
libname = "IL";
|
||||
platform_libname = "libIL.dylib";
|
||||
break;
|
||||
default:
|
||||
throw new LWJGLException("Unknown platform: " + LWJGLUtil.getPlatform());
|
||||
}
|
||||
String[] illPaths = LWJGLUtil.getLibraryPaths(libname, platform_libname, IL.class.getClassLoader());
|
||||
ILNative.nCreateIL(illPaths);
|
||||
|
||||
try {
|
||||
ILNative.initNativeStubsIL(IL.class);
|
||||
IL.ilInit();
|
||||
} catch (LWJGLException e) {
|
||||
IL.destroy();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyIL() {
|
||||
ILNative.resetNativeStubsIL(IL.class);
|
||||
ILNative.nDestroyIL();
|
||||
}
|
||||
// -----------------------------------------------------------
|
||||
|
||||
|
||||
// ILU
|
||||
// ===========================================================
|
||||
static native void initNativeStubsILU(Class clazz) throws LWJGLException;
|
||||
static native void resetNativeStubsILU(Class clazz);
|
||||
static native void nCreateILU(String[] iluPaths) throws LWJGLException;
|
||||
static native void nDestroyILU();
|
||||
|
||||
static void createILU() throws LWJGLException {
|
||||
String libname;
|
||||
switch (LWJGLUtil.getPlatform()) {
|
||||
case LWJGLUtil.PLATFORM_WINDOWS:
|
||||
libname = "ILU.dll";
|
||||
break;
|
||||
case LWJGLUtil.PLATFORM_LINUX:
|
||||
libname = "libILU.so";
|
||||
break;
|
||||
case LWJGLUtil.PLATFORM_MACOSX:
|
||||
libname = "libILU.dylib";
|
||||
break;
|
||||
default:
|
||||
throw new LWJGLException("Unknown platform: " + LWJGLUtil.getPlatform());
|
||||
}
|
||||
|
||||
String[] iluPaths = LWJGLUtil.getLibraryPaths("ILU", libname, ILU.class.getClassLoader());
|
||||
ILNative.nCreateILU(iluPaths);
|
||||
|
||||
try {
|
||||
ILNative.initNativeStubsILU(ILU.class);
|
||||
ILU.iluInit();
|
||||
} catch (LWJGLException e) {
|
||||
ILU.destroy();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyILU() {
|
||||
ILNative.resetNativeStubsILU(ILU.class);
|
||||
ILNative.nDestroyILU();
|
||||
}
|
||||
// -----------------------------------------------------------
|
||||
|
||||
// ILU
|
||||
// ===========================================================
|
||||
static native void initNativeStubsILUT(Class clazz) throws LWJGLException;
|
||||
static native void resetNativeStubsILUT(Class clazz);
|
||||
static native void nCreateILUT(String[] ilutPaths) throws LWJGLException;
|
||||
static native void nDestroyILUT();
|
||||
|
||||
static void createILUT() throws LWJGLException {
|
||||
String libname;
|
||||
switch (LWJGLUtil.getPlatform()) {
|
||||
case LWJGLUtil.PLATFORM_WINDOWS:
|
||||
libname = "ILUT.dll";
|
||||
break;
|
||||
case LWJGLUtil.PLATFORM_LINUX:
|
||||
libname = "libILUT.so";
|
||||
break;
|
||||
case LWJGLUtil.PLATFORM_MACOSX:
|
||||
libname = "libILUT.dylib";
|
||||
break;
|
||||
default:
|
||||
throw new LWJGLException("Unknown platform: " + LWJGLUtil.getPlatform());
|
||||
}
|
||||
String[] ilutPaths = LWJGLUtil.getLibraryPaths("ILUT", libname, ILUT.class.getClassLoader());
|
||||
ILNative.nCreateILUT(ilutPaths);
|
||||
|
||||
try {
|
||||
ILNative.initNativeStubsILUT(ILUT.class);
|
||||
ILUT.ilutInit();
|
||||
} catch (LWJGLException e) {
|
||||
ILUT.destroy();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyILUT() {
|
||||
ILNative.resetNativeStubsILUT(ILUT.class);
|
||||
ILNative.nDestroyILUT();
|
||||
}
|
||||
// -----------------------------------------------------------
|
||||
}
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2005 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.devil;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.BufferChecks;
|
||||
import org.lwjgl.LWJGLException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The DevIL ILU API.
|
||||
* </p>
|
||||
*
|
||||
* @author captainjester <captainjester@users.sourceforge.net>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class ILU {
|
||||
|
||||
public static final int ILU_FILTER = 0x2600;
|
||||
public static final int ILU_NEAREST = 0x2601;
|
||||
public static final int ILU_LINEAR = 0x2602;
|
||||
public static final int ILU_BILINEAR = 0x2603;
|
||||
public static final int ILU_SCALE_BOX = 0x2604;
|
||||
public static final int ILU_SCALE_TRIANGLE = 0x2605;
|
||||
public static final int ILU_SCALE_BELL = 0x2606;
|
||||
public static final int ILU_SCALE_BSPLINE = 0x2607;
|
||||
public static final int ILU_SCALE_LANCZOS3 = 0x2608;
|
||||
public static final int ILU_SCALE_MITCHELL = 0x2609;
|
||||
|
||||
// Error types
|
||||
public static final int ILU_INVALID_ENUM = 0x0501;
|
||||
public static final int ILU_OUT_OF_MEMORY = 0x0502;
|
||||
public static final int ILU_INTERNAL_ERROR = 0x0504;
|
||||
public static final int ILU_INVALID_VALUE = 0x0505;
|
||||
public static final int ILU_ILLEGAL_OPERATION = 0x0506;
|
||||
public static final int ILU_INVALID_PARAM = 0x0509;
|
||||
|
||||
// Values
|
||||
public static final int ILU_PLACEMENT = 0x0700;
|
||||
public static final int ILU_LOWER_LEFT = 0x0701;
|
||||
public static final int ILU_LOWER_RIGHT = 0x0702;
|
||||
public static final int ILU_UPPER_LEFT = 0x0703;
|
||||
public static final int ILU_UPPER_RIGHT = 0x0704;
|
||||
public static final int ILU_CENTER = 0x0705;
|
||||
public static final int ILU_CONVOLUTION_MATRIX = 0x0710;
|
||||
public static final int ILU_VERSION_NUM = IL.IL_VERSION_NUM;
|
||||
public static final int ILU_VENDOR = IL.IL_VENDOR;
|
||||
|
||||
public static native boolean iluAlienify();
|
||||
public static native boolean iluBlurAvg(int iter);
|
||||
public static native boolean iluBlurGaussian(int iter);
|
||||
public static native boolean iluBuildMipmaps();
|
||||
public static native int iluColoursUsed();
|
||||
public static native boolean iluCompareImage(int comp);
|
||||
public static native boolean iluContrast(float contrast);
|
||||
public static native boolean iluCrop(int xOff, int yOff, int zOff, int width, int height, int depth);
|
||||
public static native void iluDeleteImage(int id);
|
||||
public static native boolean iluEdgeDetectE();
|
||||
public static native boolean iluEdgeDetectP();
|
||||
public static native boolean iluEdgeDetectS();
|
||||
public static native boolean iluEmboss();
|
||||
public static native boolean iluEnlargeCanvas(int width, int height, int depth);
|
||||
public static native boolean iluEnlargeImage(float xDim, float yDim, float zDim);
|
||||
public static native boolean iluEqualize();
|
||||
public static native String iluErrorString(int error);
|
||||
public static native boolean iluFlipImage();
|
||||
public static native boolean iluGammaCorrect(float gamma);
|
||||
public static native int iluGenImage();
|
||||
public static native void iluGetImageInfo(ILinfo info);
|
||||
public static native int iluGetInteger(int mode);
|
||||
public static void iluGetIntegerv(int mode, IntBuffer param) {
|
||||
BufferChecks.checkDirect(param);
|
||||
niluGetIntegerv(mode, param, param.position());
|
||||
}
|
||||
private static native void niluGetIntegerv(int mode, IntBuffer param, int param_offset);
|
||||
public static native String iluGetString(int stringName);
|
||||
public static native void iluImageParameter(int pName, int param);
|
||||
static native void iluInit();
|
||||
public static native boolean iluInvertAlpha();
|
||||
public static native int iluLoadImage(String fileName);
|
||||
public static native boolean iluMirror();
|
||||
public static native boolean iluNegative();
|
||||
public static native boolean iluNoisify(float tolerance);
|
||||
public static native boolean iluPixelize(int pixSize);
|
||||
public static native boolean iluReplaceColour(byte red, byte green, byte blue, float tolerance);
|
||||
public static native boolean iluRotate(float angle);
|
||||
public static native boolean iluSaturate1f(float saturation);
|
||||
public static native boolean iluSaturate4f(float r, float g, float b, float saturation);
|
||||
public static native boolean iluScale(int width, int height, int depth);
|
||||
public static native boolean iluScaleColours(float r, float g, float b);
|
||||
public static native boolean iluSharpen(float factor, int iter);
|
||||
public static native boolean iluSwapColours();
|
||||
public static native boolean iluWave(float angle);
|
||||
|
||||
// public static native void iluRegionfv(ILpointf points[], int n);
|
||||
// public static native void iluRegioniv(ILpointi points[], int n);
|
||||
// public static native boolean iluRotate3D(float x, float y, float z, float Angle);
|
||||
|
||||
/* DevIL lib allows both spellings of colour. We support that too */
|
||||
// ========================================================================
|
||||
public static void iluColorsUsed() {
|
||||
iluColoursUsed();
|
||||
}
|
||||
public static void iluSwapColors() {
|
||||
iluSwapColours();
|
||||
}
|
||||
public static void iluReplaceColor(byte red, byte green, byte blue, float tolerance) {
|
||||
iluReplaceColour(red, green, blue, tolerance);
|
||||
}
|
||||
public static void iluScaleColors(float r, float g, float b) {
|
||||
iluScaleColours(r, g, b);
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** Have we been created? */
|
||||
protected static boolean created;
|
||||
|
||||
/**
|
||||
* Creates a new instance of ILU. Cannot be created unless IL has been created.
|
||||
*/
|
||||
public static void create() throws LWJGLException {
|
||||
if(!IL.isCreated()) {
|
||||
throw new LWJGLException("Cannot create ILU without having created IL instance");
|
||||
}
|
||||
|
||||
ILNative.createILU();
|
||||
created = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit cleanly by calling destroy.
|
||||
*/
|
||||
public static void destroy() {
|
||||
if (created) {
|
||||
ILNative.destroyILU();
|
||||
created = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if ILU has been created
|
||||
*/
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2005 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.devil;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The DevIL ILUT API.
|
||||
* </p>
|
||||
*
|
||||
* @author captainjester <captainjester@users.sourceforge.net>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class ILUT {
|
||||
|
||||
// Attribute Bits
|
||||
public static final int ILUT_OPENGL_BIT = 0x00000001;
|
||||
public static final int ILUT_ALL_ATTRIB_BITS = 0x000FFFFF;
|
||||
|
||||
|
||||
// Error Types
|
||||
public static final int ILUT_INVALID_ENUM = 0x0501;
|
||||
public static final int ILUT_OUT_OF_MEMORY = 0x0502;
|
||||
public static final int ILUT_INVALID_VALUE = 0x0505;
|
||||
public static final int ILUT_ILLEGAL_OPERATION = 0x0506;
|
||||
public static final int ILUT_INVALID_PARAM = 0x0509;
|
||||
public static final int ILUT_COULD_NOT_OPEN_FILE = 0x050A;
|
||||
public static final int ILUT_STACK_OVERFLOW = 0x050E;
|
||||
public static final int ILUT_STACK_UNDERFLOW = 0x050F;
|
||||
public static final int ILUT_BAD_DIMENSIONS = 0x0511;
|
||||
public static final int ILUT_NOT_SUPPORTED = 0x0550;
|
||||
|
||||
|
||||
// State Definitions
|
||||
public static final int ILUT_PALETTE_MODE = 0x0600;
|
||||
public static final int ILUT_OPENGL_CONV = 0x0610;
|
||||
public static final int ILUT_MAXTEX_WIDTH = 0x0630;
|
||||
public static final int ILUT_MAXTEX_HEIGHT = 0x0631;
|
||||
public static final int ILUT_MAXTEX_DEPTH = 0x0632;
|
||||
public static final int ILUT_GL_USE_S3TC = 0x0634;
|
||||
public static final int ILUT_GL_GEN_S3TC = 0x0635;
|
||||
public static final int ILUT_GL_AUTODETECT_TEXTURE_TARGET = 0x0807;
|
||||
|
||||
// The different rendering api's...more to be added later?
|
||||
public static final int ILUT_OPENGL = 0;
|
||||
|
||||
public static final int ILUT_VENDOR = IL.IL_VENDOR;
|
||||
public static final int ILUT_VERSION_NUM = IL.IL_VERSION_NUM;
|
||||
|
||||
public static native boolean ilutRenderer(int renderer);
|
||||
public static native boolean ilutDisable(int mode);
|
||||
public static native boolean ilutEnable(int mode);
|
||||
public static native boolean ilutGetBoolean(int mode);
|
||||
public static native int ilutGetInteger(int mode);
|
||||
public static native void ilutGetBooleanv(int mode, ByteBuffer param);
|
||||
public static native void ilutGetIntegerv(int mode, IntBuffer Param);
|
||||
public static native String ilutGetString(int stringName);
|
||||
static native void ilutInit();
|
||||
public static native boolean ilutIsDisabled(int mode);
|
||||
public static native boolean ilutIsEnabled(int mode);
|
||||
public static native void ilutPopAttrib();
|
||||
public static native void ilutPushAttrib(int bits);
|
||||
public static native void ilutSetInteger(int Mode, int param);
|
||||
|
||||
|
||||
// ImageLib Utility Toolkit's OpenGL Functions
|
||||
public static native int ilutGLBindTexImage();
|
||||
public static native int ilutGLBindMipmaps();
|
||||
public static native boolean ilutGLBuildMipmaps();
|
||||
public static native int ilutGLLoadImage(String fileName);
|
||||
public static native boolean ilutGLScreen();
|
||||
public static native boolean ilutGLScreenie();
|
||||
public static native boolean ilutGLSaveImage(String fileName, int texID);
|
||||
public static native boolean ilutGLSetTex(int texID);
|
||||
public static native boolean ilutGLTexImage(int level);
|
||||
|
||||
/** Have we been created? */
|
||||
protected static boolean created;
|
||||
|
||||
/**
|
||||
* Creates a new instance of ILUT. Cannot be created unless IL has been created.
|
||||
*/
|
||||
public static void create() throws LWJGLException {
|
||||
if(!IL.isCreated()) {
|
||||
throw new LWJGLException("Cannot create ILUT without having created IL instance");
|
||||
}
|
||||
|
||||
if(!ILU.isCreated()) {
|
||||
throw new LWJGLException("Cannot create ILUT without having created ILU instance");
|
||||
}
|
||||
|
||||
ILNative.createILUT();
|
||||
created = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit cleanly by calling destroy.
|
||||
*/
|
||||
public static void destroy() {
|
||||
if (created) {
|
||||
ILNative.destroyILUT();
|
||||
created = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if ILUT has been created
|
||||
*/
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2005 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.devil;
|
||||
|
||||
/**
|
||||
*
|
||||
* ILinfo information holding class.
|
||||
*
|
||||
* @author captainjester <captainjester@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class ILinfo {
|
||||
public int id; // the image's id
|
||||
public byte data[]; // the image's data
|
||||
public int width; // the image's width
|
||||
public int height; // the image's height
|
||||
public int depth; // the image's depth
|
||||
public byte bpp; // bytes per pixel (not bits) of the image
|
||||
public int sizeOfData; // the total size of the data (in bytes)
|
||||
public int format; // image format (in IL enum style)
|
||||
public int type; // image type (in IL enum style)
|
||||
public int origin; // origin of the image
|
||||
public byte palette[]; // the image's palette
|
||||
public int palType; // palette type
|
||||
public int palSize; // palette size
|
||||
public int cubeFlags; // flags for what cube map sides are present
|
||||
public int numNext; // number of images following
|
||||
public int numMips; // number of mipmaps
|
||||
public int numLayers; // number of layers
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2005 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.devil;
|
||||
|
||||
/**
|
||||
*
|
||||
* ILpointf information holding class.
|
||||
*
|
||||
* @author captainjester <captainjester@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class ILpointf {
|
||||
public float x;
|
||||
public float y;
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2005 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.devil;
|
||||
|
||||
/**
|
||||
*
|
||||
* ILpointi information holding class.
|
||||
*
|
||||
* @author captainjester <captainjester@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class ILpointi {
|
||||
public int x;
|
||||
public int y;
|
||||
}
|
||||
|
|
@ -1,402 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
|
||||
/**
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class FMOD {
|
||||
|
||||
/** Array of hashmaps for callbacks */
|
||||
private static HashMap[] callbacks = new HashMap[17];
|
||||
|
||||
/** FMOD System level clear dsp unit */
|
||||
static FSoundDSPUnit fmodClearUnit;
|
||||
|
||||
/** FMOD System level clip and copy dsp unit */
|
||||
static FSoundDSPUnit fmodClipAndCopyUnit;
|
||||
|
||||
/** FMOD System level music dsp unit */
|
||||
static FSoundDSPUnit fmodMusicUnit;
|
||||
|
||||
/** FMOD System level sound effects dsp unit */
|
||||
static FSoundDSPUnit fmodSFXUnit;
|
||||
|
||||
/** FMOD System level FFT dsp unit */
|
||||
static FSoundDSPUnit fmodFFTUnit;
|
||||
|
||||
/** FMOD System level FFT buffer */
|
||||
static FloatBuffer fmodFFTBuffer;
|
||||
|
||||
/** Type defining the music callback entries in callback hashmap array */
|
||||
public static final int FMUSIC_INSTCALLBACK = 0;
|
||||
|
||||
/** Type defining the music callback entries in callback hashmap array */
|
||||
public static final int FMUSIC_ORDERCALLBACK = 1;
|
||||
|
||||
/** Type defining the music callback entries in callback hashmap array */
|
||||
public static final int FMUSIC_ROWCALLBACK = 2;
|
||||
|
||||
/** Type defining the music callback entries in callback hashmap array */
|
||||
public static final int FMUSIC_ZXXCALLBACK = 3;
|
||||
|
||||
|
||||
/** Type defining the dsp callback entries in callback hashmap array */
|
||||
public static final int FSOUND_DSPCALLBACK = 4;
|
||||
|
||||
/** Type defining the stream callback entries in callback hashmap array */
|
||||
public static final int FSOUND_STREAMCALLBACK = 5;
|
||||
|
||||
/** Type defining the alloc callback entries in callback hashmap array */
|
||||
public static final int FSOUND_ALLOCCALLBACK = 6;
|
||||
|
||||
/** Type defining the realloc callback entries in callback hashmap array */
|
||||
public static final int FSOUND_REALLOCCALLBACK = 7;
|
||||
|
||||
/** Type defining the free callback entries in callback hashmap array */
|
||||
public static final int FSOUND_FREECALLBACK = 8;
|
||||
|
||||
/** Type defining the open callback entries in callback hashmap array */
|
||||
public static final int FSOUND_OPENCALLBACK = 9;
|
||||
|
||||
/** Type defining the close callback entries in callback hashmap array */
|
||||
public static final int FSOUND_CLOSECALLBACK = 10;
|
||||
|
||||
/** Type defining the metadata callback entries in callback hashmap array */
|
||||
public static final int FSOUND_METADATACALLBACK = 11;
|
||||
|
||||
/** Type defining the read callback entries in callback hashmap array */
|
||||
public static final int FSOUND_READCALLBACK = 12;
|
||||
|
||||
/** Type defining the seek callback entries in callback hashmap array */
|
||||
public static final int FSOUND_SEEKCALLBACK = 13;
|
||||
|
||||
/** Type defining the tell callback entries in callback hashmap array */
|
||||
public static final int FSOUND_TELLCALLBACK = 14;
|
||||
|
||||
/** Type defining the "end" callback entries in callback hashmap array */
|
||||
public static final int FSOUND_ENDCALLBACK = 15;
|
||||
|
||||
/** Type defining the "sync" callback entries in callback hashmap array */
|
||||
public static final int FSOUND_SYNCCALLBACK = 16;
|
||||
|
||||
/** Have we been created? */
|
||||
protected static boolean created;
|
||||
|
||||
/** No errors */
|
||||
public static final int FMOD_ERR_NONE = 0;
|
||||
|
||||
/** Cannot call this command after FSOUND_Init. Call FSOUND_Close first. */
|
||||
public static final int FMOD_ERR_BUSY = 1;
|
||||
|
||||
/** This command failed because FSOUND_Init was not called */
|
||||
public static final int FMOD_ERR_UNINITIALIZED = 2;
|
||||
|
||||
/** Error initializing output device. */
|
||||
public static final int FMOD_ERR_INIT = 3;
|
||||
|
||||
/** Error initializing output device, but more specifically, the output device is already in use and cannot be reused. */
|
||||
public static final int FMOD_ERR_ALLOCATED = 4;
|
||||
|
||||
/** Playing the sound failed. */
|
||||
public static final int FMOD_ERR_PLAY = 5;
|
||||
|
||||
/** Soundcard does not support the features needed for this soundsystem (16bit stereo output) */
|
||||
public static final int FMOD_ERR_OUTPUT_FORMAT = 6;
|
||||
|
||||
/** Error setting cooperative level for hardware. */
|
||||
public static final int FMOD_ERR_COOPERATIVELEVEL = 7;
|
||||
|
||||
/** Error creating hardware sound buffer. */
|
||||
public static final int FMOD_ERR_CREATEBUFFER = 8;
|
||||
|
||||
/** File not found */
|
||||
public static final int FMOD_ERR_FILE_NOTFOUND = 9;
|
||||
|
||||
/** Unknown file format */
|
||||
public static final int FMOD_ERR_FILE_FORMAT = 10;
|
||||
|
||||
/** Error loading file */
|
||||
public static final int FMOD_ERR_FILE_BAD = 11;
|
||||
|
||||
/** Not enough memory */
|
||||
public static final int FMOD_ERR_MEMORY = 12;
|
||||
|
||||
/** The version number of this file format is not supported */
|
||||
public static final int FMOD_ERR_VERSION = 13;
|
||||
|
||||
/** An invalid parameter was passed to this function */
|
||||
public static final int FMOD_ERR_INVALID_PARAM = 14;
|
||||
|
||||
/** Tried to use an EAX command on a non EAX enabled channel or output. */
|
||||
public static final int FMOD_ERR_NO_EAX = 15;
|
||||
|
||||
/** Failed to allocate a new channel */
|
||||
public static final int FMOD_ERR_CHANNEL_ALLOC = 17;
|
||||
|
||||
/** Recording is not supported on this machine */
|
||||
public static final int FMOD_ERR_RECORD = 18;
|
||||
|
||||
/** Required Mediaplayer codec is not installed */
|
||||
public static final int FMOD_ERR_MEDIAPLAYER = 19;
|
||||
|
||||
/** An error occured trying to open the specified CD device */
|
||||
public static final int FMOD_ERR_CDDEVICE = 20;
|
||||
|
||||
/** Whether we have been initialized */
|
||||
private static boolean initialized;
|
||||
|
||||
/** The native JNI library name */
|
||||
private static String JNI_LIBRARY_NAME = "lwjgl-fmod3";
|
||||
|
||||
/** Version of FMOD */
|
||||
private static final String VERSION = "1.1.4";
|
||||
|
||||
/** Current version of the JNI library */
|
||||
static final int JNI_VERSION = 1;
|
||||
|
||||
static {
|
||||
initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the FMOD binding
|
||||
*/
|
||||
static void initialize() {
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
initialized = true;
|
||||
|
||||
loadLibrary(JNI_LIBRARY_NAME);
|
||||
|
||||
// check for mismatch
|
||||
int nativeVersion = getNativeLibraryVersion();
|
||||
if (nativeVersion != JNI_VERSION) {
|
||||
throw new LinkageError(
|
||||
"Version mismatch: jar version is '" + JNI_VERSION +
|
||||
"', native libary version is '" + nativeVersion + "'");
|
||||
}
|
||||
|
||||
// Initialize callback hashmaps
|
||||
for(int i=0; i<callbacks.length; i++) {
|
||||
callbacks[i] = new HashMap();
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadLibrary(final String lib_name) {
|
||||
AccessController.doPrivileged(new PrivilegedAction() {
|
||||
public Object run() {
|
||||
String library_path = System.getProperty("org.lwjgl.librarypath");
|
||||
if (library_path != null) {
|
||||
System.load(library_path + File.separator +
|
||||
System.mapLibraryName(lib_name));
|
||||
} else {
|
||||
System.loadLibrary(lib_name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the version of the FMOD3-LWJGL binding as a String.
|
||||
*/
|
||||
public static String getVersion() {
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the version of the native library
|
||||
*/
|
||||
private static native int getNativeLibraryVersion();
|
||||
|
||||
/**
|
||||
* @return true if AL has been created
|
||||
*/
|
||||
public static boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an FMOD instance.
|
||||
*/
|
||||
public static void create() throws FMODException {
|
||||
if (created) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
String libname;
|
||||
switch (LWJGLUtil.getPlatform()) {
|
||||
case LWJGLUtil.PLATFORM_WINDOWS:
|
||||
libname = "fmod.dll";
|
||||
break;
|
||||
case LWJGLUtil.PLATFORM_LINUX:
|
||||
libname = "libfmod.so";
|
||||
break;
|
||||
case LWJGLUtil.PLATFORM_MACOSX:
|
||||
libname = "static-ignored";
|
||||
break;
|
||||
default:
|
||||
throw new FMODException("Unknown platform: " + LWJGLUtil.getPlatform());
|
||||
}
|
||||
String[] fmodPaths = LWJGLUtil.getLibraryPaths("fmod", libname, FMOD.class.getClassLoader());
|
||||
LWJGLUtil.log("Found " + fmodPaths.length + " FMOD paths");
|
||||
nCreate(fmodPaths);
|
||||
created = true;
|
||||
} catch (LWJGLException le) {
|
||||
throw new FMODException(le.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method to create FMOD instance
|
||||
*/
|
||||
protected static native void nCreate(String[] paths);
|
||||
|
||||
/**
|
||||
* Exit cleanly by calling destroy.
|
||||
*/
|
||||
public static void destroy() {
|
||||
if(!created) {
|
||||
return;
|
||||
}
|
||||
|
||||
FSound.FSOUND_Close();
|
||||
FMusic.FMUSIC_StopAllSongs();
|
||||
|
||||
created = false;
|
||||
nDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to locate FMOD from the JWS Library path
|
||||
* This method exists because FMOD is loaded from native code, and as such
|
||||
* is exempt from JWS library loading rutines. FMOD therefore always fails.
|
||||
* We therefore invoke the protected method of the JWS classloader to see if it can
|
||||
* locate it.
|
||||
*
|
||||
* @param libname Name of library to search for
|
||||
* @return Absolute path to library if found, otherwise null
|
||||
*/
|
||||
private static String getPathFromJWS(String libname) {
|
||||
try {
|
||||
LWJGLUtil.log("getPathFromJWS: searching for: " + libname);
|
||||
Object o = FMOD.class.getClassLoader();
|
||||
Class c = o.getClass();
|
||||
Method findLibrary =
|
||||
c.getMethod("findLibrary", new Class[] { String.class });
|
||||
Object[] arguments = new Object[] { libname };
|
||||
return (String) findLibrary.invoke(o, arguments);
|
||||
|
||||
} catch (Exception e) {
|
||||
LWJGLUtil.log("Failure locating FMOD using classloader:" + e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method the destroy the FMOD
|
||||
*/
|
||||
protected static native void nDestroy();
|
||||
|
||||
/**
|
||||
* Registers a callback by its handle
|
||||
*
|
||||
* @param handle Handle to native object being monitored
|
||||
* @param callbackHandler Object to register as the call back handler
|
||||
*/
|
||||
static void registerCallback(int type, long handle, Object handled, Object callbackHandler) {
|
||||
Long callbackID = new Long(handle);
|
||||
ArrayList callbackList = (ArrayList) callbacks[type].get(callbackID);
|
||||
|
||||
if (callbackList == null ) {
|
||||
if (callbackHandler == null) {
|
||||
LWJGLUtil.log("No callbackhandlers registered for handle: " + handle);
|
||||
} else {
|
||||
callbackList = new ArrayList();
|
||||
callbacks[type].put(callbackID, callbackList);
|
||||
}
|
||||
}
|
||||
|
||||
// are we going to add or remove from the list?
|
||||
if(callbackHandler == null) {
|
||||
callbacks[type].remove(callbackID);
|
||||
} else {
|
||||
callbackList.add(new FMOD.WrappedCallback(handled, callbackHandler));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a call back handler by its native handle
|
||||
* @param handle Handle to native object being monitored
|
||||
* @return Call back handler, or null if no such handler
|
||||
*/
|
||||
static ArrayList getCallbacks(int type, long handle) {
|
||||
return (ArrayList) callbacks[type].get(new Long(handle));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the errorcode desription for specified code
|
||||
*
|
||||
* @param errorcode errorcode to lookup
|
||||
* @return Description of errorcode
|
||||
*/
|
||||
public static native String FMOD_ErrorString(int errorcode);
|
||||
|
||||
/**
|
||||
* Wrapper class for a callback handler, and the object associated
|
||||
*/
|
||||
static class WrappedCallback {
|
||||
Object handled;
|
||||
Object callback;
|
||||
WrappedCallback(Object handled, Object callback) {
|
||||
this.handled = handled;
|
||||
this.callback = callback;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
|
||||
/**
|
||||
* FMOD Exception specific for FMOD exceptions (duh!)
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class FMODException extends LWJGLException {
|
||||
|
||||
private static final long serialVersionUID = -1979225393145509886L;
|
||||
|
||||
/**
|
||||
* Creates a new FMODException
|
||||
*
|
||||
* @param msg Message describing nature of exception
|
||||
*/
|
||||
public FMODException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,804 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.lwjgl.fmod3.callbacks.FMusicCallback;
|
||||
|
||||
/**
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class FMusic {
|
||||
|
||||
/** No song being played */
|
||||
public static final int FMUSIC_TYPE_NONE = 0;
|
||||
|
||||
/** Protracker / Fasttracker */
|
||||
public static final int FMUSIC_TYPE_MOD = 1;
|
||||
|
||||
/** ScreamTracker 3 */
|
||||
public static final int FMUSIC_TYPE_S3M = 2;
|
||||
|
||||
/** FastTracker 2 */
|
||||
public static final int FMUSIC_TYPE_XM = 3;
|
||||
|
||||
/** Impulse Tracker */
|
||||
public static final int FMUSIC_TYPE_IT = 4;
|
||||
|
||||
/** MIDI file */
|
||||
public static final int FMUSIC_TYPE_MIDI = 5;
|
||||
|
||||
/** FMOD Sample Bank file */
|
||||
public static final int FMUSIC_TYPE_FSB = 6;
|
||||
|
||||
/**
|
||||
* To load a module or bank with a given filename. FMUSIC Supports loading of
|
||||
* - .MOD (protracker/fasttracker modules)
|
||||
* - .S3M (screamtracker 3 modules)
|
||||
* - .XM (fasttracker 2 modules)
|
||||
* - .IT (impulse tracker modules)
|
||||
* - .MID (MIDI files)
|
||||
* - .RMI (MIDI files)
|
||||
* - .SGT (DirectMusic segment files)
|
||||
* - .FSB (FMOD Sample Bank files)
|
||||
*
|
||||
* @param name Filename of module to load
|
||||
* @return On success, a FMusicModule instance is returned. On failure, Null is returned
|
||||
*/
|
||||
public static FMusicModule FMUSIC_LoadSong(String name) {
|
||||
long result = nFMUSIC_LoadSong(name);
|
||||
if(result != FMUSIC_TYPE_NONE) {
|
||||
return new FMusicModule(result, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static native long nFMUSIC_LoadSong(String name);
|
||||
|
||||
/**
|
||||
* To load a module or bank with a given filename. FMUSIC Supports loading of
|
||||
* - .MOD (protracker/fasttracker modules)
|
||||
* - .S3M (screamtracker 3 modules)
|
||||
* - .XM (fasttracker 2 modules)
|
||||
* - .IT (impulse tracker modules)
|
||||
* - .MID (MIDI files)
|
||||
* - .RMI (MIDI files)
|
||||
* - .SGT (DirectMusic segment files)
|
||||
* - .FSB (FMOD Sample Bank files)
|
||||
* <p>
|
||||
* <i>
|
||||
* Loading a song from a memory handle is dangerous in one respect, if the data is corrupted or truncated, then FMUSIC could crash internally trying to load it.
|
||||
* On PlayStation 2 the data and length pointer must be 16 byte aligned for DMA purposes.
|
||||
* The samplelist and samplelistnum parameters are useful for limiting the amount of data fmod loads. This feature is for the FSB format only. It is especially useful if you have a bank of sounds and want to randomize the loading a bit by telling which sounds to load with random values, and consequently which not to load.
|
||||
* On PlayStation 2, samplelistnum has a limit of 1536 entries.
|
||||
* </i>
|
||||
* </p>
|
||||
*
|
||||
* @param data containing song to load. On PlayStation 2 data must be 16 byte aligned if loading from memory
|
||||
* @param mode Mode for opening song. With module files, only FSOUND_LOADMEMORY, FSOUND_NONBLOCKING, FSOUND_LOOP_NORMAL, or FSOUND_LOOP_OFF are supported. For FSB files, FSOUND_2D, FSOUND_HW3D, FSOUND_FORCEMONO also work
|
||||
* @param sampleList Optional. Buffer of sample indicies to load. Leave as Null if you want all samples to be loaded (default behaviour). See Remarks for more on this
|
||||
* @return On success, a FMusicModule instance is returned. On failure, Null is returned
|
||||
*/
|
||||
public static FMusicModule FMUSIC_LoadSongEx(ByteBuffer data, int mode, IntBuffer sampleList) {
|
||||
long result = nFMUSIC_LoadSongEx(data, data.position(), data.remaining(), mode, (sampleList != null) ? sampleList : null, (sampleList != null) ? sampleList.position() : 0, (sampleList != null) ? sampleList.remaining() : 0);
|
||||
if(result != FMUSIC_TYPE_NONE) {
|
||||
return new FMusicModule(result, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #FMUSIC_LoadSongEx(ByteBuffer, int, int, int, IntBuffer)
|
||||
* @param name of song
|
||||
* @param offset Optional. 0 by default. If > 0, this value is used to specify an offset in a file, so fmod will seek before opening
|
||||
* @param length Optional. 0 by default. If > 0, this value is used to specify the length of a memory block when using FSOUND_LOADMEMORY, or it is the length of a file or file segment if the offset parameter is used. On PlayStation 2 this must be 16 byte aligned for memory loading
|
||||
* @param mode Mode for opening song. With module files, only FSOUND_LOADMEMORY, FSOUND_NONBLOCKING, FSOUND_LOOP_NORMAL, or FSOUND_LOOP_OFF are supported. For FSB files, FSOUND_2D, FSOUND_HW3D, FSOUND_FORCEMONO also work
|
||||
* @param sampleList Optional. Buffer of sample indicies to load. Leave as Null if you want all samples to be loaded (default behaviour). See Remarks for more on this
|
||||
* @return On success, a FMusicModule instance is returned. On failure, Null is returned
|
||||
*/
|
||||
public static FMusicModule FMUSIC_LoadSongEx(String name, int offset, int length, int mode, IntBuffer sampleList) {
|
||||
long result = nFMUSIC_LoadSongEx(name, offset, length, mode, (sampleList != null) ? sampleList : null, (sampleList != null) ? sampleList.position() : 0, (sampleList != null) ? sampleList.remaining() : 0);
|
||||
|
||||
if(result != FMUSIC_TYPE_NONE) {
|
||||
return new FMusicModule(result, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static native long nFMUSIC_LoadSongEx(ByteBuffer data, int offset, int length, int mode, IntBuffer sampleList, int bufferOffset, int remaining);
|
||||
private static native long nFMUSIC_LoadSongEx(String name, int offset, int length, int mode, IntBuffer sampleList, int bufferOffset, int remaining);
|
||||
|
||||
/**
|
||||
* If a mod is opened with FSOUND_NONBLOCKING, this function returns the state of the opening mod.
|
||||
* @param module Module to get the open state from
|
||||
* @return 0 = mod is opened and ready. -1 = mod handle passed in is invalid. -2 = mod is still opening -3 = mod failed to open. (file not found, out of memory or other error).
|
||||
*/
|
||||
public static int FMUSIC_GetOpenState(FMusicModule module) {
|
||||
return nFMUSIC_GetOpenState(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetOpenState(long module);
|
||||
|
||||
/**
|
||||
* Frees memory allocated for a song and removes it from the FMUSIC system
|
||||
* @param module Module to be freed
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_FreeSong(FMusicModule module) {
|
||||
// when freeing a song, we automatically deregister any callbacks
|
||||
FMOD.registerCallback(FMOD.FMUSIC_INSTCALLBACK, module.moduleHandle, null, null);
|
||||
FMOD.registerCallback(FMOD.FMUSIC_ORDERCALLBACK, module.moduleHandle, null, null);
|
||||
FMOD.registerCallback(FMOD.FMUSIC_ROWCALLBACK, module.moduleHandle, null, null);
|
||||
FMOD.registerCallback(FMOD.FMUSIC_ZXXCALLBACK, module.moduleHandle, null, null);
|
||||
module.release();
|
||||
return nFMUSIC_FreeSong(module.moduleHandle);
|
||||
}
|
||||
private static native boolean nFMUSIC_FreeSong(long module);
|
||||
|
||||
/**
|
||||
* Starts a song playing
|
||||
* @param module Module to be played
|
||||
* @return true if module succeeded playing. false if module failed playing
|
||||
*/
|
||||
public static boolean FMUSIC_PlaySong(FMusicModule module) {
|
||||
return nFMUSIC_PlaySong(module.moduleHandle);
|
||||
}
|
||||
private static native boolean nFMUSIC_PlaySong(long module);
|
||||
|
||||
/**
|
||||
* Stops a song from playing.
|
||||
* @param module Module to be stopped
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_StopSong(FMusicModule module) {
|
||||
return nFMUSIC_StopSong(module.moduleHandle);
|
||||
}
|
||||
private static native boolean nFMUSIC_StopSong(long module);
|
||||
|
||||
/**
|
||||
* Stops all songs from playing. This is useful if you have multiple songs playing at once and
|
||||
* want a quick way to stop them
|
||||
*/
|
||||
public static native void FMUSIC_StopAllSongs();
|
||||
|
||||
/**
|
||||
* Sets a user callback for any Zxx commands encountered in an S3M, XM or IT file.
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* The value passed into the param parameter of the callback is the xx value specified in the Zxx
|
||||
* command by the musician
|
||||
* ------------
|
||||
* It is important to note that this callback will be called from directly WITHIN the
|
||||
* mixer / music update thread, therefore it is imperative that whatever you do from this
|
||||
* callback be extremely efficient. If the routine takes too long then breakups in the sound
|
||||
* will occur, or it will basically stop mixing until you return from the function.
|
||||
* This sort of function is usually best for just setting a flag, or do some simple variable
|
||||
* manipulation, and then exiting, letting your main thread do what it needs to based on these
|
||||
* flags or variables.
|
||||
* ------------
|
||||
* This callback is LATENCY adjusted, so that the callback happens when you HEAR the sound, not when it is mixed, for accurate synchronization.
|
||||
* Use FSOUND_INIT_DONTLATENCYADJUST if you want it to be called back at mix time, which is useful if you want to control the music interactively.
|
||||
* ------------
|
||||
* Note : This function is not supported with the MIDI format.
|
||||
* @param module Module to set the callback for
|
||||
* @param callback The callback function you supply to get called upon execution of a Zxx command
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_SetZxxCallback(FMusicModule module, FMusicCallback callback) {
|
||||
FMOD.registerCallback(FMOD.FMUSIC_ZXXCALLBACK, module.moduleHandle, module, callback);
|
||||
return nFMUSIC_SetZxxCallback(module.moduleHandle);
|
||||
}
|
||||
private static native boolean nFMUSIC_SetZxxCallback(long module);
|
||||
|
||||
/**
|
||||
* Sets a user callback to occur on every row divisible by the rowstep parameter, played from a MOD, S3M, XM or IT file.
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* It is important to note that this callback will be called from directly WITHIN the
|
||||
* mixer / music update thread, therefore it is imperative that whatever you do from this
|
||||
* callback be extremely efficient. If the routine takes too long then breakups in the sound
|
||||
* will occur, or it will basically stop mixing until you return from the function.
|
||||
* This sort of function is usually best for just setting a flag, or do some simple variable
|
||||
* manipulation, and then exiting, letting your main thread do what it needs to based on these
|
||||
* flags or variables.
|
||||
* ------------
|
||||
* This callback is LATENCY adjusted, so that the callback happens when you HEAR the sound, not when it is mixed, for accurate synchronization.
|
||||
* Use FSOUND_INIT_DONTLATENCYADJUST if you want it to be called back at mix time, which is useful if you want to control the music interactively.
|
||||
* ------------
|
||||
* Note : This function is not supported with the MIDI format.
|
||||
* @param module Module to set the callback for
|
||||
* @param callback The callback function you supply to get called
|
||||
* @param rowstep Call the callback every multiple of this number of rows
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_SetRowCallback(FMusicModule module, FMusicCallback callback, int rowstep) {
|
||||
FMOD.registerCallback(FMOD.FMUSIC_ROWCALLBACK, module.moduleHandle, module, callback);
|
||||
return nFMUSIC_SetRowCallback(module.moduleHandle, rowstep);
|
||||
}
|
||||
private static native boolean nFMUSIC_SetRowCallback(long module, int rowstep);
|
||||
|
||||
/**
|
||||
* Sets a user callback to occur on every order divisible by the orderstep parameter, played from a MOD, S3M, XM or IT file
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* It is important to note that this callback will be called from directly WITHIN the
|
||||
* mixer / music update thread, therefore it is imperative that whatever you do from this
|
||||
* callback be extremely efficient. If the routine takes too long then breakups in the sound
|
||||
* will occur, or it will basically stop mixing until you return from the function.
|
||||
* This sort of function is usually best for just setting a flag, or do some simple variable
|
||||
* manipulation, and then exiting, letting your main thread do what it needs to based on these
|
||||
* flags or variables.
|
||||
* ------------
|
||||
* This callback is LATENCY adjusted, so that the callback happens when you HEAR the sound, not when it is mixed, for accurate synchronization.
|
||||
* Use FSOUND_INIT_DONTLATENCYADJUST if you want it to be called back at mix time, which is useful if you want to control the music interactively.
|
||||
* ------------
|
||||
* Note : This function is not supported with the MIDI format.
|
||||
* @param module Module to set the callback for
|
||||
* @param callback The callback function you supply to get called
|
||||
* @param orderstep Call the callback every multiple of this number of orders
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_SetOrderCallback(FMusicModule module, FMusicCallback callback, int orderstep) {
|
||||
FMOD.registerCallback(FMOD.FMUSIC_ORDERCALLBACK, module.moduleHandle, module, callback);
|
||||
return nFMUSIC_SetOrderCallback(module.moduleHandle, orderstep);
|
||||
}
|
||||
private static native boolean nFMUSIC_SetOrderCallback(long module, int orderstep);
|
||||
|
||||
/**
|
||||
* Sets a user callback to occur every time a instrument is played, triggered from a MOD, S3M, XM or IT file.
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* It is important to note that this callback will be called from directly WITHIN the
|
||||
* mixer / music update thread, therefore it is imperative that whatever you do from this
|
||||
* callback be extremely efficient. If the routine takes too long then breakups in the sound
|
||||
* will occur, or it will basically stop mixing until you return from the function.
|
||||
* This sort of function is usually best for just setting a flag, or do some simple variable
|
||||
* manipulation, and then exiting, letting your main thread do what it needs to based on these
|
||||
* flags or variables.
|
||||
* ------------
|
||||
* This callback is LATENCY adjusted, so that the callback happens when you HEAR the sound, not when it is mixed, for accurate synchronization.
|
||||
* Use FSOUND_INIT_DONTLATENCYADJUST if you want it to be called back at mix time, which is useful if you want to control the music interactively.
|
||||
* ------------
|
||||
* Note : This function is not supported with the MIDI format.
|
||||
* @param module Module set the callback for
|
||||
* @param callback The callback function you supply to get called
|
||||
* @param instrument Call the callback when this instrument number is triggered
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_SetInstCallback(FMusicModule module, FMusicCallback callback, int instrument) {
|
||||
FMOD.registerCallback(FMOD.FMUSIC_INSTCALLBACK, module.moduleHandle, module, callback);
|
||||
return nFMUSIC_SetInstCallback(module.moduleHandle, instrument);
|
||||
}
|
||||
private static native boolean nFMUSIC_SetInstCallback(long module, int instrument);
|
||||
|
||||
/**
|
||||
* Replaces a mod's sample with a sample definition specified.
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* Because of the instrument nature of some formats like XM, this function lists all the samples in order of instruments and their subsamples.
|
||||
* ie if instrument 1 has 2 samples and instrument 2 contains 3 samples, then sampno in this case would be 0 and 1 for instrument 1's samples, and 2,3 & 4 for instrument 2's samples.
|
||||
* ------------
|
||||
* FMOD does not free the existing mod sample that you may be overwriting. If you do overwrite an existing handle, it may be lost, and you may incur a memory leak. It is a good idea to free the existing sample first before overwriting it.
|
||||
* ------------
|
||||
* Important: For PlayStation 2, this function has to do a blocking query to the IOP, and can take significantly more time than a standard non blocking fmod function. This means it is best to cache the pointers for samples while loading, and not call this function in realtime.
|
||||
* ------------
|
||||
* This function is not supported with the MIDI format.
|
||||
* </p>
|
||||
* @param module Module to set the sample for.
|
||||
* @param sampno index to sample inside module
|
||||
* @param sptr sample definition to replace mod sample
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_SetSample(FMusicModule module, int sampno, FSoundSample sptr) {
|
||||
return nFMUSIC_SetSample(module.moduleHandle, sampno, sptr.sampleHandle);
|
||||
}
|
||||
private static native boolean nFMUSIC_SetSample(long module, int sampno, long sptr);
|
||||
|
||||
/**
|
||||
* Sets a user defined value to store with the music file to be retrieved later.
|
||||
* @param module Module to set user data for
|
||||
* @param userdata Value to store with music object
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_SetUserData(FMusicModule module, ByteBuffer userdata) {
|
||||
module.userData = userdata;
|
||||
return nFMUSIC_SetUserData(module.moduleHandle, userdata, userdata.position());
|
||||
}
|
||||
private static native boolean nFMUSIC_SetUserData(long module, ByteBuffer userdata, int offset);
|
||||
|
||||
/**
|
||||
* This function helps with channel usage. If you are desperate for channels, and you are prepared to
|
||||
* let the music routines drop a few channels, then calling this function can help.
|
||||
* It basically doesnt try to play any new sounds if a certain channel limit is being played (including sound effects),
|
||||
* and the new sound is below a certain specified volume.
|
||||
* ie.
|
||||
* You set it to maxchannels = 16, and minvolume = 0x10.
|
||||
* In this case, the mod will play normally as long as the total number of channels being played inclusing sound effefcts is below 16
|
||||
* (see FSOUND_GetChannelsPlaying).
|
||||
* If the number of channels playing exceeds 16 (through a change in the music, or extra sound effects
|
||||
* are spawned, then sounds with a musician specified volume of less than 0x10 will be ignored.
|
||||
* The volume is based on volume column/default volume/volume set commands in the mod. master volume,
|
||||
* envelope volumes etc are not taken into account (this gives more control over how it will work from the
|
||||
* tracker).
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* maxchannels will default to the number of channels allocated by FSOUND, so this will never happen
|
||||
* by default.
|
||||
* minvolume will default to 0, so it will always succeed by default.
|
||||
* To see how many channels are currently being MIXED, use FSOUND_GetChannelsPlaying.
|
||||
* As a musician mentioned to me once, most of his default volumes are set fairly high, and any low end
|
||||
* volumes are usually echoes etc, and can afford to be dropped.
|
||||
* ------------
|
||||
* Note : This function is not supported with the MIDI format.
|
||||
* </p>
|
||||
* @param module Module to set channel/volume optimization settings
|
||||
* @param maxchannels Channel count to be mixed before fmusic starts to drop channels from the song
|
||||
* @param minvolume If maxchannels is exceeded, then music channels with volumes below this value will not be played. Range is 0-64. This is the value the tracker displays. All trackers use 0-64
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_OptimizeChannels(FMusicModule module, int maxchannels, int minvolume) {
|
||||
return nFMUSIC_OptimizeChannels(module.moduleHandle, maxchannels, minvolume);
|
||||
}
|
||||
private static native boolean nFMUSIC_OptimizeChannels(long module, int maxchannels, int minvolume);
|
||||
|
||||
/**
|
||||
* Turns on reverb for MIDI/RMI files.
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* Reverb may be enabled through software emulation in the future for MOD based formats.
|
||||
* </p>
|
||||
* @param reverb Set to true to turn MIDI reverb on, false to turn MIDI reverb off
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static native boolean FMUSIC_SetReverb(boolean reverb);
|
||||
|
||||
/**
|
||||
* Sets looping mode for midi and mod files
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* Defaults to TRUE. To disable looping you must call this function using FALSE as the parameter.
|
||||
* For midi files this only takes effect before FMUSIC_PlaySong is called. For mod files this
|
||||
* can be called at any time including during playback.
|
||||
* </p>
|
||||
* @param module Module to set looping for
|
||||
* @param looping Set to true to make it loop forever, or false to only have it play once
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_SetLooping(FMusicModule module, boolean looping) {
|
||||
return nFMUSIC_SetLooping(module.moduleHandle, looping);
|
||||
}
|
||||
private static native boolean nFMUSIC_SetLooping(long module, boolean looping);
|
||||
|
||||
/**
|
||||
* Sets a songs order position / current playing position.
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* Note : This function is not supported with the MIDI format.
|
||||
* </p>
|
||||
* @param module Module to have its order changed
|
||||
* @param order Order number to jump to
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_SetOrder(FMusicModule module, int order) {
|
||||
return nFMUSIC_SetOrder(module.moduleHandle, order);
|
||||
}
|
||||
private static native boolean nFMUSIC_SetOrder(long module, int order);
|
||||
|
||||
/**
|
||||
* Pauses a song
|
||||
* @param module Module to be paused/unpaused
|
||||
* @param pause true - song should be PAUSED, false - song should be UNPAUSED
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_SetPaused(FMusicModule module, boolean pause) {
|
||||
return nFMUSIC_SetPaused(module.moduleHandle, pause);
|
||||
}
|
||||
private static native boolean nFMUSIC_SetPaused(long module, boolean pause);
|
||||
|
||||
/**
|
||||
* Sets a songs master volume.
|
||||
* @param module Module to have its master volume set
|
||||
* @param volume value from 0-256. 0 = silence, 256 = full volume
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_SetMasterVolume(FMusicModule module, int volume) {
|
||||
return nFMUSIC_SetMasterVolume(module.moduleHandle, volume);
|
||||
}
|
||||
private static native boolean nFMUSIC_SetMasterVolume(long module, int volume);
|
||||
|
||||
/**
|
||||
* Sets a songs master speed scale, so that the song can be sped up or slowed down.
|
||||
* @param module Module to have its speed scale set
|
||||
* @param speed Speed scale for song. 1.0 is default. Minimum is 0 (stopped), maximum is 10.0
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_SetMasterSpeed(FMusicModule module, float speed) {
|
||||
return nFMUSIC_SetMasterSpeed(module.moduleHandle, speed);
|
||||
}
|
||||
private static native boolean nFMUSIC_SetMasterSpeed(long module, float speed);
|
||||
|
||||
/**
|
||||
* Sets the master pan seperation for a module
|
||||
* @param module Module to set pan seperation for
|
||||
* @param pansep The pan scale. 1.0 means full pan seperation, 0 means mono
|
||||
* @return On success, true is returned. On failure, false is returned
|
||||
*/
|
||||
public static boolean FMUSIC_SetPanSeperation(FMusicModule module, float pansep) {
|
||||
return nFMUSIC_SetPanSeperation(module.moduleHandle, pansep);
|
||||
}
|
||||
private static native boolean nFMUSIC_SetPanSeperation(long module, float pansep);
|
||||
|
||||
/**
|
||||
* Returns the name of the song set by the composer. With MIDI format, the filename is returned
|
||||
* @param module Module to retrieve name from
|
||||
* @return On success, the name of the song is returned. On failure, Null is returned
|
||||
*/
|
||||
public static String FMUSIC_GetName(FMusicModule module) {
|
||||
return nFMUSIC_GetName(module.moduleHandle);
|
||||
}
|
||||
private static native String nFMUSIC_GetName(long module);
|
||||
|
||||
/**
|
||||
* Returns the format type a song
|
||||
* @param module Module to retrieve type from
|
||||
* @return FMusicType constant, FMUSIC_TYPE_NONE on failure
|
||||
*/
|
||||
public static int FMUSIC_GetType(FMusicModule module) {
|
||||
return nFMUSIC_GetType(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetType(long module);
|
||||
|
||||
/**
|
||||
* Returns the number of orders in this song
|
||||
* @param module Module to retrieve number of orders from
|
||||
* @return On success, the number of orders in this song is returned. On failure, 0 is returned
|
||||
*/
|
||||
public static int FMUSIC_GetNumOrders(FMusicModule module) {
|
||||
return nFMUSIC_GetNumOrders(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetNumOrders(long module);
|
||||
|
||||
/**
|
||||
* Returns the number of patterns contained in this song.
|
||||
* @param module Module to retrieve number of patterns from
|
||||
* @return On success, the number of patterns contained in this song is returned. On failure, 0 is returned
|
||||
*/
|
||||
public static int FMUSIC_GetNumPatterns(FMusicModule module) {
|
||||
return nFMUSIC_GetNumPatterns(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetNumPatterns(long module);
|
||||
|
||||
/**
|
||||
* Returns the number of instruments contained in this song.
|
||||
* @param module Module to retrieve number of instruments from
|
||||
* @return On success, the number of instruments contained in this song is returned. On failure, 0 is returned.
|
||||
*/
|
||||
public static int FMUSIC_GetNumInstruments(FMusicModule module) {
|
||||
return nFMUSIC_GetNumInstruments(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetNumInstruments(long module);
|
||||
|
||||
/**
|
||||
* Returns the number of samples contained in this song.
|
||||
* @param module Module to retrieve number of samples
|
||||
* @return Number of samples contained in this song. On failure, 0 is returned.
|
||||
*/
|
||||
public static int FMUSIC_GetNumSamples(FMusicModule module) {
|
||||
return nFMUSIC_GetNumSamples(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetNumSamples(long module);
|
||||
|
||||
/**
|
||||
* Returns the number of channels within this songs pattern data
|
||||
* @param module Module to retrieve number of channels from
|
||||
* @return Number of channels within this songs pattern data. On failure, 0 is returned.
|
||||
*/
|
||||
public static int FMUSIC_GetNumChannels(FMusicModule module) {
|
||||
return nFMUSIC_GetNumChannels(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetNumChannels(long module);
|
||||
|
||||
/**
|
||||
* Returns a reference to a sample inside a module.
|
||||
* Once you have access to the module's sample, you can do a lot of things
|
||||
* to it, including locking and modifying the data within; using the
|
||||
* FSOUND_Sample_ functionality
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* Because of the instrument nature of some formats like XM, this
|
||||
* function lists all the samples in order of instruments and their subsamples.
|
||||
* ie if instrument 1 has 2 samples and instrument 2 contains 3 samples, then
|
||||
* sampno in this case would be 0 and 1 for instrument 1's samples, and 2,3 & 4
|
||||
* for instrument 2's samples.
|
||||
* </p>
|
||||
* @param module Module to retrieve a sample handle from
|
||||
* @param sampno index to sample inside module
|
||||
* @return On success, a valid sample is returned. On failure, Null is returned.
|
||||
*/
|
||||
public static FSoundSample FMUSIC_GetSample(FMusicModule module, int sampno) {
|
||||
long result = nFMUSIC_GetSample(module.moduleHandle, sampno);
|
||||
if(result != 0) {
|
||||
return new FSoundSample(result, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static native long nFMUSIC_GetSample(long module, int sampno);
|
||||
|
||||
/**
|
||||
* Returns the the length in rows of the pattern for the specified order number
|
||||
* @param module Module to get pattern lenght from
|
||||
* @param orderno pattern at specified order
|
||||
* @return On success, the songs pattern length at the specified order is returned. On failure, 0 is returned
|
||||
*/
|
||||
public static int FMUSIC_GetPatternLength(FMusicModule module, int orderno) {
|
||||
return nFMUSIC_GetPatternLength(module.moduleHandle, orderno);
|
||||
}
|
||||
private static native int nFMUSIC_GetPatternLength(long module, int orderno);
|
||||
|
||||
/**
|
||||
* Returns whether the song has completed playing, or when the last order has finished playing.
|
||||
* This stays set even if the song loops.
|
||||
* @param module Module that you want check if finished or not
|
||||
* @return true if module has finished playing. false if module has not finished playing.
|
||||
*/
|
||||
public static boolean FMUSIC_IsFinished(FMusicModule module) {
|
||||
return nFMUSIC_IsFinished(module.moduleHandle);
|
||||
}
|
||||
private static native boolean nFMUSIC_IsFinished(long module);
|
||||
|
||||
/**
|
||||
* Returns whether the song is currently playing or not.
|
||||
* @param module Module to retrieve name from
|
||||
* @return true Song is playing. false Song is stopped.
|
||||
*/
|
||||
public static boolean FMUSIC_IsPlaying(FMusicModule module) {
|
||||
return nFMUSIC_IsPlaying(module.moduleHandle);
|
||||
}
|
||||
private static native boolean nFMUSIC_IsPlaying(long module);
|
||||
|
||||
/**
|
||||
* Returns the song's current master volume
|
||||
* @param module Module to retrieve song master volume from
|
||||
* @return On success, the song's current master volume, from 0 (silence) to 256 (full volume) is returned. On failure, -1 is returned.
|
||||
*/
|
||||
public static int FMUSIC_GetMasterVolume(FMusicModule module) {
|
||||
return nFMUSIC_GetMasterVolume(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetMasterVolume(long module);
|
||||
|
||||
/**
|
||||
* Returns the song's current global volume
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* GLOBAL volume is not the same as MASTER volume. GLOBAL volume is an internal
|
||||
* overall volume which can be altered by the song itself (ie there might be commands
|
||||
* to fade in a particular part of the song by scaling all the volumes in the song
|
||||
* up slowly from nothing).
|
||||
* GLOBAL volume is different to MASTER volume in that the song can modify without
|
||||
* your permission, whereas MASTER volume is an overall scalar that you can control.
|
||||
* For general use, MASTER volume is more useful, but you may want to reset a song's
|
||||
* GLOBAL volume at certain times in the song. (for example the song might have faded
|
||||
* out by using GLOBAL volume and you want to reset it)
|
||||
* </p>
|
||||
* @param module Module to retrieve song global volume from
|
||||
* @return Songs current global volume, from 0 (silence) to the maximum value determined by the music format. Global volume
|
||||
* maximums are different in respect to each format, they range from 64 to 256. On failure, -1 is returned.
|
||||
*/
|
||||
public static int FMUSIC_GetGlobalVolume(FMusicModule module) {
|
||||
return nFMUSIC_GetGlobalVolume(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetGlobalVolume(long module);
|
||||
|
||||
/**
|
||||
* Returns the song's current order number
|
||||
* @param module Module to retrieve current order number from
|
||||
* @return On success, the song's current order number is returned.On failure, -1 is returned
|
||||
*/
|
||||
public static int FMUSIC_GetOrder(FMusicModule module) {
|
||||
return nFMUSIC_GetOrder(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetOrder(long module);
|
||||
|
||||
/**
|
||||
* Returns the song's current pattern number
|
||||
* @param module Module to retrieve current pattern number from
|
||||
* @return On success, The song's current pattern number is returned. On failure, -1 is returned
|
||||
*/
|
||||
public static int FMUSIC_GetPattern(FMusicModule module) {
|
||||
return nFMUSIC_GetPattern(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetPattern(long module);
|
||||
|
||||
/**
|
||||
* Returns the song's current speed.
|
||||
* @param module Module to retrieve current song speed from
|
||||
* @return On success, The song's current speed is returned. On failure, -1 is returned
|
||||
*/
|
||||
public static int FMUSIC_GetSpeed(FMusicModule module) {
|
||||
return nFMUSIC_GetSpeed(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetSpeed(long module);
|
||||
|
||||
/**
|
||||
* Returns the song's current BPM.
|
||||
* @param module Module to retrieve current song BPM from
|
||||
* @return On success, song's current BPM is returned. On failure, -1 is returned
|
||||
*/
|
||||
public static int FMUSIC_GetBPM(FMusicModule module) {
|
||||
return nFMUSIC_GetBPM(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetBPM(long module);
|
||||
|
||||
/**
|
||||
* Returns the song's current row number
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* This value is latency adjusted by default, and returns the number you are hearing, not the 'mix-time' value.
|
||||
* Use FSOUND_INIT_DONTLATENCYADJUST if you want the value at mix time, which is useful if you want to control the music interactively, or from a DSP callback.
|
||||
* </p>
|
||||
* @param module Module to retrieve current row from
|
||||
* @return On success, the song's current row number is returned. On failure, -1 is returned
|
||||
*/
|
||||
public static int FMUSIC_GetRow(FMusicModule module) {
|
||||
return nFMUSIC_GetRow(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetRow(long module);
|
||||
|
||||
/**
|
||||
* Returns whether song is currently paused or not
|
||||
* @param module Module to get paused flag from
|
||||
* @return On success, true is returned to say the song is currently paused. On failure, false is returned to say the song is NOT currently paused
|
||||
*/
|
||||
public static boolean FMUSIC_GetPaused(FMusicModule module) {
|
||||
return nFMUSIC_GetPaused(module.moduleHandle);
|
||||
}
|
||||
private static native boolean nFMUSIC_GetPaused(long module);
|
||||
|
||||
/**
|
||||
* Returns the time in milliseconds since the song was started. This is useful for
|
||||
* synchronizing purposes becuase it will be exactly the same every time, and it is
|
||||
* reliably retriggered upon starting the song. Trying to synchronize using other
|
||||
* windows timers can lead to varying results, and inexact performance. This fixes that
|
||||
* problem by actually using the number of samples sent to the soundcard as a reference
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* This value is latency adjusted by default, and returns the number you are hearing, not the 'mix-time' value.
|
||||
* Use FSOUND_INIT_DONTLATENCYADJUST if you want the value at mix time, which is useful if you want to control the music interactively, or from a DSP callback
|
||||
* </p>
|
||||
* @param module Module to the song to get time from
|
||||
* @return On success, the time played in milliseconds is returned. On failure, -1 is returned
|
||||
*/
|
||||
public static int FMUSIC_GetTime(FMusicModule module) {
|
||||
return nFMUSIC_GetTime(module.moduleHandle);
|
||||
}
|
||||
private static native int nFMUSIC_GetTime(long module);
|
||||
|
||||
/**
|
||||
* Returns the real FSOUND channel playing based on the mod's FMUSIC channel
|
||||
* <p>
|
||||
* <b>Remarks</b>
|
||||
* Note FMUSIC mod playback only allocates a real channel on a mod channel the first time an instrument is played.
|
||||
* NNA's will not register. This function only returns the primary real channel for the mod channel.
|
||||
* </p>
|
||||
* @param module Module to the song
|
||||
* @param modchannel channel index, to query the real channel from
|
||||
* @return On success, the channel index for the respective mod channel is returned. On failure, -1 is returned
|
||||
*/
|
||||
public static int FMUSIC_GetRealChannel(FMusicModule module, int modchannel) {
|
||||
return nFMUSIC_GetRealChannel(module.moduleHandle, modchannel);
|
||||
}
|
||||
private static native int nFMUSIC_GetRealChannel(long module, int modchannel);
|
||||
|
||||
/**
|
||||
* Retrieves the data set by FMUSIC_SetUserData
|
||||
* @param module Module to get the open state from
|
||||
* @return On success, userdata set by FMUSIC_SetUserData is returned. On failure, Null is returned.
|
||||
*/
|
||||
public static ByteBuffer FMUSIC_GetUserData(FMusicModule module, int capacity) {
|
||||
ByteBuffer buffer = nFMUSIC_GetUserData(module.moduleHandle, capacity);
|
||||
buffer.order(ByteOrder.nativeOrder());
|
||||
return buffer;
|
||||
}
|
||||
private static native ByteBuffer nFMUSIC_GetUserData(long module, int capacity);
|
||||
|
||||
/**
|
||||
* This is the callback rutine called by the native implementation whenever a
|
||||
* register callback is notified.
|
||||
*
|
||||
* @param handle Handle to native object being monitored
|
||||
* @param param parameter passed to callback
|
||||
*/
|
||||
public static void music_instcallback(long modulehandle, int param) {
|
||||
// we got a callback - notify everybody
|
||||
ArrayList handlers = FMOD.getCallbacks(FMOD.FMUSIC_INSTCALLBACK, modulehandle);
|
||||
for(int i=0; i<handlers.size(); i++) {
|
||||
FMOD.WrappedCallback wCallback = (FMOD.WrappedCallback) handlers.get(i);
|
||||
FMusicCallback callback = (FMusicCallback) wCallback.callback;
|
||||
callback.FMUSIC_CALLBACK((FMusicModule) wCallback.handled, param);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the callback rutine called by the native implementation whenever a
|
||||
* register callback is notified.
|
||||
*
|
||||
* @param handle Handle to native object being monitored
|
||||
* @param param parameter passed to callback
|
||||
*/
|
||||
public static void music_ordercallback(long modulehandle, int param) {
|
||||
// we got a callback - notify everybody
|
||||
ArrayList handlers = FMOD.getCallbacks(FMOD.FMUSIC_ORDERCALLBACK, modulehandle);
|
||||
for(int i=0; i<handlers.size(); i++) {
|
||||
FMOD.WrappedCallback wCallback = (FMOD.WrappedCallback) handlers.get(i);
|
||||
FMusicCallback callback = (FMusicCallback) wCallback.callback;
|
||||
callback.FMUSIC_CALLBACK((FMusicModule) wCallback.handled, param);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the callback rutine called by the native implementation whenever a
|
||||
* register callback is notified.
|
||||
*
|
||||
* @param handle Handle to native object being monitored
|
||||
* @param param parameter passed to callback
|
||||
*/
|
||||
public static void music_rowcallback(long modulehandle, int param) {
|
||||
// we got a callback - notify everybody
|
||||
ArrayList handlers = FMOD.getCallbacks(FMOD.FMUSIC_ROWCALLBACK, modulehandle);
|
||||
for(int i=0; i<handlers.size(); i++) {
|
||||
FMOD.WrappedCallback wCallback = (FMOD.WrappedCallback) handlers.get(i);
|
||||
FMusicCallback callback = (FMusicCallback) wCallback.callback;
|
||||
callback.FMUSIC_CALLBACK((FMusicModule) wCallback.handled, param);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the callback rutine called by the native implementation whenever a
|
||||
* register callback is notified.
|
||||
*
|
||||
* @param handle Handle to native object being monitored
|
||||
* @param param parameter passed to callback
|
||||
*/
|
||||
public static void music_zxxcallback(long modulehandle, int param) {
|
||||
// we got a callback - notify everybody
|
||||
ArrayList handlers = FMOD.getCallbacks(FMOD.FMUSIC_ZXXCALLBACK, modulehandle);
|
||||
for(int i=0; i<handlers.size(); i++) {
|
||||
FMOD.WrappedCallback wCallback = (FMOD.WrappedCallback) handlers.get(i);
|
||||
FMusicCallback callback = (FMusicCallback) wCallback.callback;
|
||||
callback.FMUSIC_CALLBACK((FMusicModule) wCallback.handled, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
/**
|
||||
* This class is a representation of a Module in FMod.
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class FMusicModule {
|
||||
/** Handle to module */
|
||||
long moduleHandle;
|
||||
|
||||
/** Handle to buffer containing module data */
|
||||
Buffer moduleData;
|
||||
|
||||
/** Handle to buffer containing user data */
|
||||
Buffer userData;
|
||||
|
||||
/**
|
||||
* Creates a new FMusicModule
|
||||
*
|
||||
* @param moduleHandle
|
||||
*/
|
||||
FMusicModule(long moduleHandle, Buffer moduleData) {
|
||||
this.moduleHandle = moduleHandle;
|
||||
this.moduleData = moduleData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases the reference to any data contained
|
||||
*/
|
||||
void release() {
|
||||
this.moduleData = null;
|
||||
this.userData = null;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* This class is a representation of a DSPUnit in FMod.
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class FSoundDSPUnit {
|
||||
/** Opaque handle to dsp unit */
|
||||
ByteBuffer dspHandle;
|
||||
|
||||
/** DSP id, used for tracking which dsp needs to call which
|
||||
* object (when entering from native side) */
|
||||
ByteBuffer dspTrackingID;
|
||||
|
||||
/** ID for next dsp unit */
|
||||
static long nextDspTrackingID;
|
||||
|
||||
/**
|
||||
* Creates a new FSoundDSPUnit
|
||||
*
|
||||
* @param dspHandle handle to dsp unit
|
||||
*/
|
||||
FSoundDSPUnit(ByteBuffer dspHandle) {
|
||||
this.dspHandle = dspHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new FSoundDSPUnit
|
||||
*
|
||||
* @param dspHandle handle to dsp unit
|
||||
*/
|
||||
FSoundDSPUnit(ByteBuffer dspHandle, ByteBuffer dspTrackingID) {
|
||||
this.dspHandle = dspHandle;
|
||||
this.dspTrackingID = dspTrackingID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Next dsp id
|
||||
*/
|
||||
static long getNextId() {
|
||||
// To infinity and beyond!... well almost
|
||||
if(nextDspTrackingID == Long.MAX_VALUE) {
|
||||
nextDspTrackingID = 0;
|
||||
}
|
||||
return nextDspTrackingID++;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3;
|
||||
|
||||
/**
|
||||
* This class is a representation of a Reverb channel property object in FMod.
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class FSoundReverbChannelProperties {
|
||||
/** Handle to stream */
|
||||
long reverbHandle;
|
||||
|
||||
/**
|
||||
* Creates a new FSoundStream
|
||||
*
|
||||
* @param streamHandle handle to stream
|
||||
*/
|
||||
FSoundReverbChannelProperties(long reverbHandle) {
|
||||
this.reverbHandle = reverbHandle;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3;
|
||||
|
||||
/**
|
||||
* This class is a representation of a Reverb property object in FMod.
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class FSoundReverbProperties {
|
||||
/** Handle to stream */
|
||||
long reverbHandle;
|
||||
|
||||
/**
|
||||
* Creates a new FSoundStream
|
||||
*
|
||||
* @param streamHandle handle to stream
|
||||
*/
|
||||
FSoundReverbProperties(long reverbHandle) {
|
||||
this.reverbHandle = reverbHandle;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
/**
|
||||
* This class is a representation of a Sound Sample in FMod.
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class FSoundSample {
|
||||
/** Handle to sample */
|
||||
long sampleHandle;
|
||||
|
||||
/** Handle to buffer containing sample data */
|
||||
Buffer sampleData;
|
||||
|
||||
/**
|
||||
* Creates a new FSoundSample
|
||||
*
|
||||
* @param sampleHandle handle to sample
|
||||
*/
|
||||
FSoundSample(long sampleHandle, Buffer sampleData) {
|
||||
this.sampleHandle = sampleHandle;
|
||||
this.sampleData = sampleData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases the reference to any data contained
|
||||
*/
|
||||
void release() {
|
||||
this.sampleData = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class FSoundSampleLock {
|
||||
|
||||
/** ByteBuffer that will point to the first part of the locked data */
|
||||
private ByteBuffer ptr1;
|
||||
|
||||
/**
|
||||
* ByteBuffer that will point to the second part of the locked data.
|
||||
* This will be null if the data locked hasnt wrapped at the end of the buffer
|
||||
*/
|
||||
private ByteBuffer ptr2;
|
||||
|
||||
/** Length of data in BYTES that was locked for ptr1 */
|
||||
private int len1;
|
||||
|
||||
/**
|
||||
* Length of data in BYTES that was locked for ptr2.
|
||||
* This will be 0 if the data locked hasnt wrapped at the end of the buffer
|
||||
*/
|
||||
private int len2;
|
||||
|
||||
/**
|
||||
* Creates a new FSoundSampleLock
|
||||
*/
|
||||
public FSoundSampleLock() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new SampleLock
|
||||
*
|
||||
* @param ptr1 ByteBuffer that will point to the first part of the locked data
|
||||
* @param ptr2 ByteBuffer that will point to the second part of the locked data
|
||||
* @param len1 Length of data in BYTES that was locked for ptr1
|
||||
* @param len2 Length of data in BYTES that was locked for ptr2
|
||||
*/
|
||||
void set(ByteBuffer ptr1, ByteBuffer ptr2, int len1, int len2) {
|
||||
this.ptr1 = ptr1;
|
||||
this.ptr2 = ptr2;
|
||||
this.len1 = len1;
|
||||
this.len2 = len2;
|
||||
}
|
||||
/**
|
||||
* @return Returns the len1.
|
||||
*/
|
||||
public int getLen1() {
|
||||
return len1;
|
||||
}
|
||||
/**
|
||||
* @return Returns the len2.
|
||||
*/
|
||||
public int getLen2() {
|
||||
return len2;
|
||||
}
|
||||
/**
|
||||
* @return Returns the ptr1.
|
||||
*/
|
||||
public ByteBuffer getPtr1() {
|
||||
return ptr1;
|
||||
}
|
||||
/**
|
||||
* @return Returns the ptr2.
|
||||
*/
|
||||
public ByteBuffer getPtr2() {
|
||||
return ptr2;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
/**
|
||||
* This class is a representation of a Sound stream in FMod.
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class FSoundStream {
|
||||
/** Handle to stream */
|
||||
long streamHandle;
|
||||
|
||||
/** Handle to buffer containing sample data */
|
||||
Buffer streamData;
|
||||
|
||||
/**
|
||||
* Creates a new FSoundStream
|
||||
*
|
||||
* @param streamHandle handle to stream
|
||||
*/
|
||||
FSoundStream(long streamHandle, Buffer streamData) {
|
||||
this.streamHandle = streamHandle;
|
||||
this.streamData = streamData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases the reference to any data contained
|
||||
*/
|
||||
void release() {
|
||||
this.streamData = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* This class is a representation of a SyncPoint in FMod.
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class FSoundSyncPoint {
|
||||
/** Opaque handle to syncpoint */
|
||||
ByteBuffer syncpointHandle;
|
||||
|
||||
/**
|
||||
* Creates a new FSoundSyncPoint
|
||||
*
|
||||
* @param syncpointHandle handle to syncpoint
|
||||
*/
|
||||
FSoundSyncPoint(ByteBuffer syncpointHandle) {
|
||||
this.syncpointHandle = syncpointHandle;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* This class defines attributes in a tag field
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class FSoundTagField {
|
||||
|
||||
/** Name of tagfield */
|
||||
String name;
|
||||
|
||||
/** ByteBuffer that will point to the tagfield data */
|
||||
ByteBuffer value;
|
||||
|
||||
/** Length of tagfield data */
|
||||
int length;
|
||||
|
||||
/** Type of tagfield */
|
||||
int type;
|
||||
|
||||
/**
|
||||
* Creates a new FSoundTagField
|
||||
*/
|
||||
public FSoundTagField() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new FSoundTagField
|
||||
*/
|
||||
public FSoundTagField(int type, String name) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name value and type
|
||||
* @param name name of tagfield
|
||||
* @param value value of tagfield
|
||||
* @param type type of tagfield
|
||||
*/
|
||||
void set(String name, ByteBuffer value, int type) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
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.asReadOnlyBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return value as a <b>trimmed</b> string
|
||||
*/
|
||||
public String getValueAsString() {
|
||||
byte[] buffer = new byte[value.capacity()];
|
||||
value.get(buffer);
|
||||
value.rewind();
|
||||
return new String(buffer).trim();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3;
|
||||
|
||||
/**
|
||||
* This class is a representation of a FSOUND_TOC_TAG property object in FMod.
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class FSoundTocTag {
|
||||
/** Handle to toc */
|
||||
long tocHandle;
|
||||
|
||||
/*
|
||||
char name[4] // The string "TOC", just in case this structure is accidentally treated as a string
|
||||
int numtracks // The number of tracks on the CD
|
||||
int min[100] // The start offset of each track in minutes
|
||||
int sec[100] // The start offset of each track in seconds
|
||||
int frame[100] // The start offset of each track in frames
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new FSoundTocTag
|
||||
*
|
||||
* @param tocHandle handle to TOC
|
||||
*/
|
||||
FSoundTocTag(long tocHandle) {
|
||||
this.tocHandle = tocHandle;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3.callbacks;
|
||||
|
||||
import org.lwjgl.fmod3.FMusicModule;
|
||||
|
||||
/**
|
||||
* This interface describes a callback interface to Fmod music
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public interface FMusicCallback {
|
||||
public void FMUSIC_CALLBACK(FMusicModule module, int param);
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3.callbacks;
|
||||
|
||||
/**
|
||||
* This interface describes a callback interface to Fmod music
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public interface FSoundCloseCallback {
|
||||
public void FSOUND_CLOSECALLBACK(int handle);
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3.callbacks;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* This interface describes a callback interface to Fmod music
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public interface FSoundDSPCallback {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param originalbuffer
|
||||
* @param newbuffer
|
||||
* @param length
|
||||
* @return
|
||||
*/
|
||||
public ByteBuffer FSOUND_DSPCALLBACK(ByteBuffer originalbuffer, ByteBuffer newbuffer, int length);
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3.callbacks;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* This interface describes a callback interface to Fmod music
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public interface FSoundMetaDataCallback {
|
||||
public void FSOUND_METADATACALLBACK(ByteBuffer name, ByteBuffer value);
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3.callbacks;
|
||||
|
||||
/**
|
||||
* This interface describes a callback interface to Fmod music
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public interface FSoundOpenCallback {
|
||||
public int FSOUND_OPENCALLBACK(String name);
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3.callbacks;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* This interface describes a callback interface to Fmod music
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public interface FSoundReadCallback {
|
||||
public int FSOUND_READCALLBACK(ByteBuffer buffer, int size, int handle);
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3.callbacks;
|
||||
|
||||
/**
|
||||
* This interface describes a callback interface to Fmod music
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public interface FSoundSeekCallback {
|
||||
public int FSOUND_SEEKCALLBACK(int handle, int pos, int mode);
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3.callbacks;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.lwjgl.fmod3.FSoundStream;
|
||||
|
||||
/**
|
||||
* This interface describes a callback interface to Fmod music
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public interface FSoundStreamCallback {
|
||||
public void FSOUND_STREAMCALLBACK(FSoundStream stream, ByteBuffer buff, int len);
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* 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.fmod3.callbacks;
|
||||
|
||||
/**
|
||||
* This interface describes a callback interface to Fmod music
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public interface FSoundTellCallback {
|
||||
public int FSOUND_TELLCALLBACK(int handle);
|
||||
}
|
||||
|
|
@ -1,238 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2006 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.applet;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.devil.IL;
|
||||
import org.lwjgl.devil.ILU;
|
||||
import org.lwjgl.devil.ILUT;
|
||||
import org.lwjgl.devil.ILinfo;
|
||||
import org.lwjgl.fmod3.FMOD;
|
||||
import org.lwjgl.fmod3.FMusic;
|
||||
import org.lwjgl.fmod3.FMusicModule;
|
||||
import org.lwjgl.fmod3.FSound;
|
||||
import org.lwjgl.opengl.AWTGLCanvas;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class Optional extends AWTGLCanvas implements Test {
|
||||
|
||||
float angle = 0;
|
||||
|
||||
FMusicModule module = null;
|
||||
|
||||
public Optional() throws LWJGLException {
|
||||
|
||||
try {
|
||||
FMOD.create();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Unable to create FMOD.\nPlease make sure that FMOD is available on this system. Exception: " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
IL.create();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Unable to load IL");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
ILU.create();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Unable to load ILU");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
ILUT.create();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Unable to load ILUT");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Thread t = new Thread() {
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
if (isVisible())
|
||||
repaint();
|
||||
Display.sync(60);
|
||||
}
|
||||
}
|
||||
};
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
|
||||
private void playFMOD() {
|
||||
FSound.FSOUND_Init(44100, 32, 0);
|
||||
ByteBuffer data = getData("Missing_you.mod");
|
||||
module = FMusic.FMUSIC_LoadSongEx(data, FSound.FSOUND_LOADMEMORY, null);
|
||||
FMusic.FMUSIC_PlaySong(module);
|
||||
}
|
||||
|
||||
private ByteBuffer getData(String filename) {
|
||||
ByteBuffer buffer = null;
|
||||
|
||||
System.out.println("Attempting to load: " + filename);
|
||||
|
||||
try {
|
||||
BufferedInputStream bis = new BufferedInputStream(getClass().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();
|
||||
|
||||
// place it in a buffer
|
||||
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;
|
||||
}
|
||||
|
||||
public void paintGL() {
|
||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION_MATRIX);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glOrtho(0, 640, 0, 480, 1, -1);
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(320, 240, 0.0f);
|
||||
GL11.glRotatef(angle, 0, 0, 1.0f);
|
||||
GL11.glBegin(GL11.GL_QUADS);
|
||||
GL11.glVertex2i(-50, -50);
|
||||
GL11.glVertex2i(50, -50);
|
||||
GL11.glVertex2i(50, 50);
|
||||
GL11.glVertex2i(-50, 50);
|
||||
GL11.glEnd();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
angle += 1;
|
||||
|
||||
try {
|
||||
swapBuffers();
|
||||
} catch (Exception e) {/*OK*/
|
||||
}
|
||||
}
|
||||
|
||||
public void start() {
|
||||
playFMOD();
|
||||
testDevil();
|
||||
}
|
||||
|
||||
private void testDevil() {
|
||||
IntBuffer im = BufferUtils.createIntBuffer(1);
|
||||
IL.ilGenImages(im);
|
||||
System.out.println("ilBindImage");
|
||||
IL.ilBindImage(im.get(0));
|
||||
IL.ilEnable(IL.IL_ORIGIN_SET);
|
||||
IL.ilOriginFunc(IL.IL_ORIGIN_UPPER_LEFT);
|
||||
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
|
||||
try {
|
||||
System.out.println("load lump = " + IL.ilLoadFromStream(getClass().getResourceAsStream("/ILtest.tga"), IL.IL_TGA));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
|
||||
int newIm = IL.ilCloneCurImage();
|
||||
IL.ilCopyImage(im.get(0));
|
||||
IL.ilBindImage(newIm);
|
||||
ByteBuffer buf = IL.ilGetData();
|
||||
System.out.println("ilGetData");
|
||||
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
|
||||
int limit = buf.limit();
|
||||
System.out.println("limit = " + limit);
|
||||
for (int i = 0; i < buf.limit(); i += 3) {
|
||||
System.out.println(buf.get(i) + " " + buf.get(i + 1) + " " + buf.get(i + 2));
|
||||
}
|
||||
|
||||
System.out.println("current image = " + im.get(0) + " IL.ilGetInteger(IL.IL_ACTIVE_IMAGE) = "
|
||||
+ IL.ilGetInteger(IL.IL_ACTIVE_IMAGE));
|
||||
System.out.println("Version: " + IL.ilGetInteger(IL.IL_VERSION_NUM));
|
||||
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
|
||||
|
||||
ILinfo info = new ILinfo();
|
||||
ILU.iluGetImageInfo(info);
|
||||
System.out.println("info.id = " + info.id);
|
||||
System.out.println("info.width = " + info.width);
|
||||
System.out.println("info.height = " + info.height);
|
||||
System.out.println("info.depth = " + info.depth);
|
||||
System.out.println("info.bpp = " + info.bpp);
|
||||
System.out.println("info.sizeOfData = " + info.sizeOfData);
|
||||
System.out.println("info.format = " + info.format);
|
||||
System.out.println("info.type = " + info.type);
|
||||
System.out.println("info.origin = " + info.origin);
|
||||
System.out.println("info.palType = " + info.palType);
|
||||
System.out.println("info.palSize = " + info.palSize);
|
||||
System.out.println("info.numNext = " + info.numNext);
|
||||
System.out.println("info.numMips = " + info.numMips);
|
||||
System.out.println("info.numLayers = " + info.numLayers);
|
||||
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
|
||||
|
||||
System.out.println("ILUT Vendor: " + ILUT.ilutGetString(ILUT.ILUT_VENDOR));
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
FMusic.FMUSIC_StopSong(module);
|
||||
FMusic.FMUSIC_FreeSong(module);
|
||||
FSound.FSOUND_Close();
|
||||
FMOD.destroy();
|
||||
ILUT.destroy();
|
||||
ILU.destroy();
|
||||
IL.destroy();
|
||||
|
||||
module = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
/*
|
||||
* 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.devil;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.devil.IL;
|
||||
import org.lwjgl.devil.ILU;
|
||||
import org.lwjgl.devil.ILUT;
|
||||
import org.lwjgl.devil.ILinfo;
|
||||
|
||||
/**
|
||||
* <p>The core DevIL and ILU API.</p>
|
||||
*
|
||||
* @author Mark Bernard <captainjester@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class BasicTest {
|
||||
|
||||
public static void main(String args[]) {
|
||||
try {
|
||||
org.lwjgl.opengl.Display.create();
|
||||
IL.create();
|
||||
ILU.create();
|
||||
ILUT.create();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
|
||||
System.out.println("ilGenImages");
|
||||
IntBuffer im = BufferUtils.createIntBuffer(1);
|
||||
IL.ilGenImages(im);
|
||||
System.out.println("ilBindImage");
|
||||
IL.ilBindImage(im.get(0));
|
||||
IL.ilEnable(IL.IL_ORIGIN_SET);
|
||||
IL.ilOriginFunc(IL.IL_ORIGIN_UPPER_LEFT);
|
||||
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
|
||||
URL imageURL = BasicTest.class.getResource("/res/ILtest.tga");
|
||||
System.out.println("ilLoadFromURL " + imageURL);
|
||||
try {
|
||||
System.out.println("load lump = " + IL.ilLoadFromURL(imageURL));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
|
||||
int newIm = IL.ilCloneCurImage();
|
||||
IL.ilCopyImage(im.get(0));
|
||||
IL.ilBindImage(newIm);
|
||||
ByteBuffer buf = IL.ilGetData();
|
||||
System.out.println("ilGetData");
|
||||
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
|
||||
int limit = buf.limit();
|
||||
System.out.println("limit = " + limit);
|
||||
for (int i = 0; i < buf.limit(); i += 3) {
|
||||
System.out.println(buf.get(i) + " " + buf.get(i + 1) + " " + buf.get(i + 2));
|
||||
}
|
||||
|
||||
System.out.println("current image = " + im.get(0) + " IL.ilGetInteger(IL.IL_ACTIVE_IMAGE) = "
|
||||
+ IL.ilGetInteger(IL.IL_ACTIVE_IMAGE));
|
||||
System.out.println("Version: " + IL.ilGetInteger(IL.IL_VERSION_NUM));
|
||||
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
|
||||
|
||||
ILinfo info = new ILinfo();
|
||||
ILU.iluGetImageInfo(info);
|
||||
System.out.println("info.id = " + info.id);
|
||||
System.out.println("info.width = " + info.width);
|
||||
System.out.println("info.height = " + info.height);
|
||||
System.out.println("info.depth = " + info.depth);
|
||||
System.out.println("info.bpp = " + info.bpp);
|
||||
System.out.println("info.sizeOfData = " + info.sizeOfData);
|
||||
System.out.println("info.format = " + info.format);
|
||||
System.out.println("info.type = " + info.type);
|
||||
System.out.println("info.origin = " + info.origin);
|
||||
System.out.println("info.palType = " + info.palType);
|
||||
System.out.println("info.palSize = " + info.palSize);
|
||||
System.out.println("info.numNext = " + info.numNext);
|
||||
System.out.println("info.numMips = " + info.numMips);
|
||||
System.out.println("info.numLayers = " + info.numLayers);
|
||||
System.out.println("error = " + ILU.iluErrorString(IL.ilGetError()));
|
||||
|
||||
System.out.println("ILUT Vendor: " + ILUT.ilutGetString(ILUT.ILUT_VENDOR));
|
||||
|
||||
try {
|
||||
ILUT.destroy();
|
||||
ILU.destroy();
|
||||
IL.destroy();
|
||||
org.lwjgl.opengl.Display.destroy();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* 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.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.lwjgl.fmod3.FMOD;
|
||||
import org.lwjgl.fmod3.FMODException;
|
||||
import org.lwjgl.fmod3.FSound;
|
||||
import org.lwjgl.fmod3.FSoundStream;
|
||||
|
||||
/**
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class CDDAPlayer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
FMOD.create();
|
||||
} catch (FMODException fmode) {
|
||||
fmode.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
System.out.println("Initializing FMOD");
|
||||
if (!FSound.FSOUND_Init(44100, 32, 0)) {
|
||||
System.out.println("Failed to initialize FMOD");
|
||||
System.exit(0);
|
||||
|
||||
}
|
||||
|
||||
boolean running = true;
|
||||
String token = null;
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||
FSoundStream stream = null;
|
||||
do {
|
||||
System.out.println(FMOD.FMOD_ErrorString(FSound.FSOUND_GetError()));
|
||||
System.out.println("FMOD CD Player test. Press a key corresponding to action");
|
||||
System.out.println("1: FSOUND_Stream_Open \"<drive>:\"");
|
||||
System.out.println("2: FSOUND_Stream_Open \"<drive>:?\"");
|
||||
System.out.println("3: FSOUND_Stream_Open \"<drive>:!\"");
|
||||
System.out.println("4: FSOUND_Stream_SetSubStream <position>");
|
||||
System.out.println("5: FSOUND_Stream_GetNumSubStreams");
|
||||
System.out.println("6: Enumerate tag fields");
|
||||
System.out.println("0: Exit");
|
||||
try {
|
||||
StringTokenizer st = new StringTokenizer(br.readLine().trim());
|
||||
token = st.nextToken();
|
||||
|
||||
switch (Integer.parseInt(token)) {
|
||||
case 0:
|
||||
running = false;
|
||||
break;
|
||||
case 1:
|
||||
stream = FSound.FSOUND_Stream_Open(st.nextToken() + ":", FSound.FSOUND_NORMAL, 0, 0);
|
||||
break;
|
||||
case 2:
|
||||
stream = FSound.FSOUND_Stream_Open(st.nextToken() + ":*?", 0, 0, 0);
|
||||
break;
|
||||
case 3:
|
||||
stream = FSound.FSOUND_Stream_Open(st.nextToken() + ":*!", 0, 0, 0);
|
||||
break;
|
||||
case 4:
|
||||
FSound.FSOUND_Stream_SetSubStream(stream, Integer.parseInt(st.nextToken()));
|
||||
break;
|
||||
case 5:
|
||||
System.out.println(FSound.FSOUND_Stream_GetNumSubStreams(stream));
|
||||
break;
|
||||
case 6:
|
||||
//
|
||||
break;
|
||||
default:
|
||||
System.out.println("No entry");
|
||||
}
|
||||
System.out.println("Stream: " + stream);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} while (running);
|
||||
|
||||
if(stream != null) {
|
||||
FSound.FSOUND_Stream_Close(stream);
|
||||
}
|
||||
FSound.FSOUND_Close();
|
||||
FMOD.destroy();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
/*
|
||||
* 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.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.lwjgl.fmod3.FMOD;
|
||||
import org.lwjgl.fmod3.FMODException;
|
||||
import org.lwjgl.fmod3.FSound;
|
||||
|
||||
/**
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class CDPlayer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
FMOD.create();
|
||||
} catch (FMODException fmode) {
|
||||
fmode.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
System.out.println("Initializing FMOD");
|
||||
if (!FSound.FSOUND_Init(44100, 32, 0)) {
|
||||
System.out.println("Failed to initialize FMOD");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
boolean running = true;
|
||||
String token = null;
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||
do {
|
||||
System.out.println("FMOD CD Player test. Press a key corresponding to action");
|
||||
System.out.println("1: FSOUND_CD_Eject <drive>");
|
||||
System.out.println("2: FSOUND_CD_Play <drive> <track>");
|
||||
System.out.println("3: FSOUND_CD_Stop <drive>");
|
||||
System.out.println("4: FSOUND_CD_GetNumTracks <drive>");
|
||||
System.out.println("5: FSOUND_CD_GetPaused <drive>");
|
||||
System.out.println("6: FSOUND_CD_GetTrack <drive>");
|
||||
System.out.println("7: FSOUND_CD_GetTrackLength <drive> <track>");
|
||||
System.out.println("8: FSOUND_CD_GetTrackTime <drive>");
|
||||
System.out.println("9: FSOUND_CD_SetPaused <drive>");
|
||||
System.out.println("10: FSOUND_CD_SetPlayMode <drive> <mode>");
|
||||
System.out.println("11: FSOUND_CD_SetTrackTime <drive> <milliseconds>");
|
||||
System.out.println("12: FSOUND_CD_SetVolume <drive> <volume>");
|
||||
System.out.println("0: Exit");
|
||||
try {
|
||||
StringTokenizer st = new StringTokenizer(br.readLine().trim());
|
||||
token = st.nextToken();
|
||||
|
||||
switch (Integer.parseInt(token)) {
|
||||
case 0:
|
||||
running = false;
|
||||
break;
|
||||
case 1:
|
||||
FSound.FSOUND_CD_OpenTray(st.nextToken().charAt(0), true);
|
||||
break;
|
||||
case 2:
|
||||
FSound.FSOUND_CD_Play(st.nextToken().charAt(0), Integer.parseInt(st.nextToken()));
|
||||
break;
|
||||
case 3:
|
||||
FSound.FSOUND_CD_Stop(st.nextToken().charAt(0));
|
||||
break;
|
||||
case 4:
|
||||
System.out.println(FSound.FSOUND_CD_GetNumTracks(st.nextToken().charAt(0)));
|
||||
break;
|
||||
case 5:
|
||||
System.out.println(FSound.FSOUND_CD_GetPaused(st.nextToken().charAt(0)));
|
||||
break;
|
||||
case 6:
|
||||
System.out.println(FSound.FSOUND_CD_GetTrack(st.nextToken().charAt(0)));
|
||||
break;
|
||||
case 7:
|
||||
System.out.println(FSound.FSOUND_CD_GetTrackLength(st.nextToken().charAt(0), Integer.parseInt(st.nextToken())));
|
||||
break;
|
||||
case 8:
|
||||
System.out.println(FSound.FSOUND_CD_GetTrackTime(st.nextToken().charAt(0)));
|
||||
break;
|
||||
case 9:
|
||||
FSound.FSOUND_CD_SetPaused(st.nextToken().charAt(0), Boolean.valueOf(st.nextToken()).booleanValue());
|
||||
break;
|
||||
case 10:
|
||||
FSound.FSOUND_CD_SetPlayMode(st.nextToken().charAt(0), Integer.parseInt(st.nextToken()));
|
||||
break;
|
||||
case 11:
|
||||
FSound.FSOUND_CD_SetTrackTime(st.nextToken().charAt(0), Integer.parseInt(st.nextToken()));
|
||||
break;
|
||||
case 12:
|
||||
FSound.FSOUND_CD_SetVolume(st.nextToken().charAt(0), Integer.parseInt(st.nextToken()));
|
||||
break;
|
||||
default:
|
||||
System.out.println("No entry");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} while (running);
|
||||
|
||||
FSound.FSOUND_Close();
|
||||
FMOD.destroy();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,189 +0,0 @@
|
|||
/*
|
||||
* 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.ByteBuffer;
|
||||
|
||||
import org.lwjgl.fmod3.FMOD;
|
||||
import org.lwjgl.fmod3.FMODException;
|
||||
import org.lwjgl.fmod3.FSound;
|
||||
import org.lwjgl.fmod3.FSoundDSPUnit;
|
||||
import org.lwjgl.fmod3.FSoundStream;
|
||||
import org.lwjgl.fmod3.callbacks.FSoundDSPCallback;
|
||||
import org.lwjgl.fmod3.callbacks.FSoundStreamCallback;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$ <br>
|
||||
*/
|
||||
public class DSPTest {
|
||||
|
||||
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>");
|
||||
|
||||
// default to phero.mp3
|
||||
args = new String[] { "res" + File.separator + "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]);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
try {
|
||||
FMOD.create();
|
||||
} catch (FMODException fmode) {
|
||||
fmode.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
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()));
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
System.out.println("Loading " + args[0]);
|
||||
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);
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
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()));
|
||||
}
|
||||
|
||||
FSound.FSOUND_Close();
|
||||
FMOD.destroy();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public class TestDspCallback implements FSoundDSPCallback {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
* 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 org.lwjgl.fmod3.FMOD;
|
||||
import org.lwjgl.fmod3.FMODException;
|
||||
import org.lwjgl.fmod3.FMusic;
|
||||
import org.lwjgl.fmod3.FMusicModule;
|
||||
import org.lwjgl.fmod3.FSound;
|
||||
|
||||
/**
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class MusicPlayer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 1) {
|
||||
System.out.println("Usage:\n MusicPlayer <file>");
|
||||
|
||||
// default to Missing_you.mod
|
||||
args = new String[] { "res" + File.separator + "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]);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
try {
|
||||
FMOD.create();
|
||||
} catch (FMODException fmode) {
|
||||
fmode.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
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();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
/*
|
||||
* 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.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.lwjgl.fmod3.FMOD;
|
||||
import org.lwjgl.fmod3.FMODException;
|
||||
import org.lwjgl.fmod3.FMusic;
|
||||
import org.lwjgl.fmod3.FMusicModule;
|
||||
import org.lwjgl.fmod3.FSound;
|
||||
|
||||
/**
|
||||
* <br>
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision: 2286 $
|
||||
* $Id: MusicPlayer.java 2286 2006-03-23 19:32:21Z matzon $
|
||||
*/
|
||||
public class MusicPlayerMemory {
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 1) {
|
||||
System.out.println("Usage:\n MusicPlayer <file>");
|
||||
|
||||
// default to Missing_you.mod
|
||||
args = new String[] { "res" + File.separator + "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]);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
try {
|
||||
FMOD.create();
|
||||
} catch (FMODException fmode) {
|
||||
fmode.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
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)
|
||||
ByteBuffer data = getData(args[0]);
|
||||
FMusicModule module = FMusic.FMUSIC_LoadSongEx(data, 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();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(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();
|
||||
|
||||
// place it in a buffer
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,445 +0,0 @@
|
|||
/*
|
||||
* 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.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.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;
|
||||
import org.lwjgl.fmod3.FSound;
|
||||
import org.lwjgl.fmod3.FSoundStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$ <br>
|
||||
*/
|
||||
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://www.scenemusic.eu:8002/live.mp3",
|
||||
"http://basu.cockos.com:6969/"};
|
||||
|
||||
/**
|
||||
* Creates a new NetTest
|
||||
* @param frame parent frame
|
||||
*/
|
||||
public NetTest(Frame frame) {
|
||||
this.frame = frame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes NetTest
|
||||
*/
|
||||
private void dispose() {
|
||||
if (initialized) {
|
||||
stop();
|
||||
FSound.FSOUND_Close();
|
||||
FMOD.destroy();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays the supplied URL
|
||||
*
|
||||
* @param url URK to play
|
||||
*/
|
||||
protected void play(final String url) {
|
||||
// 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the playing
|
||||
*/
|
||||
protected void stop() {
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
// 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
|
||||
*/
|
||||
private void error(String string) {
|
||||
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));
|
||||
|
||||
// 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 <brian@matzon.dk>
|
||||
* @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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
* 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 org.lwjgl.fmod3.FMOD;
|
||||
import org.lwjgl.fmod3.FMODException;
|
||||
import org.lwjgl.fmod3.FSound;
|
||||
import org.lwjgl.fmod3.FSoundStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$ <br>
|
||||
*/
|
||||
public class StreamPlayer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 1) {
|
||||
System.out.println("Usage:\n StreamPlayer <file>");
|
||||
|
||||
// default to phero.mp3
|
||||
args = new String[] { "res" + File.separator + "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]);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
try {
|
||||
FMOD.create();
|
||||
} catch (FMODException fmode) {
|
||||
fmode.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
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()));
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
System.out.println("Loading " + args[0]);
|
||||
FSoundStream stream = FSound.FSOUND_Stream_Open(args[0], FSound.FSOUND_NORMAL, 0, 0);
|
||||
|
||||
if (stream != null) {
|
||||
FSound.FSOUND_Stream_Play(0, stream);
|
||||
|
||||
System.out.println("Press enter to stop playing");
|
||||
try {
|
||||
System.in.read();
|
||||
} catch (IOException ioe) {
|
||||
}
|
||||
|
||||
System.out.println("Done playing. Cleaning up");
|
||||
FSound.FSOUND_Stream_Stop(stream);
|
||||
FSound.FSOUND_Stream_Close(stream);
|
||||
} else {
|
||||
System.out.println("Unable to play: " + args[0]);
|
||||
System.out.println("Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError()));
|
||||
}
|
||||
|
||||
FSound.FSOUND_Close();
|
||||
FMOD.destroy();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
* 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.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.lwjgl.fmod3.FMOD;
|
||||
import org.lwjgl.fmod3.FMODException;
|
||||
import org.lwjgl.fmod3.FSound;
|
||||
import org.lwjgl.fmod3.FSoundStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$ <br>
|
||||
*/
|
||||
public class StreamPlayerMemory {
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 1) {
|
||||
System.out.println("Usage:\n StreamPlayerMemory <file>");
|
||||
|
||||
// default to phero.mp3
|
||||
args = new String[] { "res" + File.separator + "phero2.ogg"};
|
||||
System.out.println("Using default: " + args[0]);
|
||||
}
|
||||
|
||||
try {
|
||||
FMOD.create();
|
||||
} catch (FMODException fmode) {
|
||||
fmode.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
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()));
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
ByteBuffer data = getData(args[0]);
|
||||
FSoundStream stream = FSound.FSOUND_Stream_Open(data, FSound.FSOUND_LOADMEMORY);
|
||||
|
||||
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) {
|
||||
}
|
||||
|
||||
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();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(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();
|
||||
|
||||
// place it in a buffer
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* 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.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.fmod3.FMOD;
|
||||
import org.lwjgl.fmod3.FMODException;
|
||||
import org.lwjgl.fmod3.FSound;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$ <br>
|
||||
*/
|
||||
public class StreamTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
FMOD.create();
|
||||
} catch (FMODException fmode) {
|
||||
fmode.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
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()));
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,259 +0,0 @@
|
|||
/*
|
||||
* 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.ByteBuffer;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.fmod3.FMOD;
|
||||
import org.lwjgl.fmod3.FMODException;
|
||||
import org.lwjgl.fmod3.FMusic;
|
||||
import org.lwjgl.fmod3.FMusicModule;
|
||||
import org.lwjgl.fmod3.FSound;
|
||||
import org.lwjgl.fmod3.callbacks.FMusicCallback;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$ <br>
|
||||
*/
|
||||
public class SyncTest {
|
||||
|
||||
/** Path to file to play */
|
||||
private String filePath;
|
||||
|
||||
/** Module instance loaded */
|
||||
private FMusicModule module;
|
||||
|
||||
/** Whether test is running */
|
||||
private boolean running = true;
|
||||
|
||||
/** Current row */
|
||||
private int row;
|
||||
|
||||
/** Current order */
|
||||
private int order;
|
||||
|
||||
/** Number of orders in the song */
|
||||
private int numOrders;
|
||||
|
||||
/**
|
||||
* Creates a new SyncTest
|
||||
* @param string
|
||||
*/
|
||||
public SyncTest(String filePath) {
|
||||
this.filePath = filePath;
|
||||
|
||||
// create thread to exit when a key has been pressed
|
||||
Thread t = new Thread() {
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
System.in.read();
|
||||
} catch (IOException ioe) {
|
||||
}
|
||||
running = false;
|
||||
}
|
||||
};
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
if (args.length < 1) {
|
||||
System.out.println("Usage:\n SyncTest <file>");
|
||||
|
||||
// default to Missing_you.mod
|
||||
args = new String[] { "res" + File.separator + "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]);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// initialize FMOD
|
||||
try {
|
||||
System.out.println("Initializing FMOD");
|
||||
FMOD.create();
|
||||
} catch (FMODException fmode) {
|
||||
fmode.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
||||
// go go go!
|
||||
run();
|
||||
}
|
||||
|
||||
// we're done - clean up
|
||||
destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup FMOD
|
||||
*/
|
||||
private void setup() {
|
||||
if (!FSound.FSOUND_Init(44100, 32, 0)) {
|
||||
System.out.println("Failed to initialize FMOD");
|
||||
System.out.println("Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError()));
|
||||
return;
|
||||
}
|
||||
|
||||
// load module
|
||||
System.out.println("Loading " + filePath);
|
||||
module = FMusic.FMUSIC_LoadSong(filePath);
|
||||
|
||||
if (module == null) {
|
||||
System.out.println("Unable to load " + filePath + ": " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError()));
|
||||
return;
|
||||
}
|
||||
|
||||
// get number of orders
|
||||
numOrders = FMusic.FMUSIC_GetNumOrders(module);
|
||||
|
||||
// install order callback
|
||||
FMusic.FMUSIC_SetOrderCallback(module, new FMusicCallback() {
|
||||
|
||||
public void FMUSIC_CALLBACK(FMusicModule module, int param) {
|
||||
order = param;
|
||||
}
|
||||
}, 1);
|
||||
|
||||
// install row callback
|
||||
// will be called once PER CHANNEL! - but since we only set the row
|
||||
// no harm is done :)
|
||||
FMusic.FMUSIC_SetRowCallback(module, new FMusicCallback() {
|
||||
|
||||
public void FMUSIC_CALLBACK(FMusicModule module, int param) {
|
||||
row = param;
|
||||
}
|
||||
}, 1);
|
||||
|
||||
// try to add some userdata
|
||||
ByteBuffer buffer = BufferUtils.createByteBuffer(24);
|
||||
buffer.putInt(1).putInt(2).putInt(3).putInt(4).putInt(5).putInt(6).rewind();
|
||||
FMusic.FMUSIC_SetUserData(module, buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update status of module - spew it out in console
|
||||
*/
|
||||
private void update() {
|
||||
// mark as not running when finished
|
||||
if (FMusic.FMUSIC_IsFinished(module)) {
|
||||
running = false;
|
||||
}
|
||||
|
||||
int patternLength = FMusic.FMUSIC_GetPatternLength(module, order);
|
||||
int time = FMusic.FMUSIC_GetTime(module) / 1000;
|
||||
int time2 = FMusic.FMUSIC_GetTime(module) % 1000 / 10;
|
||||
double cpu = Math.round(FSound.FSOUND_GetCPUUsage() * 100.0) / 100.0;
|
||||
|
||||
System.out.println("O: " + ((order < 10) ? "0" : "") + order + "/" + numOrders + " | R: " + ((row < 10) ? "0" : "")
|
||||
+ row + "/" + patternLength + " | T: " + time + "." + ((time2 < 10) ? "0" : "") + time2 + " | BPM: "
|
||||
+ FMusic.FMUSIC_GetBPM(module) + " | Play: " + FMusic.FMUSIC_IsFinished(module) + " | C: "
|
||||
+ FSound.FSOUND_GetChannelsPlaying() + " | CPU: " + cpu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the actual test - that is, play | update ad nausea
|
||||
*/
|
||||
private void run() {
|
||||
// play
|
||||
FMusic.FMUSIC_PlaySong(module);
|
||||
|
||||
// loop, printing update, if we actually changed row
|
||||
int lastRow = row;
|
||||
while (running) {
|
||||
if (lastRow != row) {
|
||||
lastRow = row;
|
||||
update();
|
||||
} else {
|
||||
pause(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i
|
||||
*/
|
||||
private void pause(long i) {
|
||||
try {
|
||||
Thread.sleep(i);
|
||||
} catch (InterruptedException inte) {
|
||||
}
|
||||
}
|
||||
|
||||
// clean up our own mess
|
||||
private void destroy() {
|
||||
if (module != null) {
|
||||
// retrieve userdata
|
||||
ByteBuffer buffer = FMusic.FMUSIC_GetUserData(module, 24);
|
||||
|
||||
// should contain 1,2,3,4,5,6
|
||||
for (int i = 0; i < 6; i++) {
|
||||
System.out.println(buffer.getInt());
|
||||
}
|
||||
|
||||
FMusic.FMUSIC_FreeSong(module);
|
||||
}
|
||||
FSound.FSOUND_Close();
|
||||
FMOD.destroy();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
/*
|
||||
* 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.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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
* $Id$ <br>
|
||||
*/
|
||||
public class TagFieldTest {
|
||||
|
||||
/** Scratch buffer */
|
||||
static IntBuffer scratch = BufferUtils.createIntBuffer(16);
|
||||
|
||||
/**
|
||||
* Main entry point
|
||||
*
|
||||
* @param args arguments for app
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 1) {
|
||||
System.out.println("Usage:\n TagFieldTest <file|dir>");
|
||||
|
||||
// default to .
|
||||
args = new String[] { "."};
|
||||
System.out.println("Using default: " + args[0]);
|
||||
}
|
||||
|
||||
// initialize fmod
|
||||
try {
|
||||
System.out.println("Initializing FMOD");
|
||||
FMOD.create();
|
||||
|
||||
if (!FSound.FSOUND_Init(44100, 32, 0)) {
|
||||
System.out.println("Failed to initialize FMOD");
|
||||
System.out.println("Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError()));
|
||||
FMOD.destroy();
|
||||
System.exit(0);
|
||||
}
|
||||
} catch (FMODException fmode) {
|
||||
fmode.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// scan the supplied arg
|
||||
System.out.println("Starting recursive scan from: " + args[0]);
|
||||
scanPath(new File(args[0]));
|
||||
|
||||
// shutdown
|
||||
FSound.FSOUND_Close();
|
||||
FMOD.destroy();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans a path for files
|
||||
*
|
||||
* @param path Path to scan
|
||||
*/
|
||||
private static void scanPath(File path) {
|
||||
// if we got supplied a file - scan it
|
||||
if (path.isFile()) {
|
||||
scanFile(path);
|
||||
return;
|
||||
}
|
||||
|
||||
// if we got a dir scan it for files and subfolders
|
||||
if (path.isDirectory()) {
|
||||
File[] files = path.listFiles();
|
||||
if (files != null) {
|
||||
// scan each entry, recursively calling scanPath
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
scanPath(files[i]);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("Ignoring: " + path.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans a file for tag fields
|
||||
* @param file file to scan for tags
|
||||
*/
|
||||
private static void scanFile(File file) {
|
||||
// if we got an mp3 or an ogg file, open it
|
||||
if (file.getName().indexOf(".mp3") != -1 || file.getName().indexOf(".ogg") != -1) {
|
||||
System.out.println("Opening " + file.getAbsolutePath());
|
||||
FSoundStream stream = FSound.FSOUND_Stream_Open(file.getAbsolutePath(), FSound.FSOUND_NORMAL, 0, 0);
|
||||
if(stream == null) {
|
||||
System.out.println("Unable to open file: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError()));
|
||||
return;
|
||||
}
|
||||
FSound.FSOUND_Stream_GetNumTagFields(stream, scratch);
|
||||
int tagCount = scratch.get(0);
|
||||
|
||||
// print each name value pair
|
||||
if (tagCount > 0) {
|
||||
System.out.println("The following list of tags were found:");
|
||||
FSoundTagField field;
|
||||
for (int i = 0; i < tagCount; i++) {
|
||||
field = new FSoundTagField();
|
||||
if (FSound.FSOUND_Stream_GetTagField(stream, i, field)) {
|
||||
System.out.println(" " + field.getName() + " = '" + field.getValueAsString() + "'");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.println("Unable to locates any tags");
|
||||
}
|
||||
System.out.println();
|
||||
FSound.FSOUND_Stream_Close(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue