change: ALUTLoadWAVFile -> ALUTLoadWAVData
This commit is contained in:
parent
68e100a6e9
commit
14ae13dd26
|
@ -66,9 +66,17 @@ public class ALUT {
|
|||
* Loads a wave file into memory
|
||||
*
|
||||
* @param file name of file to load (in current working directory)
|
||||
* @return ALUTLoadWAVFile object containing information regarding file loaded
|
||||
* @return ALUTLoadWAVData object containing information regarding wave data loaded
|
||||
*/
|
||||
public native ALUTLoadWAVFile loadWAVFile(String file);
|
||||
public native ALUTLoadWAVData loadWAVFile(String file);
|
||||
|
||||
/**
|
||||
* Loads a byte buffer into memory
|
||||
*
|
||||
* @param buffer byte buffer containing file
|
||||
* @return ALUTLoadWAVData object containing information regarding wave data loaded
|
||||
*/
|
||||
public native ALUTLoadWAVData loadWAVMemory(byte[] buffer);
|
||||
|
||||
/**
|
||||
* Unloads the specified file from memory
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class ALUTLoadWAVFile {
|
||||
public class ALUTLoadWAVData {
|
||||
|
||||
/* format of file */
|
||||
public final int format;
|
||||
|
@ -68,7 +68,7 @@ public class ALUTLoadWAVFile {
|
|||
* @param freq frequency of the data
|
||||
* @param loop looping indicator for the WAV data
|
||||
*/
|
||||
public ALUTLoadWAVFile(int format, int data, int size, int freq, boolean loop) {
|
||||
public ALUTLoadWAVData(int format, int data, int size, int freq, boolean loop) {
|
||||
this.format = format;
|
||||
this.data = data;
|
||||
this.size = size;
|
|
@ -31,6 +31,9 @@
|
|||
*/
|
||||
package org.lwjgl.openal;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
|
@ -72,7 +75,12 @@ public class OpenALTest {
|
|||
al.genSources(1, sources);
|
||||
|
||||
/* load data */
|
||||
ALUTLoadWAVFile file = alut.loadWAVFile("footsteps.wav");
|
||||
ALUTLoadWAVData file = alut.loadWAVFile("footsteps.wav");
|
||||
//byte[] buffer = getBufferFor("footsteps.wav");
|
||||
|
||||
//System.out.println("buffersize: " + buffer.length);
|
||||
|
||||
//ALUTLoadWAVData file = alut.loadWAVMemory(buffer);
|
||||
|
||||
/* copy to buffers */
|
||||
al.bufferData(buffers[0], file.format, file.data, file.size, file.freq);
|
||||
|
@ -108,4 +116,40 @@ public class OpenALTest {
|
|||
/* shutdown */
|
||||
alut.exit();
|
||||
}
|
||||
|
||||
private static byte[] getBufferFor(String filename) {
|
||||
URL url = null;
|
||||
|
||||
String cwd = System.getProperty("user.dir");
|
||||
|
||||
try {
|
||||
url = new URL("file:///" + cwd + "/" + filename);
|
||||
} catch (MalformedURLException mue) {
|
||||
mue.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Attempting to load: " + url);
|
||||
|
||||
try {
|
||||
BufferedInputStream bis = new BufferedInputStream(url.openStream());
|
||||
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();
|
||||
|
||||
return baos.toByteArray();
|
||||
} catch (Exception ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
System.exit(-1);
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -117,7 +117,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALUT_loadWAVFile (JNIEnv *env, j
|
|||
alutLoadWAVFile(filename, (ALenum*) &format, (void**) &data, (ALsizei*) &size, (ALsizei*) &freq, (ALboolean*) &loop);
|
||||
|
||||
/* get class */
|
||||
alutLoadWAVFile_class = env->FindClass("org/lwjgl/openal/ALUTLoadWAVFile");
|
||||
alutLoadWAVFile_class = env->FindClass("org/lwjgl/openal/ALUTLoadWAVData");
|
||||
|
||||
/* get constructor */
|
||||
methodID = env->GetMethodID(alutLoadWAVFile_class, "<init>", "(IIIIZ)V");
|
||||
|
@ -168,7 +168,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALUT_loadWAVMemory (JNIEnv *env,
|
|||
alutLoadWAVMemory(bufferlocation, (ALenum*) &format, (void**) &data, (ALsizei*) &size, (ALsizei*) &freq, (ALboolean*) &loop);
|
||||
|
||||
/* get class */
|
||||
alutLoadWAVFile_class = env->FindClass("org/lwjgl/openal/ALUTLoadWAVFile");
|
||||
alutLoadWAVFile_class = env->FindClass("org/lwjgl/openal/ALUTLoadWAVData");
|
||||
|
||||
/* get constructor */
|
||||
methodID = env->GetMethodID(alutLoadWAVFile_class, "<init>", "(IIIIZ)V");
|
||||
|
|
Loading…
Reference in New Issue