From 96967d1296c8b6321476be077de6f0c54e7662ff Mon Sep 17 00:00:00 2001 From: Brian Matzon Date: Thu, 28 Oct 2004 20:01:08 +0000 Subject: [PATCH] change to directory scanning thingy --- .../org/lwjgl/test/fmod3/TagFieldTest.java | 155 ++++++++++-------- 1 file changed, 90 insertions(+), 65 deletions(-) diff --git a/src/java/org/lwjgl/test/fmod3/TagFieldTest.java b/src/java/org/lwjgl/test/fmod3/TagFieldTest.java index 4b4acd41..c4bbbe92 100644 --- a/src/java/org/lwjgl/test/fmod3/TagFieldTest.java +++ b/src/java/org/lwjgl/test/fmod3/TagFieldTest.java @@ -32,7 +32,6 @@ package org.lwjgl.test.fmod3; import java.io.File; -import java.io.IOException; import java.nio.IntBuffer; import org.lwjgl.BufferUtils; @@ -49,81 +48,107 @@ import org.lwjgl.fmod3.FSoundTagField; * @version $Revision$ */ public class TagFieldTest { - + + /** Scratch buffer */ + static IntBuffer scratch = BufferUtils.createIntBuffer(16); + + /** + * Main entry point + * + * @param args arguments for app + */ public static void main(String[] args) { if (args.length < 1) { - System.out.println("Usage:\n TagFieldTest "); - - // default to phero.mp3 - args = new String[] { "res\\phero.mp3"}; + System.out.println("Usage:\n TagFieldTest "); + + // default to . + args = new String[] { "."}; System.out.println("Using default: " + args[0]); } - - File file = new File(args[0]); - if (!file.exists()) { - System.out.println("No such file: " + args[0]); - return; - } - + + // initialize fmod try { + System.out.println("Initializing FMOD"); FMOD.create(); + + if (!FSound.FSOUND_Init(44100, 32, 0)) { + System.out.println("Failed to initialize FMOD"); + System.out.println("Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); + FMOD.destroy(); + return; + } } catch (FMODException fmode) { fmode.printStackTrace(); return; } - - System.out.println("Initializing FMOD"); - if (!FSound.FSOUND_Init(44100, 32, 0)) { - System.out.println("Failed to initialize FMOD"); - System.out.println("Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); - return; - } - - System.out.println("Loading " + args[0]); - FSoundStream stream = FSound.FSOUND_Stream_Open(args[0], FSound.FSOUND_NORMAL, 0, 0); - - if (stream != null) { - //scratch buffer - IntBuffer scratch = BufferUtils.createIntBuffer(16); - - FSound.FSOUND_Stream_Play(0, stream); - - // find number of tags - FSound.FSOUND_Stream_GetNumTagFields(stream, scratch); - int tagCount = scratch.get(0); - System.out.println("Found: " + tagCount + " tag fields"); - - // print each name value pair - FSoundTagField field; - for(int i=0; i 0) { + System.out.println("The following list of tags were found:"); + FSoundTagField field; + for (int i = 0; i < tagCount; i++) { + field = new FSoundTagField(); + if (FSound.FSOUND_Stream_GetTagField(stream, i, field)) { + System.out.println(" " + field.getName() + " = '" + field.getValueAsString() + "'"); + } + } + } else { + System.out.println("Unable to locates any tags"); + } + System.out.println(); + FSound.FSOUND_Stream_Close(stream); + } + } } \ No newline at end of file