LIBOPENMPT_MODPLUG_API ModPlugFile* ModPlug_Load(const void* data, int size)
{
	ModPlugFile* file = malloc(sizeof(ModPlugFile));
	if(!file) return NULL;
	memset(file,0,sizeof(ModPlugFile));
	memcpy(&file->settings,&globalsettings,sizeof(ModPlug_Settings));
	file->mod = openmpt_module_create_from_memory(data,size,NULL,NULL,NULL);
	if(!file->mod){
		free(file);
		return NULL;
	}
	file->buf = malloc(BUFFER_COUNT*sizeof(signed short)*4);
	if(!file->buf){
		openmpt_module_destroy(file->mod);
		free(file);
		return NULL;
	}
	openmpt_module_set_repeat_count(file->mod,file->settings.mLoopCount);
	file->name = openmpt_module_get_metadata(file->mod,"title");
	file->message = openmpt_module_get_metadata(file->mod,"message");
#ifndef LIBOPENMPT_MODPLUG_0_8_7
	openmpt_module_set_render_param(file->mod,OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT,file->settings.mStereoSeparation*100/128);
#endif
	openmpt_module_set_render_param(file->mod,OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH,modplugresamplingmode_to_filterlength(file->settings.mResamplingMode));
	return file;
}
Exemple #2
0
JNIEXPORT jlong JNICALL Java_com_ssb_droidsound_plugins_OpenMPTPlugin_N_1load(JNIEnv *env, jobject obj, jstring fname, jboolean loopmode)
{
	openmpt_module* mod = 0;
	FILE* file = NULL;
	
	const char *filename = env->GetStringUTFChars(fname, NULL);
	file = fopen(filename,"rb");
	mod = openmpt_module_create(openmpt_stream_get_file_callbacks(), file, NULL, NULL, NULL);
	if (loopmode)
		openmpt_module_set_repeat_count(mod, -1);
	fclose(file);
	return (long)mod;
}