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")); }
JNIEXPORT jint JNICALL Java_com_ssb_droidsound_plugins_OpenMPTPlugin_N_1getIntInfo(JNIEnv *env, jobject obj, jlong song, jint what) { openmpt_module* mod = (openmpt_module*)song; switch(what) { case INFO_LENGTH: return openmpt_module_get_duration_seconds(mod) * 1000; case INFO_SUBTUNES: return openmpt_module_get_num_subsongs(mod); case INFO_STARTTUNE: return 0; case INFO_CHANNELS: return openmpt_module_get_num_channels(mod); case INFO_PATTERNS: return openmpt_module_get_num_patterns(mod); } return -1; }