From: <man...@us...> - 2014-02-01 16:52:36
|
Revision: 3617 http://sourceforge.net/p/modplug/code/3617 Author: manxorist Date: 2014-02-01 16:52:29 +0000 (Sat, 01 Feb 2014) Log Message: ----------- [New] libopenmpt: Allow disabling/selecting dither with ctl_set("dither"). [New] openmpt123: Allow disabling/selecting dither with --dither n . Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/openmpt123/openmpt123.hpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-02-01 16:37:27 UTC (rev 3616) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-02-01 16:52:29 UTC (rev 3617) @@ -23,6 +23,7 @@ #include <cstring> #include "common/version.h" +#include "common/misc_util.h" #include "soundlib/Sndfile.h" #include "soundlib/AudioReadTarget.h" #include "soundlib/FileReader.h" @@ -1031,17 +1032,22 @@ std::vector<std::string> module_impl::get_ctls() const { std::vector<std::string> retval; + retval.push_back( "dither" ); return retval; } std::string module_impl::ctl_get( const std::string & ctl ) const { if ( ctl == "" ) { throw openmpt::exception("unknown ctl"); + } else if ( ctl == "dither" ) { + return mpt::ToString( static_cast<int>( m_Dither->GetMode() ) ); } throw openmpt::exception("unknown ctl"); } void module_impl::ctl_set( const std::string & ctl, const std::string & value ) { if ( ctl == "" ) { throw openmpt::exception("unknown ctl: " + ctl + " := " + value); + } else if ( ctl == "dither" ) { + m_Dither->SetMode( static_cast<DitherMode>( ConvertStrTo<int>( value ) ) ); } throw openmpt::exception("unknown ctl: " + ctl + " := " + value); } Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2014-02-01 16:37:27 UTC (rev 3616) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2014-02-01 16:52:29 UTC (rev 3617) @@ -229,6 +229,7 @@ s << "Stereo separation: " << flags.separation << std::endl; s << "Interpolation filter taps: " << flags.filtertaps << std::endl; s << "Volume ramping strength: " << flags.ramping << std::endl; + s << "Output dithering: " << flags.dither << std::endl; s << "Repeat count: " << flags.repeatcount << std::endl; s << "Seek target: " << flags.seek_target << std::endl; s << "Standard output: " << flags.use_stdout << std::endl; @@ -456,6 +457,7 @@ log << " --stereo n Set stereo separation to n % [default: " << commandlineflags().separation << "]" << std::endl; log << " --filter n Set interpolation filter taps to n [1,2,4,8] [default: " << commandlineflags().filtertaps << "]" << std::endl; log << " --ramping n Set volume ramping strength n [0..5] [default: " << commandlineflags().ramping << "]" << std::endl; + log << " --dither n Dither type for 16bit integer output: [0=off,1=auto,2=0.5bit,3=1bit] [default: " << commandlineflags().dither << "]" << std::endl; log << std::endl; log << " --[no-]shuffle Shuffle playlist (-1 means forever) [default: " << commandlineflags().shuffle << "]" << std::endl; log << std::endl; @@ -531,6 +533,10 @@ mod.set_render_param( openmpt::module::RENDER_STEREOSEPARATION_PERCENT, flags.separation ); mod.set_render_param( openmpt::module::RENDER_INTERPOLATIONFILTER_LENGTH, flags.filtertaps ); mod.set_render_param( openmpt::module::RENDER_VOLUMERAMPING_STRENGTH, flags.ramping ); + std::ostringstream dither_str; + dither_str.imbue( std::locale::classic() ); + dither_str << flags.dither; + mod.ctl_set( "dither", dither_str.str() ); } struct prev_file { int count; prev_file( int c ) : count(c) { } }; @@ -1575,6 +1581,10 @@ std::istringstream istr( nextarg ); istr >> flags.ramping; ++i; + } else if ( arg == "--dither" && nextarg != "" ) { + std::istringstream istr( nextarg ); + istr >> flags.dither; + ++i; } else if ( arg == "--shuffle" ) { flags.shuffle = true; } else if ( arg == "--no-shuffle" ) { Modified: trunk/OpenMPT/openmpt123/openmpt123.hpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.hpp 2014-02-01 16:37:27 UTC (rev 3616) +++ trunk/OpenMPT/openmpt123/openmpt123.hpp 2014-02-01 16:52:29 UTC (rev 3617) @@ -251,6 +251,7 @@ std::int32_t separation; std::int32_t filtertaps; std::int32_t ramping; // ramping strength : -1:default 0:off 1 2 3 4 5 // roughly milliseconds + std::int32_t dither; std::int32_t repeatcount; double seek_target; bool quiet; @@ -304,6 +305,7 @@ separation = 100; filtertaps = 8; ramping = -1; + dither = 1; repeatcount = 0; seek_target = 0.0; quiet = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |