Index: libopenmpt/libopenmpt_impl.cpp =================================================================== --- libopenmpt/libopenmpt_impl.cpp (revision 12440) +++ libopenmpt/libopenmpt_impl.cpp (working copy) @@ -1145,6 +1145,40 @@ "warnings", }; } +std::string module_impl::get_message_instruments() const { + std::string retval; + std::string tmp; + bool valid = false; + for ( INSTRUMENTINDEX i = 1; i <= m_sndFile->GetNumInstruments(); ++i ) { + std::string instname = m_sndFile->GetInstrumentName( i ); + if ( !instname.empty() ) { + valid = true; + } + tmp += instname; + tmp += "\n"; + } + if ( valid ) { + retval = tmp; + } + return retval; +} +std::string module_impl::get_message_samples() const { + std::string retval; + std::string tmp; + bool valid = false; + for ( SAMPLEINDEX i = 1; i <= m_sndFile->GetNumSamples(); ++i ) { + std::string samplename = m_sndFile->GetSampleName( i ); + if ( !samplename.empty() ) { + valid = true; + } + tmp += samplename; + tmp += "\n"; + } + if ( valid ) { + retval = tmp; + } + return retval; +} std::string module_impl::get_metadata( const std::string & key ) const { if ( key == std::string("type") ) { return mpt::ToCharset(mpt::Charset::UTF8, m_sndFile->m_modFormat.type ); @@ -1172,35 +1206,55 @@ } else if ( key == std::string("message") ) { std::string retval = m_sndFile->m_songMessage.GetFormatted( SongMessage::leLF ); if ( retval.empty() ) { - std::string tmp; - bool valid = false; - for ( INSTRUMENTINDEX i = 1; i <= m_sndFile->GetNumInstruments(); ++i ) { - std::string instname = m_sndFile->GetInstrumentName( i ); - if ( !instname.empty() ) { - valid = true; - } - tmp += instname; - tmp += "\n"; + switch ( m_sndFile->GetMessageHeuristic() ) { + case ModMessageHeuristicOrder::Instruments: + retval = get_message_instruments(); + break; + case ModMessageHeuristicOrder::Samples: + retval = get_message_samples(); + break; + case ModMessageHeuristicOrder::InstrumentsSamples: + if ( retval.empty() ) { + retval = get_message_instruments(); + } + if ( retval.empty() ) { + retval = get_message_samples(); + } + break; + case ModMessageHeuristicOrder::SamplesInstruments: + if ( retval.empty() ) { + retval = get_message_samples(); + } + if ( retval.empty() ) { + retval = get_message_instruments(); + } + break; + case ModMessageHeuristicOrder::BothInstrumentsSamples: + { + std::string message_instruments = get_message_instruments(); + std::string message_samples = get_message_samples(); + if ( !message_instruments.empty() ) { + retval += std::move( message_instruments ); + } + if ( !message_samples.empty() ) { + retval += std::move( message_samples ); + } + } + break; + case ModMessageHeuristicOrder::BothSamplesInstruments: + { + std::string message_instruments = get_message_instruments(); + std::string message_samples = get_message_samples(); + if ( !message_samples.empty() ) { + retval += std::move( message_samples ); + } + if ( !message_instruments.empty() ) { + retval += std::move( message_instruments ); + } + } + break; } - if ( valid ) { - retval = tmp; - } } - if ( retval.empty() ) { - std::string tmp; - bool valid = false; - for ( SAMPLEINDEX i = 1; i <= m_sndFile->GetNumSamples(); ++i ) { - std::string samplename = m_sndFile->GetSampleName( i ); - if ( !samplename.empty() ) { - valid = true; - } - tmp += samplename; - tmp += "\n"; - } - if ( valid ) { - retval = tmp; - } - } return mod_string_to_utf8( retval ); } else if ( key == std::string("message_raw") ) { std::string retval = m_sndFile->m_songMessage.GetFormatted( SongMessage::leLF ); Index: libopenmpt/libopenmpt_impl.hpp =================================================================== --- libopenmpt/libopenmpt_impl.hpp (revision 12440) +++ libopenmpt/libopenmpt_impl.hpp (working copy) @@ -146,6 +146,8 @@ std::size_t read_wrapper( std::size_t count, float * left, float * right, float * rear_left, float * rear_right ); std::size_t read_interleaved_wrapper( std::size_t count, std::size_t channels, std::int16_t * interleaved ); std::size_t read_interleaved_wrapper( std::size_t count, std::size_t channels, float * interleaved ); + std::string get_message_instruments() const; + std::string get_message_samples() const; std::pair< std::string, std::string > format_and_highlight_pattern_row_channel_command( std::int32_t p, std::int32_t r, std::int32_t c, int command ) const; std::pair< std::string, std::string > format_and_highlight_pattern_row_channel( std::int32_t p, std::int32_t r, std::int32_t c, std::size_t width, bool pad ) const; static double could_open_probability( const OpenMPT::FileReader & file, double effort, std::unique_ptr log ); Index: soundlib/Sndfile.cpp =================================================================== --- soundlib/Sndfile.cpp (revision 12440) +++ soundlib/Sndfile.cpp (working copy) @@ -1581,6 +1581,34 @@ #endif // MODPLUG_TRACKER +ModMessageHeuristicOrder CSoundFile::GetMessageHeuristic() const +{ + ModMessageHeuristicOrder result = ModMessageHeuristicOrder::Default; + switch(GetType()) + { + case MOD_TYPE_MPT: + result = ModMessageHeuristicOrder::Samples; + break; + case MOD_TYPE_IT: + result = ModMessageHeuristicOrder::Samples; + break; + case MOD_TYPE_XM: + result = ModMessageHeuristicOrder::InstrumentsSamples; + break; + case MOD_TYPE_MDL: + result = ModMessageHeuristicOrder::InstrumentsSamples; + break; + case MOD_TYPE_IMF: + result = ModMessageHeuristicOrder::InstrumentsSamples; + break; + default: + result = ModMessageHeuristicOrder::Default; + break; + } + return result; +} + + bool CSoundFile::SetTitle(const std::string &newTitle) { if(m_songName != newTitle) Index: soundlib/Sndfile.h =================================================================== --- soundlib/Sndfile.h (revision 12440) +++ soundlib/Sndfile.h (working copy) @@ -247,6 +247,17 @@ }; +enum class ModMessageHeuristicOrder +{ + Instruments, + Samples, + InstrumentsSamples, + SamplesInstruments, + BothInstrumentsSamples, + BothSamplesInstruments, + Default = InstrumentsSamples, +}; + struct ModFormatDetails { mpt::ustring formatName; // "FastTracker 2" @@ -674,6 +685,8 @@ #endif // MODPLUG_TRACKER } + ModMessageHeuristicOrder GetMessageHeuristic() const; + void SetPreAmp(uint32 vol); uint32 GetPreAmp() const { return m_MixerSettings.m_nPreAmp; }