Hello World - Hangman/TuningFork GitHub Wiki
Alright, what we want to do now, is to let TuningFork say "Hello World" to verify everything's properly set up. By now you should look at an empty libGDX project in your IDE or be ready to modify an existing project with the following code.
Setup libGDX to use TuningFork for audio
The first thing you always need to do is disabling audio in libGDX, so TuningFork can take over. Open up the DesktopLauncher (Lwjgl3Launcher in liftoff projects) and add this to your Lwjgl3ApplicationConfiguration:
config.disableAudio(true);
The whole class could then look like this:
public class DesktopLauncher {
public static void main (String[] arg) {
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.disableAudio(true);
new Lwjgl3Application(new MyGdxGame(), config);
}
}
The Hello World Example
Now you're ready to initialize TuningFork in the core project, load a sound, play it and dispose the resources when the program ends.
public class MyGdxGame extends ApplicationAdapter {
private Audio audio;
private SoundBuffer sound;
@Override
public void create() {
// before we can do anything, we need to initialize our Audio instance
audio = Audio.init();
// load a sound
sound = SoundLoader.load(Gdx.files.internal("sound.wav"));
// play the sound
sound.play();
}
@Override
public void render() {
// nothing to render or update
}
@Override
public void dispose() {
sound.dispose();
// always dispose Audio last
audio.dispose();
}
}
You can also find this example in the repository here.