From: <man...@us...> - 2013-07-28 17:09:43
|
Revision: 2549 http://sourceforge.net/p/modplug/code/2549 Author: manxorist Date: 2013-07-28 17:09:33 +0000 (Sun, 28 Jul 2013) Log Message: ----------- [Ref] Calculate stereo vu meters also in libopenmpt and remove #define ENABLE_STEREOVU. [Ref] Remove unused ModChannel::nVUMeter. [New] libopenmpt: Add stereo vu meters per channel. [New] libopenmpt: Add functions to format each pattern cell as a string of given length. [Ref] xmp-openmpt: Improve pattern display (still disabled because it is still too slow). [New] openmpt123: Add channel peak meters. [Imp] openmpt123: Make terminal width user-overridable. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.h trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/openmpt123/openmpt123.hpp trunk/OpenMPT/soundlib/ModChannel.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-07-28 17:09:33 UTC (rev 2549) @@ -114,6 +114,9 @@ LIBOPENMPT_API int32_t openmpt_module_get_current_row( openmpt_module * mod ); LIBOPENMPT_API int32_t openmpt_module_get_current_playing_channels( openmpt_module * mod ); +LIBOPENMPT_API float openmpt_module_get_current_channel_vu_left( openmpt_module * mod, int32_t channel ); +LIBOPENMPT_API float openmpt_module_get_current_channel_vu_right( openmpt_module * mod, int32_t channel ); + LIBOPENMPT_API int32_t openmpt_module_get_num_subsongs( openmpt_module * mod ); LIBOPENMPT_API int32_t openmpt_module_get_num_channels( openmpt_module * mod ); LIBOPENMPT_API int32_t openmpt_module_get_num_orders( openmpt_module * mod ); @@ -133,6 +136,9 @@ LIBOPENMPT_API uint8_t openmpt_module_get_pattern_row_channel_command( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, int command ); +LIBOPENMPT_API const char * openmpt_module_format_pattern_row_channel( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, size_t width, int pad ); +LIBOPENMPT_API const char * openmpt_module_highlight_pattern_row_channel( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, size_t width, int pad ); + LIBOPENMPT_API const char * openmpt_module_get_ctls( openmpt_module * mod ); LIBOPENMPT_API const char * openmpt_module_ctl_get( openmpt_module * mod, const char * ctl ); LIBOPENMPT_API int openmpt_module_ctl_set( openmpt_module * mod, const char * ctl, const char * value ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -155,6 +155,9 @@ std::int32_t get_current_row() const; std::int32_t get_current_playing_channels() const; + float get_current_channel_vu_left( std::int32_t channel ) const; + float get_current_channel_vu_right( std::int32_t channel ) const; + std::int32_t get_num_subsongs() const; std::int32_t get_num_channels() const; std::int32_t get_num_orders() const; @@ -175,6 +178,9 @@ std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; + std::string format_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const; + std::string highlight_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const; + std::vector<std::string> get_ctls() const; std::string ctl_get( const std::string & ctl ) const; Modified: trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -560,6 +560,21 @@ return 0; } +LIBOPENMPT_API float openmpt_module_get_current_channel_vu_left( openmpt_module * mod, int32_t channel ) { + try { + OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); + return mod->impl->get_current_channel_vu_left( channel ); + } OPENMPT_INTERFACE_CATCH_TO_LOG; + return 0.0; +} +LIBOPENMPT_API float openmpt_module_get_current_channel_vu_right( openmpt_module * mod, int32_t channel ) { + try { + OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); + return mod->impl->get_current_channel_vu_right( channel ); + } OPENMPT_INTERFACE_CATCH_TO_LOG; + return 0.0; +} + LIBOPENMPT_API int32_t openmpt_module_get_num_subsongs( openmpt_module * mod ) { try { OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); @@ -712,6 +727,22 @@ return 0; } +LIBOPENMPT_API const char * openmpt_module_format_pattern_row_channel( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, size_t width, int pad ) { + try { + OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); + return openmpt::strdup( mod->impl->format_pattern_row_channel( pattern, row, channel, width, pad ? true : false ).c_str() ); + } OPENMPT_INTERFACE_CATCH_TO_LOG; + return 0; +} + +LIBOPENMPT_API const char * openmpt_module_highlight_pattern_row_channel( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, size_t width, int pad ) { + try { + OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); + return openmpt::strdup( mod->impl->highlight_pattern_row_channel( pattern, row, channel, width, pad ? true : false ).c_str() ); + } OPENMPT_INTERFACE_CATCH_TO_LOG; + return 0; +} + const char * openmpt_module_get_ctls( openmpt_module * mod ) { try { OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -211,6 +211,13 @@ return impl->get_current_playing_channels(); } +float module::get_current_channel_vu_left( std::int32_t channel ) const { + return impl->get_current_channel_vu_left( channel ); +} +float module::get_current_channel_vu_right( std::int32_t channel ) const { + return impl->get_current_channel_vu_right( channel ); +} + std::int32_t module::get_num_subsongs() const { return impl->get_num_subsongs(); } @@ -260,6 +267,13 @@ return impl->get_pattern_row_channel_command( pattern, row, channel, command ); } +std::string module::format_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width, bool pad ) const { + return impl->format_pattern_row_channel( pattern, row, channel, width, pad ); +} +std::string module::highlight_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width, bool pad ) const { + return impl->highlight_pattern_row_channel( pattern, row, channel, width, pad ); +} + std::vector<std::string> module::get_ctls() const { return impl->get_ctls(); } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -590,6 +590,7 @@ } return ""; } + std::int32_t module_impl::get_current_speed() const { return m_sndFile->m_nMusicSpeed; } @@ -608,6 +609,19 @@ std::int32_t module_impl::get_current_playing_channels() const { return m_sndFile->m_nMixChannels; } +float module_impl::get_current_channel_vu_left( std::int32_t channel ) const { + if ( channel < 0 || channel >= m_sndFile->GetNumChannels() ) { + return 0.0f; + } + return m_sndFile->Chn[channel].nLeftVU * (1.0f/128.0f); +} +float module_impl::get_current_channel_vu_right( std::int32_t channel ) const { + if ( channel < 0 || channel >= m_sndFile->GetNumChannels() ) { + return 0.0f; + } + return m_sndFile->Chn[channel].nRightVU * (1.0f/128.0f); +} + std::int32_t module_impl::get_num_subsongs() const { return m_sndFile->Order.GetNumSequences(); } @@ -719,6 +733,65 @@ return 0; } +std::pair< std::string, std::string > module_impl::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 { + std::string text = pad ? std::string( width, ' ' ) : std::string(); + std::string high = pad ? std::string( width, ' ' ) : std::string(); + const CHANNELINDEX numchannels = m_sndFile->GetNumChannels(); + if ( p < 0 || p >= m_sndFile->Patterns.Size() ) { + return std::make_pair( text, high ); + } + if ( r < 0 || r >= (std::int32_t)m_sndFile->Patterns[p].GetNumRows() ) { + return std::make_pair( text, high ); + } + if ( c < 0 || c >= numchannels ) { + return std::make_pair( text, high ); + } + if ( width == 0 ) { + return std::make_pair( text, high ); + } + // 0000000001111 + // 1234567890123 + // "NNN IIvVV EFF" + const ModCommand cell = m_sndFile->Patterns[p][r*numchannels+c]; + text.clear(); + high.clear(); + text += cell.IsNote() ? m_sndFile->GetNoteName( cell.note, cell.instr ) : std::string("..."); + high += cell.IsNote() ? std::string("nnn") : std::string("..."); + if ( width >= 6 ) { + text += std::string(" "); + high += std::string(" "); + text += cell.instr ? mpt::String::Format( "%02X", cell.instr ) : std::string(".."); + high += cell.instr ? std::string("ii") : std::string(".."); + } + if ( width >= 9 ) { + text += cell.IsPcNote() ? mpt::String::Format( " %02X", cell.GetValueVolCol() & 0xff ) : cell.volcmd != VOLCMD_NONE ? mpt::String::Format( "%1c%02X", m_sndFile->GetModSpecifications().GetVolEffectLetter( cell.volcmd ), cell.vol ) : std::string(" .."); + high += cell.IsPcNote() ? std::string(" vv") : cell.volcmd != VOLCMD_NONE ? std::string("wvv") : std::string(" .."); + } + if ( width >= 13 ) { + text += std::string(" "); + high += std::string(" "); + text += cell.IsPcNote() ? mpt::String::Format( "%03X", cell.GetValueEffectCol() & 0x0fff ) : cell.command != CMD_NONE ? mpt::String::Format( "%1c%02X", m_sndFile->GetModSpecifications().GetEffectLetter( cell.command ), cell.param ) : std::string("..."); + high += cell.IsPcNote() ? std::string("eff") : cell.command != CMD_NONE ? std::string("eff") : std::string("..."); + } + if ( text.length() > width ) { + text = text.substr( 0, width ); + } else if ( pad ) { + text += std::string( width - text.length(), ' ' ); + } + if ( high.length() > width ) { + high = high.substr( 0, width ); + } else if ( pad ) { + high += std::string( width - high.length(), ' ' ); + } + return std::make_pair( text, high ); +} +std::string module_impl::format_pattern_row_channel( std::int32_t p, std::int32_t r, std::int32_t c, std::size_t width, bool pad ) const { + return format_and_highlight_pattern_row_channel( p, r, c, width, pad ).first; +} +std::string module_impl::highlight_pattern_row_channel( std::int32_t p, std::int32_t r, std::int32_t c, std::size_t width, bool pad ) const { + return format_and_highlight_pattern_row_channel( p, r, c, width, pad ).second; +} + std::vector<std::string> module_impl::get_ctls() const { std::vector<std::string> retval; return retval; Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -70,6 +70,7 @@ 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::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; public: static std::vector<std::string> get_supported_extensions(); static bool is_extension_supported( const std::string & extension ); @@ -108,6 +109,8 @@ std::int32_t get_current_pattern() const; std::int32_t get_current_row() const; std::int32_t get_current_playing_channels() const; + float get_current_channel_vu_left( std::int32_t channel ) const; + float get_current_channel_vu_right( std::int32_t channel ) const; std::int32_t get_num_subsongs() const; std::int32_t get_num_channels() const; std::int32_t get_num_orders() const; @@ -123,6 +126,8 @@ std::int32_t get_order_pattern( std::int32_t o ) const; std::int32_t get_pattern_num_rows( std::int32_t p ) const; std::uint8_t get_pattern_row_channel_command( std::int32_t p, std::int32_t r, std::int32_t c, int cmd ) const; + std::string format_pattern_row_channel( std::int32_t p, std::int32_t r, std::int32_t c, std::size_t width, bool pad ) const; + std::string highlight_pattern_row_channel( std::int32_t p, std::int32_t r, std::int32_t c, std::size_t width, bool pad ) const; std::vector<std::string> get_ctls() const; std::string ctl_get( const std::string & ctl ) const; void ctl_set( const std::string & ctl, const std::string & value ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -193,8 +193,8 @@ timeinfo_position += (double)count / (double)samplerate; timeinfo info; info.seconds = timeinfo_position; - info.pattern = mod->get_current_pattern(); - info.row = mod->get_current_row(); + info.pattern = self->mod->get_current_pattern(); + info.row = self->mod->get_current_row(); timeinfos.push( info ); } @@ -204,13 +204,11 @@ timeinfo info = current_timeinfo; #if 0 info.seconds = timeinfo_position; - info.pattern = mod->get_current_pattern(); - info.row = mod->get_current_row(); + info.pattern = self->mod->get_current_pattern(); + info.row = self->mod->get_current_row(); #endif while ( timeinfos.size() > 0 && timeinfos.front().seconds < seconds ) { - info.seconds = timeinfos.front().seconds; - info.pattern = timeinfos.front().pattern; - info.row = timeinfos.front().row; + info = timeinfos.front(); timeinfos.pop(); } current_timeinfo = info; @@ -743,7 +741,7 @@ #ifdef EXPERIMENTAL_VIS -std::vector< std::vector< std::vector < std::uint8_t > > > patterns; +std::vector< std::vector< std::string > > patterns_rows; DWORD viscolors[3]; HPEN vispens[3]; HBRUSH visbrushs[3]; @@ -765,16 +763,18 @@ visbrushs[0] = CreateSolidBrush( viscolors[0] ); visbrushs[1] = CreateSolidBrush( viscolors[1] ); visbrushs[2] = CreateSolidBrush( viscolors[2] ); - if ( !mod ) { + if ( !self->mod ) { return FALSE; } - patterns.resize( mod->get_num_patterns() ); - for ( std::size_t pattern = 0; pattern < mod->get_num_patterns(); pattern++ ) { - patterns[pattern].resize( mod->get_pattern_num_rows( pattern ) ); - for ( std::size_t row = 0; row < mod->get_pattern_num_rows( pattern ); row++ ) { - patterns[pattern][row].resize( mod->get_num_channels() ); - for ( std::size_t channel = 0; channel < mod->get_num_channels(); channel++ ) { - patterns[pattern][row][channel] = mod->get_pattern_row_channel_command( pattern, row, channel, openmpt::module::command_note ); + patterns_rows.resize( self->mod->get_num_patterns() ); + for ( std::size_t pattern = 0; pattern < (std::size_t)self->mod->get_num_patterns(); pattern++ ) { + patterns_rows[pattern].resize( self->mod->get_pattern_num_rows( pattern ) ); + for ( std::size_t row = 0; row < (std::size_t)self->mod->get_pattern_num_rows( pattern ); row++ ) { + for ( std::size_t channel = 0; channel < (std::size_t)self->mod->get_num_channels(); channel++ ) { + if ( channel > 0 ) { + patterns_rows[pattern][row] += "|"; + } + patterns_rows[pattern][row] += self->mod->format_pattern_row_channel( pattern, row, channel, 3 ); } } } @@ -806,29 +806,20 @@ int top = 0; - int channels = mod->get_num_channels(); + int channels = self->mod->get_num_channels(); #if 0 - int pattern = mod->get_current_pattern(); - int current_row = mod->get_current_row(); + int pattern = self->mod->get_current_pattern(); + int current_row = self->mod->get_current_row(); #else - timeinfo info = lookup_timeinfo( timeinfo_position - ( (double)xmpfstatus->GetLatency() / (double)samplerate ) ); + timeinfo info = lookup_timeinfo( timeinfo_position - ( (double)xmpfstatus->GetLatency() / (double)self->num_channels / (double)self->samplerate ) ); int pattern = info.pattern; int current_row = info.row; #endif - int rows = mod->get_pattern_num_rows( pattern ); + std::size_t rows = self->mod->get_pattern_num_rows( pattern ); - static char buf[1<<16]; - char * dst; - dst = buf; for ( std::size_t row = 0; row < rows; row++ ) { - dst = buf; - for ( std::size_t channel = 0; channel < channels; channel++ ) { - *dst++ = nibble_to_char( ( patterns[pattern][row][channel] >> 4 ) &0xf ); - *dst++ = nibble_to_char( ( patterns[pattern][row][channel] >> 0 ) &0xf ); - } - *dst++ = '\0'; if ( row == current_row ) { //SelectObject( dc, vispens[2] ); SetTextColor( dc, viscolors[2] ); @@ -838,7 +829,7 @@ rect.left = 0; rect.right = size.cx; rect.bottom = size.cy; - DrawText( dc, buf, strlen( buf ), &rect, DT_LEFT ); + DrawText( dc, patterns_rows[pattern][row].c_str(), patterns_rows[pattern][row].length(), &rect, DT_LEFT ); top += tm.tmHeight; if ( row == current_row ) { //SelectObject( dc, vispens[1] ); Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -21,6 +21,7 @@ #include <cmath> #include <cstdint> +#include <cstdlib> #include <cstring> #include <ctime> @@ -150,6 +151,7 @@ s << "Mode : " << mode_to_string( flags.mode ) << std::endl; s << "Show progress: " << flags.show_progress << std::endl; s << "Show peak meters: " << flags.show_meters << std::endl; + s << "Show channel peak meters: " << flags.show_channel_meters << std::endl; s << "Show details: " << flags.show_details << std::endl; s << "Show message: " << flags.show_message << std::endl; #ifdef MPT_WITH_PORTAUDIO @@ -328,8 +330,11 @@ return; } std::clog << std::endl; + std::clog << " --terminal-width n Assume terminal is n characters wide [default: " << commandlineflags().terminal_width << "]" << std::endl; + std::clog << std::endl; std::clog << " --[no-]progress Show playback progress [default: " << commandlineflags().show_progress << "]" << std::endl; std::clog << " --[no-]meters Show peak meters [default: " << commandlineflags().show_meters << "]" << std::endl; + std::clog << " --[no-]channel-meters Show channel peak meters [default: " << commandlineflags().show_channel_meters << "]" << std::endl; std::clog << std::endl; std::clog << " --[no-]details Show song details [default: " << commandlineflags().show_details << "]" << std::endl; std::clog << " --[no-]message Show song message [default: " << commandlineflags().show_message << "]" << std::endl; @@ -570,6 +575,57 @@ } } +static char peak_to_char( float peak ) { + if ( peak >= 1.0f ) { + return '#'; + } else if ( peak >= 0.5f ) { + return 'O'; + } else if ( peak >= 0.25f ) { + return 'o'; + } else if ( peak >= 0.125f ) { + return '.'; + } else { + return ' '; + } +} + +static std::string peak_to_string_left( float peak, int width ) { + std::string result; + float thresh = 1.0f; + while ( width-- ) { + if ( peak >= thresh ) { + if ( thresh == 1.0f ) { + result.push_back( '#' ); + } else { + result.push_back( '<' ); + } + } else { + result.push_back( ' ' ); + } + thresh *= 0.5f; + } + return result; +} + +static std::string peak_to_string_right( float peak, int width ) { + std::string result; + float thresh = 1.0f; + while ( width-- ) { + if ( peak >= thresh ) { + if ( thresh == 1.0f ) { + result.push_back( '#' ); + } else { + result.push_back( '>' ); + } + } else { + result.push_back( ' ' ); + } + thresh *= 0.5f; + } + std::reverse( result.begin(), result.end() ); + return result; +} + static void draw_meters( std::ostream & log, const meter_type & meter, const commandlineflags & flags ) { for ( int channel = 0; channel < flags.channels; ++channel ) { log << channel_to_string( flags.channels, channel, meter.channels[channel] ) << std::endl; @@ -582,6 +638,21 @@ } } +static void draw_channel_meters_tiny( std::ostream & log, float peak ) { + log << peak_to_char( peak ); +} + +static void draw_channel_meters_tiny( std::ostream & log, float peak_left, float peak_right ) { + log << peak_to_char( peak_left ) << peak_to_char( peak_right ); +} + +static void draw_channel_meters( std::ostream & log, float peak_left, float peak_right, int width ) { + if ( width >= 8 + 1 + 8 ) { + width = 8 + 1 + 8; + } + log << peak_to_string_left( peak_left, width / 2 ) << ( width % 1 == 1 ? "|" : "" ) << peak_to_string_right( peak_right, width / 2 ); +} + template < typename Tsample, typename Tmod > void render_loop( commandlineflags & flags, Tmod & mod, double & duration, std::ostream & log, write_buffers_interface & audio_stream ) { @@ -776,6 +847,27 @@ if ( flags.show_progress ) { log << "Position...: " << seconds_to_string( mod.get_position_seconds() ) << " / " << seconds_to_string( duration ) << " " << std::endl; } + } else if ( flags.show_channel_meters ) { + if ( flags.show_ui || flags.show_details || flags.show_progress ) { + int width = flags.terminal_width / mod.get_num_channels(); + log << " "; + for ( std::int32_t channel = 0; channel < mod.get_num_channels(); ++channel ) { + if ( width >= 3 ) { + log << "|"; + } + if ( width == 1 ) { + draw_channel_meters_tiny( log, ( mod.get_current_channel_vu_left( channel ) + mod.get_current_channel_vu_right( channel ) ) * (1.0f/std::sqrt(2.0f)) ); + } else if ( width == 2 || width == 3 ) { + draw_channel_meters_tiny( log, mod.get_current_channel_vu_left( channel ), mod.get_current_channel_vu_right( channel ) ); + } else { + draw_channel_meters( log, mod.get_current_channel_vu_left( channel ), mod.get_current_channel_vu_right( channel ), width - 1 ); + } + } + if ( width >= 3 ) { + log << "|"; + } + } + log << " " << "\r"; } else { if ( flags.show_ui ) { log << " "; @@ -1062,6 +1154,10 @@ flags.mode = ModeBatch; } else if ( arg == "--render" ) { flags.mode = ModeRender; + } else if ( arg == "--terminal-width" && nextarg != "" ) { + std::istringstream istr( nextarg ); + istr >> flags.terminal_width; + ++i; } else if ( arg == "--progress" ) { flags.show_progress = true; } else if ( arg == "--no-progress" ) { @@ -1070,6 +1166,10 @@ flags.show_meters = true; } else if ( arg == "--no-meters" ) { flags.show_meters = false; + } else if ( arg == "--channel-meters" ) { + flags.show_channel_meters = true; + } else if ( arg == "--no-channel-meters" ) { + flags.show_channel_meters = false; } else if ( arg == "--details" ) { flags.show_details = true; } else if ( arg == "--no-details" ) { Modified: trunk/OpenMPT/openmpt123/openmpt123.hpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.hpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/openmpt123/openmpt123.hpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -97,11 +97,13 @@ double seek_target; bool quiet; bool verbose; + int terminal_width; bool show_details; bool show_message; bool show_ui; bool show_progress; bool show_meters; + bool show_channel_meters; bool use_float; bool use_stdout; std::vector<std::string> filenames; @@ -128,6 +130,19 @@ seek_target = 0.0; quiet = false; verbose = false; + terminal_width = 72; +#if !defined(_MSC_VER) + if ( isatty( STDERR_FILENO ) ) { + if ( std::getenv( "COLUMNS" ) ) { + std::istringstream istr( std::getenv( "COLUMNS" ) ); + int tmp = 0; + istr >> tmp; + if ( tmp > 0 ) { + terminal_width = tmp; + } + } + } +#endif show_details = true; show_message = false; #if defined(_MSC_VER) @@ -140,6 +155,7 @@ show_ui = canUI; show_progress = canProgress; show_meters = canUI && canProgress; + show_channel_meters = false; use_stdout = false; #if defined(MPT_WITH_FLAC) || defined(MPT_WITH_MMIO) || defined(MPT_WITH_SNDFILE) output_extension = "wav"; @@ -184,14 +200,18 @@ case ModeInfo: show_ui = false; show_progress = false; + show_meters = false; + show_channel_meters = false; break; case ModeUI: break; case ModeBatch: show_meters = false; + show_channel_meters = false; break; case ModeRender: show_meters = false; + show_channel_meters = false; show_ui = false; break; } @@ -200,6 +220,7 @@ show_ui = false; show_details = false; show_progress = false; + show_channel_meters = false; } if ( verbose ) { show_details = true; Modified: trunk/OpenMPT/soundlib/ModChannel.h =================================================================== --- trunk/OpenMPT/soundlib/ModChannel.h 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/soundlib/ModChannel.h 2013-07-28 17:09:33 UTC (rev 2549) @@ -67,7 +67,6 @@ int32 nPeriod, nC5Speed, nPortamentoDest; int32 nCalcVolume; // Calculated channel volume, 14-Bit (without global volume, pre-amp etc applied) - for MIDI macros EnvInfo VolEnv, PanEnv, PitchEnv; // Envelope playback info - uint32 nVUMeter; int32 nGlobalVol; // Channel volume (CV in ITTECH.TXT) int32 nInsVol; // Sample / Instrument volume (SV * IV in ITTECH.TXT) int32 nFineTune, nTranspose; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -1176,7 +1176,6 @@ // Enable Ramping if(!bPorta) { - pChn->nVUMeter = 0x100; pChn->nLeftVU = pChn->nRightVU = 0xFF; pChn->dwFlags.reset(CHN_FILTER); pChn->dwFlags.set(CHN_FASTVOLRAMP); Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -19,10 +19,6 @@ #include "../mptrack/TrackerSettings.h" #endif -#ifdef MODPLUG_TRACKER -#define ENABLE_STEREOVU -#endif - // VU-Meter #define VUMETER_DECAY 4 @@ -1757,12 +1753,7 @@ // Process MIDI macros on channels that are currently muted. ProcessMacroOnChannel(nChn); } - - pChn->nVUMeter = 0; -#ifdef ENABLE_STEREOVU pChn->nLeftVU = pChn->nRightVU = 0; -#endif - continue; } // Reset channel data @@ -1982,10 +1973,8 @@ // Volume ramping pChn->dwFlags.set(CHN_VOLUMERAMP, (pChn->nRealVolume | pChn->rightVol | pChn->leftVol) != 0); -#ifdef ENABLE_STEREOVU if (pChn->nLeftVU > VUMETER_DECAY) pChn->nLeftVU -= VUMETER_DECAY; else pChn->nLeftVU = 0; if (pChn->nRightVU > VUMETER_DECAY) pChn->nRightVU -= VUMETER_DECAY; else pChn->nRightVU = 0; -#endif // Check for too big nInc if (((pChn->nInc >> 16) + 1) >= (LONG)(pChn->nLoopEnd - pChn->nLoopStart)) pChn->dwFlags.reset(CHN_LOOP); @@ -1994,7 +1983,6 @@ if (pChn->pCurrentSample) { // Update VU-Meter (nRealVolume is 14-bit) -#ifdef ENABLE_STEREOVU UINT vul = (pChn->nRealVolume * pChn->nRealPan) >> 14; if (vul > 127) vul = 127; if (pChn->nLeftVU > 127) pChn->nLeftVU = (BYTE)vul; @@ -2005,7 +1993,6 @@ if (pChn->nRightVU > 127) pChn->nRightVU = (BYTE)vur; vur >>= 1; if (pChn->nRightVU < vur) pChn->nRightVU = (BYTE)vur; -#endif #ifdef MODPLUG_TRACKER const UINT kChnMasterVol = pChn->dwFlags[CHN_EXTRALOUD] ? (UINT)m_PlayConfig.getNormalSamplePreAmp() : nMasterVol; @@ -2095,12 +2082,10 @@ ChnMix[m_nMixChannels++] = nChn; } else { -#ifdef ENABLE_STEREOVU // Note change but no sample if (pChn->nLeftVU > 128) pChn->nLeftVU = 0; if (pChn->nRightVU > 128) pChn->nRightVU = 0; -#endif // ENABLE_STEREOVU - if (pChn->nVUMeter > 0xFF) pChn->nVUMeter = 0; + pChn->rightVol = pChn->leftVol = 0; pChn->nLength = 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |