Merge branch 'master' into cpp20

This commit is contained in:
Dalton Messmer
2024-11-07 00:19:20 -05:00
24 changed files with 167 additions and 377 deletions

View File

@@ -1,4 +1,4 @@
INCLUDE(BuildPlugin)
BUILD_PLUGIN(hydrogenimport HydrogenImport.cpp HydrogenImport.h local_file_mgr.cpp LocalFileMng.h)
BUILD_PLUGIN(hydrogenimport HydrogenImport.cpp HydrogenImport.h LocalFileMng.cpp LocalFileMng.h)

View File

@@ -1,7 +1,8 @@
#include "HydrogenImport.h"
#include <QDomDocument>
#include "LocalFileMng.h"
#include "HydrogenImport.h"
#include "Song.h"
#include "Engine.h"
#include "Instrument.h"

View File

@@ -1,12 +1,11 @@
#include <sys/stat.h>
#include "LocalFileMng.h"
#include <cctype>
#include <QDomDocument>
#include <QFile>
#include <QLocale>
#include <QTextCodec>
#include "LocalFileMng.h"
namespace lmms
{
@@ -197,10 +196,7 @@ QDomDocument LocalFileMng::openXmlDocument( const QString& filename )
return QDomDocument();
if( TinyXMLCompat ) {
QString enc = QTextCodec::codecForLocale()->name();
if( enc == QString("System") ) {
enc = "UTF-8";
}
const QString enc = "UTF-8"; // unknown encoding, so assume utf-8 and call it a day
QByteArray line;
QByteArray buf = QString("<?xml version='1.0' encoding='%1' ?>\n")
.arg( enc )

View File

@@ -14,12 +14,6 @@ namespace lmms
class LocalFileMng
{
public:
LocalFileMng();
~LocalFileMng();
std::vector<QString> getallPatternList(){
return m_allPatternList;
}
static QString readXmlString( QDomNode , const QString& nodeName, const QString& defaultValue, bool bCanBeEmpty = false, bool bShouldExists = true , bool tinyXmlCompatMode = false);
static float readXmlFloat( QDomNode , const QString& nodeName, float defaultValue, bool bCanBeEmpty = false, bool bShouldExists = true , bool tinyXmlCompatMode = false);
static int readXmlInt( QDomNode , const QString& nodeName, int defaultValue, bool bCanBeEmpty = false, bool bShouldExists = true , bool tinyXmlCompatMode = false);
@@ -27,7 +21,6 @@ public:
static void convertFromTinyXMLString( QByteArray* str );
static bool checkTinyXMLCompatMode( const QString& filename );
static QDomDocument openXmlDocument( const QString& filename );
std::vector<QString> m_allPatternList;
};

View File

@@ -132,8 +132,18 @@ Effect::ProcessStatus PeakControllerEffect::processImpl(SampleFrame* buf, const
float curRMS = sqrt_neg(sum / frames);
const float tres = c.m_tresholdModel.value();
const float amount = c.m_amountModel.value() * c.m_amountMultModel.value();
const float attack = 1.0f - c.m_attackModel.value();
const float decay = 1.0f - c.m_decayModel.value();
curRMS = qAbs( curRMS ) < tres ? 0.0f : curRMS;
m_lastSample = qBound( 0.0f, c.m_baseModel.value() + amount * curRMS, 1.0f );
float target = c.m_baseModel.value() + amount * curRMS;
// Use decay when the volume is decreasing, attack otherwise.
// Since direction can change as often as every sampleBuffer, it's difficult
// to witness attack/decay working in isolation unless using large buffer sizes.
const float t = target < m_lastSample ? decay : attack;
// Set m_lastSample to the interpolation between itself and target.
// When t is 1.0, m_lastSample snaps to target. When t is 0.0, m_lastSample shouldn't change.
m_lastSample = std::clamp(m_lastSample + t * (target - m_lastSample), 0.0f, 1.0f);
return ProcessStatus::Continue;
}

View File

@@ -226,7 +226,7 @@ void VestigeInstrument::loadSettings( const QDomElement & _this )
QStringList s_dumpValues;
for( int i = 0; i < paramCount; i++ )
{
sprintf(paramStr.data(), "param%d", i);
std::snprintf(paramStr.data(), paramStr.size(), "param%d", i);
s_dumpValues = dump[paramStr.data()].split(":");
knobFModel[i] = new FloatModel( 0.0f, 0.0f, 1.0f, 0.01f, this, QString::number(i) );
@@ -290,7 +290,7 @@ void VestigeInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this )
for( int i = 0; i < paramCount; i++ )
{
if (knobFModel[i]->isAutomated() || knobFModel[i]->controllerConnection()) {
sprintf(paramStr.data(), "param%d", i);
std::snprintf(paramStr.data(), paramStr.size(), "param%d", i);
knobFModel[i]->saveSettings(_doc, _this, paramStr.data());
}
@@ -987,7 +987,7 @@ ManageVestigeInstrumentView::ManageVestigeInstrumentView( Instrument * _instrume
for( int i = 0; i < m_vi->paramCount; i++ )
{
sprintf(paramStr.data(), "param%d", i);
std::snprintf(paramStr.data(), paramStr.size(), "param%d", i);
s_dumpValues = dump[paramStr.data()].split(":");
vstKnobs[ i ] = new CustomTextKnob( KnobType::Bright26, this, s_dumpValues.at( 1 ) );
@@ -996,7 +996,7 @@ ManageVestigeInstrumentView::ManageVestigeInstrumentView( Instrument * _instrume
if( !hasKnobModel )
{
sprintf(paramStr.data(), "%d", i);
std::snprintf(paramStr.data(), paramStr.size(), "%d", i);
m_vi->knobFModel[i] = new FloatModel(LocaleHelper::toFloat(s_dumpValues.at(2)),
0.0f, 1.0f, 0.01f, castModel<VestigeInstrument>(), paramStr.data());
}
@@ -1059,8 +1059,8 @@ void ManageVestigeInstrumentView::syncPlugin( void )
// those auto-setted values are not jurnaled, tracked for undo / redo
if( !( m_vi->knobFModel[ i ]->isAutomated() || m_vi->knobFModel[ i ]->controllerConnection() ) )
{
sprintf(paramStr.data(), "param%d", i);
s_dumpValues = dump[paramStr.data()].split(":");
std::snprintf(paramStr.data(), paramStr.size(), "param%d", i);
s_dumpValues = dump[paramStr.data()].split(":");
float f_value = LocaleHelper::toFloat(s_dumpValues.at(2));
m_vi->knobFModel[ i ]->setAutomatedValue( f_value );
m_vi->knobFModel[ i ]->setInitValue( f_value );

View File

@@ -87,7 +87,7 @@ void VstEffectControls::loadSettings( const QDomElement & _this )
QStringList s_dumpValues;
for( int i = 0; i < paramCount; i++ )
{
sprintf(paramStr.data(), "param%d", i);
std::snprintf(paramStr.data(), paramStr.size(), "param%d", i);
s_dumpValues = dump[paramStr.data()].split(":");
knobFModel[i] = new FloatModel( 0.0f, 0.0f, 1.0f, 0.01f, this, QString::number(i) );
@@ -137,7 +137,7 @@ void VstEffectControls::saveSettings( QDomDocument & _doc, QDomElement & _this )
for( int i = 0; i < paramCount; i++ )
{
if (knobFModel[i]->isAutomated() || knobFModel[i]->controllerConnection()) {
sprintf(paramStr.data(), "param%d", i);
std::snprintf(paramStr.data(), paramStr.size(), "param%d", i);
knobFModel[i]->saveSettings(_doc, _this, paramStr.data());
}
}
@@ -386,7 +386,7 @@ ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls *
for( int i = 0; i < m_vi->paramCount; i++ )
{
sprintf(paramStr.data(), "param%d", i);
std::snprintf(paramStr.data(), paramStr.size(), "param%d", i);
s_dumpValues = dump[paramStr.data()].split(":");
vstKnobs[ i ] = new CustomTextKnob( KnobType::Bright26, widget, s_dumpValues.at( 1 ) );
@@ -395,7 +395,7 @@ ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls *
if( !hasKnobModel )
{
sprintf(paramStr.data(), "%d", i);
std::snprintf(paramStr.data(), paramStr.size(), "%d", i);
m_vi->knobFModel[i] = new FloatModel(LocaleHelper::toFloat(s_dumpValues.at(2)),
0.0f, 1.0f, 0.01f, _eff, paramStr.data());
}
@@ -460,7 +460,7 @@ void ManageVSTEffectView::syncPlugin()
if( !( m_vi2->knobFModel[ i ]->isAutomated() ||
m_vi2->knobFModel[ i ]->controllerConnection() ) )
{
sprintf(paramStr.data(), "param%d", i);
std::snprintf(paramStr.data(), paramStr.size(), "param%d", i);
s_dumpValues = dump[paramStr.data()].split(":");
float f_value = LocaleHelper::toFloat(s_dumpValues.at(2));
m_vi2->knobFModel[ i ]->setAutomatedValue( f_value );