From: <sag...@us...> - 2014-10-10 22:26:40
|
Revision: 4414 http://sourceforge.net/p/modplug/code/4414 Author: saga-games Date: 2014-10-10 22:26:29 +0000 (Fri, 10 Oct 2014) Log Message: ----------- [Imp] VST: Randomize params now randomizes parameters by a factor (this is much more useful than completely random parameters) [Fix] MOD: Sample names couldn't contain any ANSI characters (broke in r1526 / OpenMPT 1.22). Revision Links: -------------- http://sourceforge.net/p/modplug/code/1526 Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/soundlib/Load_mod.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-10-10 20:30:27 UTC (rev 4413) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-10-10 22:26:29 UTC (rev 4414) @@ -21,6 +21,7 @@ #include "VstPresets.h" #include "../soundlib/FileReader.h" #include "InputHandler.h" +#include "dlg_misc.h" #include <sstream> @@ -226,12 +227,15 @@ } -VOID CAbstractVstEditor::OnRandomizePreset() +void CAbstractVstEditor::OnRandomizePreset() //----------------------------------------- { - if(Reporting::Confirm("Are you sure you want to randomize parameters?\nYou will lose current parameter values.", false, false, this) == cnfYes) + static int randomFactor = 10; + CInputDlg dlg(this, _T("Input parameter randomization amount (0 = no change, 100 = completely random)"), 0, 100, randomFactor); + if(dlg.DoModal() == IDOK) { - m_VstPlugin.RandomizeParams(); + randomFactor = dlg.resultNumber; + m_VstPlugin.RandomizeParams(randomFactor); UpdateParamDisplays(); } } @@ -494,10 +498,8 @@ // Can't process notes return false; } - } else - { - return true; } + return true; } Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2014-10-10 20:30:27 UTC (rev 4413) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2014-10-10 22:26:29 UTC (rev 4414) @@ -959,21 +959,17 @@ } -bool CVstPlugin::RandomizeParams(PlugParamIndex minParam, PlugParamIndex maxParam) -//-------------------------------------------------------------------------------- +void CVstPlugin::RandomizeParams(int amount) +//------------------------------------------ { - if (minParam == 0 && maxParam == 0) + PlugParamValue factor = PlugParamValue(amount) / 100.0f; + for(PlugParamIndex p = 0; p < m_Effect.numParams; p++) { - maxParam = m_Effect.numParams; + PlugParamValue val = GetParameter(p); + val += (2.0f * PlugParamValue(rand()) / PlugParamValue(RAND_MAX) - 1.0f) * factor; + Limit(val, 0.0f, 1.0f); + SetParameter(p, val); } - LimitMax(maxParam, PlugParamIndex(m_Effect.numParams)); - - for(PlugParamIndex p = minParam; p < maxParam; p++) - { - SetParameter(p, (float(rand()) / float(RAND_MAX))); - } - - return true; } Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2014-10-10 20:30:27 UTC (rev 4413) +++ trunk/OpenMPT/mptrack/Vstplug.h 2014-10-10 22:26:29 UTC (rev 4414) @@ -213,7 +213,7 @@ // Check if programs should be stored as chunks or parameters bool ProgramsAreChunks() const { return (m_Effect.flags & effFlagsProgramChunks) != 0; } bool GetParams(float* param, VstInt32 min, VstInt32 max); - bool RandomizeParams(PlugParamIndex minParam = 0, PlugParamIndex maxParam = 0); + void RandomizeParams(int amount); // If true, the plugin produces an output even if silence is being fed into it. bool ShouldProcessSilence() { return m_Effect.numInputs == 0 || ((m_Effect.flags & effFlagsNoSoundInStop) == 0 && Dispatch(effGetTailSize, 0, 0, nullptr, 0.0f) != 1); } void ResetSilence() { m_MixState.ResetSilence(); } Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-10 20:30:27 UTC (rev 4413) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-10 22:26:29 UTC (rev 4414) @@ -389,7 +389,7 @@ // Get rid of weird characters in sample names. for(size_t i = 0; i < CountOf(sampleName); i++) { - if(sampleName[i] && sampleName[i] < ' ') + if(sampleName[i] > 0 && sampleName[i] < ' ') { sampleName[i] = ' '; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |