<classpath>\r
<classpathentry excluding="**/.svn/*" kind="src" path="src"/>\r
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
- <classpathentry kind="lib" path="libs/jlayer-1.0.1-libgdx.jar"/>\r
<classpathentry kind="lib" path="libs/jorbis.jar"/>\r
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx"/>\r
<classpathentry exported="true" kind="lib" path="libs/lwjgl-debug.jar"/>\r
+ <classpathentry kind="lib" path="libs/jlayer-1.0.1-libgdx.jar"/>\r
<classpathentry kind="output" path="bin"/>\r
</classpath>\r
boolean setup = bitstream == null;\r
if (setup) {\r
bitstream = new Bitstream(file.read());\r
-\r
- outputBuffer = new OutputBuffer(2, false);\r
-\r
decoder = new MP3Decoder();\r
- decoder.setOutputBuffer(outputBuffer);\r
}\r
\r
int totalLength = 0;\r
Header header = bitstream.readFrame();\r
if (header == null) break;\r
if (setup) {\r
- setup(outputBuffer.isStereo() ? 2 : 1, header.getSampleRate());\r
+ int channels = header.mode() == Header.SINGLE_CHANNEL ? 1 : 2;\r
+ outputBuffer = new OutputBuffer(channels, false);\r
+ decoder.setOutputBuffer(outputBuffer);\r
+ setup(channels, header.getSampleRate());\r
setup = false;\r
}\r
try {\r
ByteArrayOutputStream output = new ByteArrayOutputStream(4096);\r
\r
Bitstream bitstream = new Bitstream(file.read());\r
-\r
- OutputBuffer outputBuffer = new OutputBuffer(2, false);\r
-\r
MP3Decoder decoder = new MP3Decoder();\r
- decoder.setOutputBuffer(outputBuffer);\r
\r
try {\r
- int sampleRate = -1;\r
+ OutputBuffer outputBuffer = null;\r
+ int sampleRate = -1, channels = -1;\r
while (true) {\r
Header header = bitstream.readFrame();\r
if (header == null) break;\r
- if (sampleRate == -1) sampleRate = header.getSampleRate();\r
+ if (outputBuffer == null) {\r
+ channels = header.mode() == Header.SINGLE_CHANNEL ? 1 : 2;\r
+ outputBuffer = new OutputBuffer(channels, false);\r
+ decoder.setOutputBuffer(outputBuffer);\r
+ sampleRate = header.getSampleRate();\r
+ }\r
try {\r
decoder.decodeFrame(header, bitstream);\r
} catch (Exception ignored) {\r
output.write(outputBuffer.getBuffer(), 0, outputBuffer.reset());\r
}\r
bitstream.close();\r
- setup(output.toByteArray(), outputBuffer.isStereo() ? 2 : 1, sampleRate);\r
+ setup(output.toByteArray(), channels, sampleRate);\r
} catch (Throwable ex) {\r
throw new GdxRuntimeException("Error reading audio data.", ex);\r
}\r
try {\r
return soundClass.getConstructor(new Class[] {OpenALAudio.class, FileHandle.class}).newInstance(this, file);\r
} catch (Exception ex) {\r
- throw new GdxRuntimeException("Error creating sound " + soundClass.getName() + " for file: " + file);\r
+ throw new GdxRuntimeException("Error creating sound " + soundClass.getName() + " for file: " + file, ex);\r
}\r
}\r
\r
try {\r
return musicClass.getConstructor(new Class[] {OpenALAudio.class, FileHandle.class}).newInstance(this, file);\r
} catch (Exception ex) {\r
- throw new GdxRuntimeException("Error creating music " + musicClass.getName() + " for file: " + file);\r
+ throw new GdxRuntimeException("Error creating music " + musicClass.getName() + " for file: " + file, ex);\r
}\r
}\r
\r
if (state != AL_STOPPED) alSourceStop(streamID);\r
alDeleteSources(streamID);\r
}\r
- \r
+\r
AL.destroy();\r
}\r
\r
\r
public AudioRecorder newAudioRecoder (int samplingRate, boolean isMono) {\r
return new JavaSoundAudioRecorder(samplingRate, isMono);\r
- } \r
+ }\r
}\r
import java.awt.BorderLayout;\r
import java.awt.event.ActionEvent;\r
import java.awt.event.ActionListener;\r
+import java.awt.event.KeyAdapter;\r
+import java.awt.event.KeyEvent;\r
import java.awt.event.MouseAdapter;\r
import java.awt.event.MouseEvent;\r
+import java.util.prefs.Preferences;\r
\r
import javax.swing.DefaultListSelectionModel;\r
import javax.swing.JButton;\r
public TestList () {\r
setLayout(new BorderLayout());\r
\r
- final JList list = new JList(GdxTests.getNames());\r
final JButton button = new JButton("Run Test");\r
+\r
+ final JList list = new JList(GdxTests.getNames());\r
JScrollPane pane = new JScrollPane(list);\r
\r
DefaultListSelectionModel m = new DefaultListSelectionModel();\r
}\r
});\r
\r
+ list.addKeyListener(new KeyAdapter() {\r
+ public void keyPressed (KeyEvent e) {\r
+ if (e.getKeyCode() == KeyEvent.VK_ENTER) button.doClick();\r
+ }\r
+ });\r
+\r
+ list.setSelectedValue(Preferences.systemNodeForPackage(GdxTests.class).get("last", null), true);\r
+\r
button.addActionListener(new ActionListener() {\r
@Override public void actionPerformed (ActionEvent e) {\r
String testName = (String)list.getSelectedValue();\r
GdxTest test = GdxTests.newTest(testName);\r
new LwjglApplication(test, testName, 480, 320, test.needsGL20());\r
+ Preferences.systemNodeForPackage(GdxTests.class).put("last", testName);\r
}\r
});\r
\r
public class SoundTest extends GdxTest implements InputProcessor {\r
Sound sound;\r
Music music;\r
- float volume = 1.0f;\r
+ float volume = 0.5f;\r
\r
@Override public void render () {\r
}\r
@Override public void create () {\r
sound = Gdx.audio.newSound(Gdx.files.getFileHandle("data/shotgun.wav", FileType.Internal));\r
\r
-// music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/threeofaperfectpair.mp3", FileType.Internal));\r
- music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/cloudconnected.ogg", FileType.Internal));\r
+ music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/threeofaperfectpair.mp3", FileType.Internal));\r
+ music.setVolume(volume);\r
music.play();\r
music.setLooping(true);\r
Gdx.input.setInputProcessor(this);\r
}\r
\r
@Override public boolean touchDown (int x, int y, int pointer, int newParam) {\r
- sound.play(0.5f);\r
+ sound.play(1f);\r
return false;\r
}\r
\r