[英]calling a class from another directory
I know this sounds a bit silly.. but im really confused about this: 我知道这听起来有些愚蠢..但是我对此感到非常困惑:
I need to instanciate the FFTProcessor class to the main activity, or move it to the com.example.audioconv
package (i tried moving it but i had problems loading the libraries). 我需要实例化FFTProcessor类到主要活动,或将其移动到
com.example.audioconv
包(我尝试移动它,但在加载库时遇到问题)。
The FFTProcessor
class calls the native functions implemented in in_waslos_kneo_libsimplefft_FFTProcessor.c
FFTProcessor
类调用in_waslos_kneo_libsimplefft_FFTProcessor.c
实现的本机函数
Here is where i have to call the class: 这是我必须叫课的地方:
public class MainActivity extends Activity {
//---------------------------------------------------------variables declaration
File externalDir1=Environment.getExternalStorageDirectory();
File externalDir2=Environment.getExternalStorageDirectory();
File f1=new File(externalDir1.getAbsolutePath()+"/Test"+File.separator+"wav1.wav");
File f2=new File(externalDir2.getAbsolutePath()+"/Test"+File.separator+"wav2.wav");
//-----------------------------------load libraryv
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
//-------------------------read files
float[]raw1=bytesToFloats(read(f1));
float[]raw2=bytesToFloats(read(f2));
float[] im1=new float[raw1.length];//----imaginary parts
float[] im2=new float[raw2.length];//----
for(int j=0;j<im1.length;j++)
{
im1[j]=0;
}
for(int k=0;k<im2.length;k++)
{
im2[k]=0;
}
int convhandle= FFTProcessor.createFastConvolutionContext(raw1.length, raw1, im1);
FFTProcessor.performFastConvolution(convhandle, raw2, im2);
//------------------------------------------------convolution log
for (int i=0;i<raw2.length; i++)
Log.i("convolution", "conv output "+raw2+" "+im2);
And in FFTProcessor class: 在FFTProcessor类中:
package in.waslos.kneo.libsimplefft;
public class FFTProcessor{
public static final byte FFT_MODE_NORMAL = 0;
public static final byte FFT_MODE_INVERSE = 1;
public static final byte CPLX_TYPE_SP = 0;
public static final byte CPLX_TYPE_DP = 1;
public static final byte CPLX_TYPE_INT = 2;
static{
System.loadLibrary("simplefft");
System.loadLibrary("simplefft4j");
}
private static native int createFFTContext(int samples, byte mode, byte type);
private static native void destroyFFTContext(int handle);
....
any help? 有什么帮助吗?
您可以使另一个项目如何包含第二个目录作为源代码,并将其添加到项目的类路径中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.