/*
 * HA_interface.cpp
 *
 */
#include "HA_config.h"

#include "HA_interface.h"
#include "HA_log.h"
//#include "HA_java.h"
#include "HA_ControlObject.h"

namespace HARKAndroid {
ControlObject *HARKControl;
}
#ifdef ENABLE_JNI_FOR_ANDROID
jint HACreate(JNIEnv *env, jobject thiz)
#else
int HACreate()
#endif // ENABLE_JNI_FOR_ANDROID
{
	if (HARKAndroid::HARKControl == NULL) {
		HARKAndroid::HARKControl = new HARKAndroid::ControlObject;
#ifdef ENABLE_JNI_FOR_ANDROID
		HARKAndroid::HARKControl->Create(env, thiz);
#else
		HARKAndroid::HARKControl->Create();
#endif // ENABLE_JNI_FOR_ANDROID
	}
	return(0);
}

#ifdef ENABLE_JNI_FOR_ANDROID
jint HAStart(JNIEnv *env, jobject thiz)
#else
int HAStart()
#endif // ENABLE_JNI_FOR_ANDROID
{
#ifdef ENABLE_JNI_FOR_ANDROID
	int ret = HARKAndroid::HARKControl->Start(env, thiz);
#else
	int ret = HARKAndroid::HARKControl->Start();
#endif // ENABLE_JNI_FOR_ANDROID
	return(ret);
}

#ifdef ENABLE_JNI_FOR_ANDROID
jint HAStop(JNIEnv *env, jobject thiz)
#else
int HAStop()
#endif // ENABLE_JNI_FOR_ANDROID
{
	int ret = HARKAndroid::HARKControl->Stop();
	return(ret);
}

#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParam(JNIEnv *env, jobject thiz)
#else
int HASetParam()
#endif // ENABLE_JNI_FOR_ANDROID
{
#ifdef ENABLE_JNI_FOR_ANDROID
	int ret = HARKAndroid::HARKControl->SetParam(env, thiz);
#else
	int ret = HARKAndroid::HARKControl->SetParam();
#endif // ENABLE_JNI_FOR_ANDROID
	return(ret);
}

#ifdef ENABLE_JNI_FOR_ANDROID
jint HAGetParam(JNIEnv *env, jobject thiz/*, jint cmd_module, jint cmd_param, jintArray int_array_params, jfloatArray float_array_params*/)
#else
int HAGetParam()
#endif // ENABLE_JNI_FOR_ANDROID
{
	/*
	jboolean b;
	jint *i_ar_params = env->GetIntArrayElements(int_array_params, &b);
	jfloat *f_ar_params = env->GetDoubleArrayElements(float_array_params, &b);
	*/
#ifdef ENABLE_JNI_FOR_ANDROID
	int ret = HARKAndroid::HARKControl->GetParam(env, thiz);
#else
	int ret = HARKAndroid::HARKControl->GetParam();
#endif // ENABLE_JNI_FOR_ANDROID
	return(ret);
}

#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetJuliusMFTServer(JNIEnv *env, jobject thiz, jstring serveraddr)
#else
int HASetJuliusMFTServer(const char * const serveraddr)
#endif
{

#ifdef ENABLE_JNI_FOR_ANDROID
	const char *c1 = env->GetStringUTFChars(serveraddr, 0);
	HARKAndroid::HARKControl->set_jiliusMFThostname(c1);
	env->ReleaseStringUTFChars(serveraddr, c1);
#else
	HARKAndroid::HARKControl->set_jiliusMFThostname(serveraddr);
#endif // ENABLE_JNI_FOR_ANDROID
	return(0);
}

#ifdef ENABLE_JNI_FOR_ANDROID
//jint HASetRaspZXServer(JNIEnv *env, jobject thiz, jboolean connect, jstring serveraddr)
jint HASetSocketMicServer(JNIEnv *env, jobject thiz, jboolean connect, jstring serveraddr)
#else
//int HASetRaspZXServer(const bool connect, const char * const serveraddr)
int HASetSocketMicServer(const bool connect, const char * const serveraddr)
#endif
{
#ifdef ENABLE_JNI_FOR_ANDROID
	const char *c1 = env->GetStringUTFChars(serveraddr, 0);
	//HARKAndroid::HARKControl->set_RaspZX(connect, c1);
	HARKAndroid::HARKControl->set_SocketMic(connect, c1);
	env->ReleaseStringUTFChars(serveraddr, c1);
#else
	//HARKAndroid::HARKControl->set_RaspZX(connect, serveraddr);
	HARKAndroid::HARKControl->set_SocketMic(connect, serveraddr);
#endif // ENABLE_JNI_FOR_ANDROID
	return(0);
}


#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamSendPort(JNIEnv *env, jobject thiz, jint send_port)
#else
int HASetParamSendPort(int send_port)
#endif
{
	HARKAndroid::HARKControl->SetParamSendPort(send_port);
	return 0;
}

#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetAudioParam(JNIEnv *env, jobject thiz, jint input_channels, jint advance)
#else
int HASetAudioParam(int input_channels, int advance)
#endif
{
	HARKAndroid::HARKControl->SetAudioParam(input_channels, advance);
	return 0;
}

#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetGhdssParamFilePath(JNIEnv *env, jobject thiz, jstring file_name)
#else
int HASetGhdssParamFilePath(const char * const file_name)
#endif
{
#ifdef ENABLE_JNI_FOR_ANDROID
	const char *c1 = env->GetStringUTFChars(file_name, 0);
	HARKAndroid::HARKControl->SetGhdssParamFilePath(c1);
	env->ReleaseStringUTFChars(file_name, c1);
#else
	HARKAndroid::HARKControl->SetGhdssParamFilePath(file_name);
#endif

	return 0;
}

#ifdef ENABLE_JNI_FOR_ANDROID
// Logcatなしでのエラー通知検討 : c側からjavaを呼び出す Ex) EmbeddedHARKMainActivity.callJni を呼び出す
//jvoid Java_jp_hark_embeddedhark_EmbeddedHARKMainActivity_callbackJNI(JNIEnv* env, jobject thiz)
//{
//    // Get class
//    jclass jcls = (*env)->GetObjectClass(env, thiz );
//    // Get method
//    jmethodID  mj = (*env)->GetMethodID(env, jcls, "callJni", "()V");
//    // Call method
//    (*env)->CallObjectMethod(env, thiz, mj);
//}

jint HASetUSBMicDeviceType(JNIEnv *env, jobject thiz, jint device_type)
{
	HARKAndroid::HARKControl->set_USBMicDeviceType(device_type);
	return 0;
}

//jint HASetRaspLCDevice(JNIEnv *env, jobject thiz, jint channels, jint bits)
jint HASetUSBMicDevice(JNIEnv *env, jobject thiz, jint channels, jint bits)
{
	//HARKAndroid::HARKControl->set_RaspLCDevice(channels, bits);
	HARKAndroid::HARKControl->set_USBMicDevice(channels, bits);
	return 0;
}

//jint HASetRaspLCInterface(JNIEnv *env, jobject thiz, jint if_no, jint ep_addr, jint max_packet_size)
jint HASetUSBMicInterface(JNIEnv *env, jobject thiz, jint if_no, jint ep_addr, jint max_packet_size)
{
	//HARKAndroid::HARKControl->set_RaspLCInterface(if_no, ep_addr, max_packet_size);
	HARKAndroid::HARKControl->set_USBMicInterface(if_no, ep_addr, max_packet_size);
	return 0;
}

//jint HASetRaspLCFd(JNIEnv *env, jobject thiz, jint fd)
jint HASetUSBMicFd(JNIEnv *env, jobject thiz, jint fd)
{
	//HARKAndroid::HARKControl->set_RaspLCFd(fd);
	HARKAndroid::HARKControl->set_USBMicFd(fd);
	return 0;
}


// K.Takagi
jint HASetLocalizeMusicParamNumSource(JNIEnv *env, jobject thiz, jint num_source)
{
	return HARKAndroid::HARKControl->SetLocalizeMusicParamNumSource(num_source);
}

jint HASetLocalizeMusicParamPeriod(JNIEnv *env, jobject thiz, jint period)
{
	return HARKAndroid::HARKControl->SetLocalizeMusicParamPeriod(period);
}

jint HASetLocalizeMusicParamFrequency(JNIEnv *env, jobject thiz, jint low_bound_freq, jint upper_bound_freq)
{
	return HARKAndroid::HARKControl->SetLocalizeMusicParamFrequency(low_bound_freq, upper_bound_freq);
}

jint HASetLocalizeMusicParamDeg(JNIEnv *env, jobject thiz, jint min_deg, jint max_deg)
{
	return HARKAndroid::HARKControl->SetLocalizeMusicParamDeg(min_deg, max_deg);
}

jint HASetLocalizeMusicParamFilePath(JNIEnv *env, jobject thiz, jstring file_name)
{
	const char *c1 = env->GetStringUTFChars(file_name, 0);
	HARKAndroid::HARKControl->SetLocalizeMusicParamFilePath(c1);
	env->ReleaseStringUTFChars(file_name, c1);

	return 0;
}

jint HASetSourceTrackerParamThresh(JNIEnv *env, jobject thiz, jfloat thresh)
{
	return HARKAndroid::HARKControl->SetSourceTrackerParamThresh(thresh);
}

jint HASetSourceTrackerParamPauseLength(JNIEnv *env, jobject thiz, jfloat pause_length)
{
	return HARKAndroid::HARKControl->SetSourceTrackerParamPauseLength(pause_length);
}

jint HASetSourceTrackerParamMinSrcInterval(JNIEnv *env, jobject thiz, jfloat min_src_interval)
{
	return HARKAndroid::HARKControl->SetSourceTrackerParamMinSrcInterval(min_src_interval);
}

jint HASetSourceIntervalExtenderParam(JNIEnv *env, jobject thiz, jint preroll_length)
{
	return HARKAndroid::HARKControl->SetSourceIntervalExtenderParam(preroll_length);
}


jint HASetEstimateLeakParamFactor(JNIEnv *env, jobject thiz, jfloat factor)
{
	return HARKAndroid::HARKControl->SetEstimateLeakParamFactor(factor);
}

jint HASetNoneSeparationParamTargetChannel(JNIEnv *env, jobject thiz, jint target_channel)
{
	return HARKAndroid::HARKControl->SetNoneSeparationParamTargetChannel(target_channel);
}

jint HASetHrleParamLx(JNIEnv *env, jobject thiz, jfloat lx)
{
	return HARKAndroid::HARKControl->SetHrleParamLx(lx);
}
jint HASetHrleParamTr(JNIEnv *env, jobject thiz, jfloat tr)
{
	return HARKAndroid::HARKControl->SetHrleParamTr(tr);
}
jint HASetHrleParamMinLv(JNIEnv *env, jobject thiz, jfloat min_lv)
{
	return HARKAndroid::HARKControl->SetHrleParamMinLv(min_lv);
}
jint HASetHrleParamStepLv(JNIEnv *env, jobject thiz, jfloat step_lv)
{
	return HARKAndroid::HARKControl->SetHrleParamStepLv(step_lv);
}
jint HASetHrleParamNumBin(JNIEnv *env, jobject thiz, jint num_bin)
{
	return HARKAndroid::HARKControl->SetHrleParamNumBin(num_bin);
}

jint HASetWhiteNoiseAdderParamLevel(JNIEnv *env, jobject thiz, jfloat wn_level)
{
	return HARKAndroid::HARKControl->SetWhiteNoiseAdderParamLevel(wn_level);
}

jint HASetPreEmphasisParamCutoff(JNIEnv *env, jobject thiz, jint cut_off)
{
	return HARKAndroid::HARKControl->SetPreEmphasisParamCutoff(cut_off);
}
jint HASetPreEmphasisParamCoef(JNIEnv *env, jobject thiz, jfloat coef)
{
	return HARKAndroid::HARKControl->SetPreEmphasisParamCoef(coef);
}

jint HASetMelFilterParamCutoff(JNIEnv *env, jobject thiz, jint cut_off)
{
	return HARKAndroid::HARKControl->SetMelFilterParamCutoff(cut_off);
}
jint HASetMelFilterParamFreq(JNIEnv *env, jobject thiz, jint min_freq, jint max_freq)
{
	return HARKAndroid::HARKControl->SetMelFilterParamFreq(min_freq, max_freq);
}

jint HASetHarkPath(JNIEnv *env, jobject thiz, jstring path)
{
	const char *c1 = env->GetStringUTFChars(path, 0);
	HARKAndroid::HARKControl->setHarkPath(c1);
	env->ReleaseStringUTFChars(path, c1);

	return 0;
}







// takigahira

#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputTypeMicRaw(JNIEnv *env, jobject thiz, jint type)
#else
int HASetParamOutputTypeMicRaw(int type)
#endif
{
    HARKAndroid::HARKControl->SetParamSaveMicRawType(type);
    return 0;
}
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputTypeMicSpec(JNIEnv *env, jobject thiz, jint type)
#else
int HASetParamOutputTypeMicSpec(int type)
#endif
{
    HARKAndroid::HARKControl->SetParamSaveMicSpecType(type);
    return 0;
}
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputTypeLocalizePowSpec(JNIEnv *env, jobject thiz, jint type)
#else
int HASetParamOutputTypeLocalizePowSpec(int type)
#endif
{
    HARKAndroid::HARKControl->SetParamSaveLocalizePowerSpecType(type);
    return 0;
}
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputTypeSepRaw(JNIEnv *env, jobject thiz, jint type)
#else
int HASetParamOutputTypeSepRaw(int type)
#endif
{
    HARKAndroid::HARKControl->SetParamSaveSepRawType(type);
    return 0;
}
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputTypeSepSpec(JNIEnv *env, jobject thiz, jint type)
#else
int HASetParamOutputTypeSepSpec(int type)
#endif
{
    HARKAndroid::HARKControl->SetParamSaveSepSpecType(type);
    return 0;
}
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputTypeSepFeature(JNIEnv *env, jobject thiz, jint type, jint sub_type)
#else
int HASetParamOutputTypeSepFeature(int type, int sub_type)
#endif
{
    HARKAndroid::HARKControl->SetParamSaveSepFeatureType(type, sub_type);
    return 0;
}
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputTypeSource(JNIEnv *env, jobject thiz, jint type)
#else
int HASetParamOutputTypeSource(int type)
#endif
{
    HARKAndroid::HARKControl->SetParamSaveSourceType(type);
    return 0;
}


//////
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputFilePathMicRaw(JNIEnv *env, jobject thiz, jstring file_name)
#else
int HASetParamOutputFilePathMicRaw(const char * const file_name)
#endif
{
#ifdef ENABLE_JNI_FOR_ANDROID
    const char *c1 = env->GetStringUTFChars(file_name, 0);
    HARKAndroid::HARKControl->SetOutputParamMicPCMFilePath(c1);
    env->ReleaseStringUTFChars(file_name, c1);
#else
    HARKAndroid::HARKControl->SetOutputParamMicPCMFilePath(file_name);
#endif
    return 0;
}
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputFilePathMicSpec(JNIEnv *env, jobject thiz, jstring file_name)
#else
int HASetParamOutputFilePathMicSpec(const char * const file_name)
#endif
{
#ifdef ENABLE_JNI_FOR_ANDROID
    const char *c1 = env->GetStringUTFChars(file_name, 0);
    HARKAndroid::HARKControl->SetGhdssParamFilePath(c1);
    env->ReleaseStringUTFChars(file_name, c1);
#else
    HARKAndroid::HARKControl->SetGhdssParamFilePath(file_name);
#endif
    return 0;
}
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputFilePathLocalizePowSpec(JNIEnv *env, jobject thiz, jstring file_name)
#else
int HASetParamOutputFilePathLocalizePowSpec(const char * const file_name)
#endif
{
#ifdef ENABLE_JNI_FOR_ANDROID
    const char *c1 = env->GetStringUTFChars(file_name, 0);
    HARKAndroid::HARKControl->SetOutputParamPowSpecFilePath(c1);
    env->ReleaseStringUTFChars(file_name, c1);
#else
    HARKAndroid::HARKControl->SetOutputParamPowSpecFilePath(file_name);
#endif
    return 0;
}
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputFilePathSepRaw(JNIEnv *env, jobject thiz, jstring file_name)
#else
int HASetParamOutputFilePathSepRaw(const char * const file_name)
#endif
{
#ifdef ENABLE_JNI_FOR_ANDROID
    const char *c1 = env->GetStringUTFChars(file_name, 0);
    HARKAndroid::HARKControl->SetOutputParamSepPCMFilePath(c1);
    env->ReleaseStringUTFChars(file_name, c1);
#else
    HARKAndroid::HARKControl->SetOutputParamSepPCMFilePath(file_name);
#endif
    return 0;
}
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputFilePathSepSpec(JNIEnv *env, jobject thiz, jstring file_name)
#else
int HASetParamOutputFilePathSepSpec(const char * const file_name)
#endif
{
#ifdef ENABLE_JNI_FOR_ANDROID
    const char *c1 = env->GetStringUTFChars(file_name, 0);
    HARKAndroid::HARKControl->SetGhdssParamFilePath(c1);
    env->ReleaseStringUTFChars(file_name, c1);
#else
    HARKAndroid::HARKControl->SetGhdssParamFilePath(file_name);
#endif
    return 0;
}
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputFilePathSepFeature(JNIEnv *env, jobject thiz, jstring file_name)
#else
int HASetParamOutputFilePathSepFeature(const char * const file_name)
#endif
{
#ifdef ENABLE_JNI_FOR_ANDROID
    const char *c1 = env->GetStringUTFChars(file_name, 0);
    HARKAndroid::HARKControl->SetOutputParamSepFeatureFilePath(c1);
    env->ReleaseStringUTFChars(file_name, c1);
#else
    HARKAndroid::HARKControl->SetOutputParamSepFeatureFilePath(file_name);
#endif
    return 0;
}
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamOutputFilePathSource(JNIEnv *env, jobject thiz, jstring file_name)
#else
int HASetParamOutputFilePathSource(const char * const file_name)
#endif
{
#ifdef ENABLE_JNI_FOR_ANDROID
    const char *c1 = env->GetStringUTFChars(file_name, 0);
    HARKAndroid::HARKControl->SetOutputParamSourceFilePath(c1);
    env->ReleaseStringUTFChars(file_name, c1);
#else
    HARKAndroid::HARKControl->SetOutputParamSourceFilePath(file_name);
#endif
    return 0;
}


////////
#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamLocalizeAlgorithm(JNIEnv *env, jobject thiz, jint algorithm)
#else
int HASetParamLocalizeAlgorithm(int algorithm)
#endif
{
    HARKAndroid::HARKControl->SetParamSwitchLocalizeAlgorithm(algorithm);
    return 0;
}

#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamSeparationAlgorithm(JNIEnv *env, jobject thiz, jint algorithm)
#else
int HASetParamSeparationAlgorithm(int algorithm)
#endif
{
    HARKAndroid::HARKControl->SetParamSwitchSeparationAlgorithm(algorithm);
    return 0;
}

#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamFilterAlgorithm(JNIEnv *env, jobject thiz, jint algorithm)
#else
int HASetParamFilterAlgorithm(int algorithm)
#endif
{
    HARKAndroid::HARKControl->SetParamSwitchFilterAlgorithm(algorithm);
    return 0;
}


#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetParamSIDAlgorithm(JNIEnv *env, jobject thiz, jint algorithm)
#else
int HASetParamSIDAlgorithm(int algorithm)
#endif
{
    HARKAndroid::HARKControl->SetParamSwitchSIDAlgorithm(algorithm);
    return 0;
}




jint HASetExtendedSourceTrackerParamThresh(JNIEnv *env, jobject thiz, jfloat thresh)
{
    return HARKAndroid::HARKControl->SetExtendedSourceTrackerParamThresh(thresh);
}

jint HASetExtendedSourceTrackerParamPauseLength(JNIEnv *env, jobject thiz, jint pause_length)
{
    return HARKAndroid::HARKControl->SetExtendedSourceTrackerParamPauseLength(pause_length);
}

jint HASetExtendedSourceTrackerParamRemoveLength(JNIEnv *env, jobject thiz, jint remove_length)
{
    return HARKAndroid::HARKControl->SetExtendedSourceTrackerParamRemoveLength(remove_length);
}

jint HASetExtendedSourceTrackerParamRemoveCheckLength(JNIEnv *env, jobject thiz, jint remove_check_length)
{
    return HARKAndroid::HARKControl->SetExtendedSourceTrackerParamRemoveCheckLength(remove_check_length);
}

jint HASetExtendedSourceTrackerParamCompareMode(JNIEnv *env, jobject thiz, jint compare_mode)
{
    return HARKAndroid::HARKControl->SetExtendedSourceTrackerParamCompareMode(compare_mode);
}

jint HASetExtendedSourceTrackerParamMinSrcInterval(JNIEnv *env, jobject thiz, jfloat min_src_interval)
{
    return HARKAndroid::HARKControl->SetExtendedSourceTrackerParamMinSrcInterval(min_src_interval);
}

jint HASetExtendedSourceTrackerParamMinTFIndexInterval(JNIEnv *env, jobject thiz, jint min_tfindex_interval)
{
    return HARKAndroid::HARKControl->SetExtendedSourceTrackerParamMinTFIndexInterval(min_tfindex_interval);
}

jint HASetExtendedSourceTrackerParamMaxNumSource(JNIEnv *env, jobject thiz, jint max_num_source)
{
    return HARKAndroid::HARKControl->SetExtendedSourceTrackerParamMaxNumSource(max_num_source);
}

jint HASetExtendedSourceTrackerParamPrerollLength(JNIEnv *env, jobject thiz, jint preroll_length)
{
    return HARKAndroid::HARKControl->SetExtendedSourceTrackerParamPrerollLength(preroll_length);
}

jint HASetExtendedSourceTrackerParamRemovedSourceAlgorithm(JNIEnv *env, jobject thiz, jint removed_source_algorithm)
{
    return HARKAndroid::HARKControl->SetExtendedSourceTrackerParamRemovedSourceAlgorithm(removed_source_algorithm);
}

jint HASetExtendedSourceTrackerParamMinID(JNIEnv *env, jobject thiz, jint min_id)
{
    return HARKAndroid::HARKControl->SetExtendedSourceTrackerParamMinID(min_id);
}

jint HASetNormalizeMusicParamInitialThreshold(JNIEnv *env, jobject thiz, jfloat initial_threshold)
{
    return HARKAndroid::HARKControl->SetNormalizeMusicParamInitialThreshold(initial_threshold);
}

jint HASetNormalizeMusicParamActiveProp(JNIEnv *env, jobject thiz, jfloat active_prop)
{
    return HARKAndroid::HARKControl->SetNormalizeMusicParamActiveProp(active_prop);
}

jint HASetNormalizeMusicParamUpdateInterval(JNIEnv *env, jobject thiz, jint update_interval)
{
    return HARKAndroid::HARKControl->SetNormalizeMusicParamUpdateInterval(update_interval);
}

jint HASetNormalizeMusicParamPriorWeight(JNIEnv *env, jobject thiz, jfloat prior_weight)
{
    return HARKAndroid::HARKControl->SetNormalizeMusicParamPriorWeight(prior_weight);
}

jint HASetNormalizeMusicParamMaxSourceNum(JNIEnv *env, jobject thiz, jint max_source_num)
{
    return HARKAndroid::HARKControl->SetNormalizeMusicParamMaxSourceNum(max_source_num);
}

jint HASetNormalizeMusicParamParticleNum(JNIEnv *env, jobject thiz, jint particle_num)
{
    return HARKAndroid::HARKControl->SetNormalizeMusicParamParticleNum(particle_num);
}

jint HASetNormalizeMusicParamLocalPeakMargin(JNIEnv *env, jobject thiz, jfloat local_peak_margin)
{
    return HARKAndroid::HARKControl->SetNormalizeMusicParamLocalPeakMargin(local_peak_margin);
}

jint HASetBeamformingParamBFMethod(JNIEnv *env, jobject thiz, jint bf_method)
{
    return HARKAndroid::HARKControl->SetBeamformingParamBFMethod(bf_method);
}

#ifdef ENABLE_JNI_FOR_ANDROID
jint HASetBeamformingParamTFConjFilePath(JNIEnv *env, jobject thiz, jstring file_name)
#else
int HASetBeamformingParamTFConjFilePath(const char * const file_name)
#endif
{
#ifdef ENABLE_JNI_FOR_ANDROID
    const char *c1 = env->GetStringUTFChars(file_name, 0);
    HARKAndroid::HARKControl->SetBeamformingParamTFConjFilePath(c1);
    env->ReleaseStringUTFChars(file_name, c1);
#else
    HARKAndroid::HARKControl->SetBeamformingParamTFConjFilePath(file_name);
#endif
    return 0;
}
jint HASetBeamformingParamLCMethod(JNIEnv *env, jobject thiz, jint lc_method)
{
    return HARKAndroid::HARKControl->SetBeamformingParamLCMethod(lc_method);
}

jint HASetBeamformingParamLCMyu(JNIEnv *env, jobject thiz, jfloat lc_myu)
{
    return HARKAndroid::HARKControl->SetBeamformingParamLCMyu(lc_myu);
}

jint HASetBeamformingParamSSMethod(JNIEnv *env, jobject thiz, jint ss_method)
{
    return HARKAndroid::HARKControl->SetBeamformingParamSSMethod(ss_method);
}

jint HASetBeamformingParamSSMyu(JNIEnv *env, jobject thiz, jfloat ss_myu)
{
    return HARKAndroid::HARKControl->SetBeamformingParamSSMyu(ss_myu);
}

jint HASetBeamformingParamSSScale(JNIEnv *env, jobject thiz, jfloat ss_scale)
{
    return HARKAndroid::HARKControl->SetBeamformingParamSSScale(ss_scale);
}

jint HASetBeamformingParamNlFunc(JNIEnv *env, jobject thiz, jint nl_func)
{
    return HARKAndroid::HARKControl->SetBeamformingParamNlFunc(nl_func);
}

jint HASetBeamformingParamDecompositionAlgorithm(JNIEnv *env, jobject thiz, jint decomposition_algorithm)
{
    return HARKAndroid::HARKControl->SetBeamformingParamDecompositionAlgorithm(decomposition_algorithm);
}

jint HASetBeamformingParamAlpha(JNIEnv *env, jobject thiz, jfloat alpha)
{
    return HARKAndroid::HARKControl->SetBeamformingParamAlpha(alpha);
}

jint HASetBeamformingParamRegFactor(JNIEnv *env, jobject thiz, jfloat reg_factor)
{
    return HARKAndroid::HARKControl->SetBeamformingParamRegFactor(reg_factor);
}
/*
jint HASetLogisticRegressionParamCepstrumNormalize(JNIEnv *env, jobject thiz, jint compare_mode)
{
    return HARKAndroid::HARKControl->(compare_mode);
}

jint HASetLogisticRegressionParam(JNIEnv *env, jobject thiz, jint compare_mode)
{
    return HARKAndroid::HARKControl->(compare_mode);
}

jint HASetLogisticRegressionParam(JNIEnv *env, jobject thiz, jint compare_mode)
{
    return HARKAndroid::HARKControl->(compare_mode);
}

jint HASetLogisticRegressionParam(JNIEnv *env, jobject thiz, jint compare_mode)
{
    return HARKAndroid::HARKControl->(compare_mode);
}

jint HASetLogisticRegressionParam(JNIEnv *env, jobject thiz, jint compare_mode)
{
    return HARKAndroid::HARKControl->(compare_mode);
}

jint HASetLogisticRegressionParam(JNIEnv *env, jobject thiz, jint compare_mode)
{
    return HARKAndroid::HARKControl->(compare_mode);
}
*/









#endif // ENABLE_JNI_FOR_ANDROID

#ifdef IS_APPLE_IOS
int HASetUserParamLM(const struct Param_LocalizeMUSIC_t * const arg)
{
	//HARKAndroid::HARKControl->setParam(*reinterpret_cast<const Param_LocalizeMUSIC_t *>(arg));
	HARKAndroid::HARKControl->setParam(*arg);
    return(0);
}
int HASetUserParamSourceTracker(const struct Param_SourceTracker_t * const arg)
{
	//HARKAndroid::HARKControl->setParam(*reinterpret_cast<const Param_SourceTracker_t *>(arg));
	HARKAndroid::HARKControl->setParam(*arg);
    return(0);
}
int HASetUserParamSourceIntervalExtender(const struct Param_SourceIntervalExtender_t * const arg)
{
	//HARKAndroid::HARKControl->setParam(*reinterpret_cast<const Param_SourceIntervalExtender_t *>(arg));
	HARKAndroid::HARKControl->setParam(*arg);
    return(0);
}
int HASetUserParamEstimateLeak(const struct Param_EstimateLeak_t * const arg)
{
	//HARKAndroid::HARKControl->setParam(*reinterpret_cast<const Param_EstimateLeak_t *>(arg));
	HARKAndroid::HARKControl->setParam(*arg);
    return(0);
}
int HASetUserParamHrle(const struct Param_HRLE_t * const arg)
{
	//HARKAndroid::HARKControl->setParam(*reinterpret_cast<const Param_HRLE_t *>(arg));
	HARKAndroid::HARKControl->setParam(*arg);
    return(0);
}
int HASetUserParamWhiteNoiseAdder(const struct Param_WhiteNoiseAdder_t * const arg)
{
	//HARKAndroid::HARKControl->setParam(*reinterpret_cast<const Param_WhiteNoiseAdder_t *>(arg));
	HARKAndroid::HARKControl->setParam(*arg);
    return(0);
}
int HASetUserParamPreEmphasis(const struct Param_PreEmphasis_t * const arg)
{
	//HARKAndroid::HARKControl->setParam(*reinterpret_cast<const Param_PreEmphasis_t *>(arg));
 	HARKAndroid::HARKControl->setParam(*arg);
    return(0);
}
int HASetUserParamMelFilterBank(const struct Param_MelFilterBank_t * const arg)
{
	//HARKAndroid::HARKControl->setParam(*reinterpret_cast<const Param_MelFilterBank_t *>(arg));
	HARKAndroid::HARKControl->setParam(*arg);
    return(0);
}
#endif
