view swig/java/test.java @ 96:757e6f99dcd7

Dan Stowell: Removed strange "zeroing" part of xtract_mfcc() which was zeroing a load of elements despite the fact that they're ignored by the DCT process called next, and never used for anything. This was writing to an assumed large result array (same size as number of FFT bins) despite the fact that only a small number of MFCCs (typically less than 50) are required, therefore either wasting memory or writing to memory it shouldn't do!
author Dan Stowell <danstowell@gmail.com>
date Wed, 03 Oct 2007 13:43:16 +0000
parents 35a3bb5c3ffd
children 15bc88384ecd
line wrap: on
line source

import xtract.core.*;

public class test {
    public static void main(String argv[]) {

	try {
	    System.loadLibrary("jxtract");
	}
	catch (UnsatisfiedLinkError e) {
	    System.out.println("Failed to load the library \"jxtract\"");
	    System.out.println(e.toString());
	}

	System.out.println("\nRunning libxtract Java bindings test...\n");

        int len = 5;
        int retval = 0;
        float result[];
        floatArray a = new floatArray(len);
        SWIGTYPE_p_void myvoid = null;

        result = new float[1];

	System.out.print("The mean of: ");

        for (int i = 0; i < len; i++){
	    System.out.print(i * 2 + ", ");
            a.setitem(i, i * 2);
	}

	System.out.print("is: ");

        retval = xtract.xtract_mean(a.cast(), len, myvoid, result);

        System.out.print(result[0] + "\n");

	System.out.println("\nFinished!\n\n");

    }
}