Skip to content

Commit

Permalink
Improve JniTest
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias <webmaster@pottgames.de>
  • Loading branch information
Hangman committed Aug 31, 2023
1 parent 48aa984 commit c68eb5e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions core/src/test/java/de/pottgames/tuningfork/test/JniTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;

import de.pottgames.tuningfork.Audio;
import de.pottgames.tuningfork.OpenDeviceException;
import de.pottgames.tuningfork.SoundBuffer;
import de.pottgames.tuningfork.UnsupportedAudioDeviceException;
import de.pottgames.tuningfork.WaveLoader;

public class JniTest extends ApplicationAdapter {
Expand All @@ -18,14 +16,21 @@ public class JniTest extends ApplicationAdapter {

@Override
public void create() {
try {
this.audio = Audio.initSafe();
} catch (OpenDeviceException | UnsupportedAudioDeviceException e) {
e.printStackTrace();
}
this.audio = Audio.init();

// load via java decoder
final long javaStartTime = System.nanoTime();
this.sound = WaveLoader.load(Gdx.files.internal("ima_adpcm_stereo.wav"), true);
final long javaEndTime = System.nanoTime();
this.sound.dispose();
System.out.println("java decoder load time: " + (javaEndTime - javaStartTime) / 1000 / 1000 + " ms");

// load via rust decoder
final long rustStartTime = System.nanoTime();
this.sound = WaveLoader.load(Gdx.files.internal("ima_adpcm_stereo.wav"), false);
System.out.println("Sound duration: " + this.sound.getDuration() + "s");
final long rustEndTime = System.nanoTime();
System.out.println("rust decoder load time: " + (rustEndTime - rustStartTime) / 1000 / 1000 + " ms");

this.sound.play();
}

Expand Down

0 comments on commit c68eb5e

Please sign in to comment.