Look at the big smart programmer using the library code instead of rolling his own, hacked-up shit
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@623 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -24,12 +24,26 @@ package com.threerings.openal;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.lwjgl.openal.AL10;
|
||||
import org.lwjgl.util.WaveData;
|
||||
|
||||
/**
|
||||
* Contains data for a single sampled sound.
|
||||
*/
|
||||
public class Clip
|
||||
{
|
||||
public Clip ()
|
||||
{}
|
||||
|
||||
/**
|
||||
* Fills in a clip from the given wave data.
|
||||
*/
|
||||
public Clip (WaveData data)
|
||||
{
|
||||
format = data.format;
|
||||
frequency = data.samplerate;
|
||||
this.data = data.data;
|
||||
}
|
||||
|
||||
/** The OpenAL format of this clip: {@link AL10#AL_FORMAT_MONO8}, etc. */
|
||||
public int format;
|
||||
|
||||
|
||||
@@ -31,16 +31,13 @@ import org.lwjgl.util.WaveData;
|
||||
*/
|
||||
public class WaveDataClipProvider implements ClipProvider
|
||||
{
|
||||
public Clip loadClip (String path) throws IOException
|
||||
public Clip loadClip (String path)
|
||||
throws IOException
|
||||
{
|
||||
Clip clip = new Clip();
|
||||
WaveData file = WaveData.create(path);
|
||||
if (file == null) {
|
||||
throw new IOException("Error loading " + path);
|
||||
}
|
||||
clip.format = file.format;
|
||||
clip.frequency = file.samplerate;
|
||||
clip.data = file.data;
|
||||
return clip;
|
||||
return new Clip(file);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user