Exemple #1
0
MPTWrap::MPTWrap(QIODevice *device)
{
  mod = openmpt_module_create(callbacks, device, openmpt_log_func_silent, nullptr, nullptr);
  if(mod == nullptr) throw InvalidFile();

  openmpt_module_select_subsong(mod, -1);

  duration_ = openmpt_module_get_duration_seconds(mod) * 1000;
  title_ = copystr(openmpt_module_get_metadata(mod, "title"));
  format_ = copystr(openmpt_module_get_metadata(mod, "type_long"));
  pattern_count_ = openmpt_module_get_num_patterns(mod);
  instrument_count_ = openmpt_module_get_num_instruments(mod);
  sample_count_ = openmpt_module_get_num_samples(mod);
  channel_count_ = openmpt_module_get_num_channels(mod);

  for(int i = 0; i < openmpt_module_get_num_instruments(mod); i++)
  {
    instruments_.push_back(copystr(openmpt_module_get_instrument_name(mod, i)));
  }

  for(int i = 0; i < openmpt_module_get_num_samples(mod); i++)
  {
    samples_.push_back(copystr(openmpt_module_get_sample_name(mod, i)));
  }

  comment_ = copystr(openmpt_module_get_metadata(mod, "message_raw"));
}
Exemple #2
0
JNIEXPORT jstring JNICALL Java_com_ssb_droidsound_plugins_OpenMPTPlugin_N_1getStringInfo(JNIEnv *env, jobject obj, jlong song, jint what)
{
	openmpt_module* mod = (openmpt_module*)song;
	switch(what)
	{
		case INFO_INSTRUMENTS:
			{
						
			char instruments[2048];
			char *ptr = instruments;
			char *instEnd = instruments + sizeof(instruments) - 48;
			int pat = openmpt_module_get_num_patterns(mod);
			int ns = openmpt_module_get_num_samples(mod);
			memset(ptr, 0, 2048);
			if ((ns * 48) > 2048)
				return  NewString(env, instruments); 
			
			if(ns > 0)
			{
				for(int i=1; i<ns; i++)
				{
					const char* instr_name = openmpt_module_get_sample_name(mod, i);
					memcpy((void*)ptr, instr_name, strlen(instr_name));
					ptr += strlen(instr_name);
					if(ptr >= instEnd)
						break;
					*ptr++ = 0x0a;
					*ptr = 0;
				}
			}
			return  NewString(env, instruments); 
			}
		
		return NewString(env, ""); 
	
	}

}