From: <man...@us...> - 2015-03-27 15:18:27
|
Revision: 4906 http://sourceforge.net/p/modplug/code/4906 Author: manxorist Date: 2015-03-27 15:18:21 +0000 (Fri, 27 Mar 2015) Log Message: ----------- [Imp] VUMeter: Make decay speed configurable via hidden setting [Display]VuMeterDecaySpeedDecibelPerSecond. The default (88) corresponds to the speed OpenMPT had used until now. The meter is still linear though, and the dynamic range stays at 48dB (which the configured speed gets scaled to). Using a logarithmic setting gives the value a more natural feeling and makes it easier to provide a logarithmic VUMeter in the future. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2015-03-24 17:03:16 UTC (rev 4905) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2015-03-27 15:18:21 UTC (rev 4906) @@ -850,10 +850,21 @@ } +const float VUMeter::dynamicRange = 48.0f; // corresponds to the current implementation of the UI widget displaying the result + + +void VUMeter::SetDecaySpeedDecibelPerSecond(float decibelPerSecond) +//----------------------------------------------------------------- +{ + float linearDecayRate = decibelPerSecond / dynamicRange; + decayParam = Util::Round<int32>(linearDecayRate * MIXING_CLIPMAX); +} + + void VUMeter::Decay(int32 secondsNum, int32 secondsDen) //----------------------------------------------------- { - int32 decay = Util::muldivr(120000 << 11, secondsNum, secondsDen); + int32 decay = Util::muldivr(decayParam, secondsNum, secondsDen); for(std::size_t channel = 0; channel < maxChannels; ++channel) { channels[channel].peak = std::max(channels[channel].peak - decay, 0); @@ -2271,6 +2282,7 @@ //--------------------------------------------------------- { OPENMPT_PROFILE_FUNCTION(Profiler::GUI); + m_VUMeter.SetDecaySpeedDecibelPerSecond(TrackerSettings::Instance().VuMeterDecaySpeedDecibelPerSecond); // update in notification update in order to avoid querying the settings framework from inside audio thread Notification *pnotify = (Notification *)lParam; if (pnotify) { Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2015-03-24 17:03:16 UTC (rev 4905) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2015-03-27 15:18:21 UTC (rev 4906) @@ -303,6 +303,7 @@ { public: static const std::size_t maxChannels = 4; + static const float dynamicRange; // corresponds to the current implementation of the UI widget diplaying the result struct Channel { int32 peak; @@ -311,7 +312,11 @@ }; private: Channel channels[maxChannels]; + int32 decayParam; public: + VUMeter() : decayParam(0) { SetDecaySpeedDecibelPerSecond(88.0f); } + void SetDecaySpeedDecibelPerSecond(float decibelPerSecond); +public: const Channel & operator [] (std::size_t channel) const { return channels[channel]; } void Process(const int *mixbuffer, std::size_t numChannels, std::size_t numFrames); // mixbuffer is interleaved void Decay(int32 secondsNum, int32 secondsDen); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-03-24 17:03:16 UTC (rev 4905) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-03-27 15:18:21 UTC (rev 4906) @@ -160,6 +160,7 @@ , gnMsgBoxVisiblityFlags(conf, "Display", "MDIGraphHeight", uint32_max) , GUIUpdateInterval(conf, "Display", "GUIUpdateInterval", 0) , VuMeterUpdateInterval(conf, "Display", "VuMeterUpdateInterval", 15) + , VuMeterDecaySpeedDecibelPerSecond(conf, "Display", "VuMeterDecaySpeedDecibelPerSecond", 88.0f) , rememberSongWindows(conf, "Display", "RememberSongWindows", true) , commentsFont(conf, "Display", "Comments Font", FontSetting("Courier New", 120)) // Misc Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2015-03-24 17:03:16 UTC (rev 4905) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2015-03-27 15:18:21 UTC (rev 4906) @@ -417,6 +417,7 @@ Setting<uint32> gnMsgBoxVisiblityFlags; Setting<uint32> GUIUpdateInterval; CachedSetting<uint32> VuMeterUpdateInterval; + CachedSetting<float> VuMeterDecaySpeedDecibelPerSecond; Setting<bool> rememberSongWindows; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |