62 4. ANALOG-TO-DIGITAL SIGNAL CONVERSION
break loop;
}
process(currentFrame.getAudio());
getOutput(currentFrame.getAudio(), Settings.output);
output.put(currentFrame);
}
process() takes the short array input corresponding to the input signal and processes it using
the native code methods. After the processing method is called, the samples corresponding to
the filtered output will be stored temporarily in a memory location allocated by the native code.
To retrieve the filtered signal, the getOutput() method is used to overwrite the contents of the
WaveFrame audio buffer with the desired output as selected by an integer based switch.
L3.5 JNI NATIVE C CODE
e above explanation on Java indicated how to write a wrapper around C codes. ere are three
basic steps that need to be followed when writing C codes using JNI.
1. Native code definitions—within one of the Java classes, it is required to have code dec-
larations which match the signature (inputs and outputs match types) of the functions
implemented in the native code. In the example app, these definitions appear in the Fil-
ters class. Another example is shown below:
package <tld>.<your_domain>.<your_package>;
public class <YourClass> {
public static native float[]<yourMethod>(float[] in,
float a, int b);
}
2. Method naming within the native code should follow a set pattern and handle JNI
variables as indicated below. Note that the input and output types shown in the above
yourMethod declaration correspond to the input and output types in the declaration
noted below with the addition of some JNI fields.
jfloatArray
Java_<tld>_<your_domain>_<your_package>_<YourClass>_<yourMethod> (
JNIEnv*env, jobject thiz, jfloatArray in, jfloat a, jint a)
{ /*do stuff*/ }
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.175.182