From 445a31e54ab2e2ab29c23356f430949e790ec1f1 Mon Sep 17 00:00:00 2001 From: Vesa Date: Sun, 6 Apr 2014 22:14:54 +0300 Subject: [PATCH] Monstro: tweak the constants a bit --- plugins/monstro/Monstro.cpp | 16 ++++++++-------- plugins/monstro/Monstro.h | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/plugins/monstro/Monstro.cpp b/plugins/monstro/Monstro.cpp index 745777078..465f0b859 100644 --- a/plugins/monstro/Monstro.cpp +++ b/plugins/monstro/Monstro.cpp @@ -98,8 +98,8 @@ MonstroSynth::MonstroSynth( MonstroInstrument * _i, NotePlayHandle * _nph, m_r_last = 0.0f; // constants for very simple antialias/bandlimiting by amp delta capping - m_adcap3 = ( 44100 * 0.3 ) / m_samplerate; - m_adcap4 = ( 44100 * 0.25 ) / m_samplerate; + m_adcap1 = ADCAP1 / m_samplerate; + m_adcap2 = ADCAP2 / m_samplerate; } @@ -404,8 +404,8 @@ void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf ) sample_t O2R = oscillate( o2w, o2r_p ); // do simple alias reduction filtering before volume is touched, by capping amplitude delta - O2L = qBound( m_osc2l_last - m_adcap3, O2L, m_osc2l_last + m_adcap3 ); - O2R = qBound( m_osc2r_last - m_adcap3, O2R, m_osc2r_last + m_adcap3 ); + O2L = qBound( m_osc2l_last - m_adcap1, O2L, m_osc2l_last + m_adcap1 ); + O2R = qBound( m_osc2r_last - m_adcap1, O2R, m_osc2r_last + m_adcap1 ); m_osc2l_last = O2L; m_osc2r_last = O2R; @@ -469,8 +469,8 @@ void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf ) sample_t O3R = linearInterpolate( O3AR, O3BR, sub ); // do very simple bandlimit filtering by amp delta capping, before volume is touched - O3L = qBound( m_osc3l_last - m_adcap3, O3L, m_osc3l_last + m_adcap3 ); - O3R = qBound( m_osc3r_last - m_adcap3, O3R, m_osc3r_last + m_adcap3 ); + O3L = qBound( m_osc3l_last - m_adcap1, O3L, m_osc3l_last + m_adcap1 ); + O3R = qBound( m_osc3r_last - m_adcap1, O3R, m_osc3r_last + m_adcap1 ); m_osc3l_last = O3L; m_osc3r_last = O3R; @@ -494,8 +494,8 @@ void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf ) sample_t L = O1L + O3L + ( omod == MOD_MIX ? O2L : 0.0f ); sample_t R = O1R + O3R + ( omod == MOD_MIX ? O2R : 0.0f ); - L = qBound( m_l_last - m_adcap4, L, m_l_last + m_adcap4 ); - R = qBound( m_r_last - m_adcap4, R, m_r_last + m_adcap4 ); + L = qBound( m_l_last - m_adcap2, L, m_l_last + m_adcap2 ); + R = qBound( m_r_last - m_adcap2, R, m_r_last + m_adcap2 ); _buf[f][0] = L; _buf[f][1] = R; diff --git a/plugins/monstro/Monstro.h b/plugins/monstro/Monstro.h index 6a1066da9..45cf71778 100644 --- a/plugins/monstro/Monstro.h +++ b/plugins/monstro/Monstro.h @@ -38,6 +38,9 @@ #include "Oscillator.h" #include "lmms_math.h" +// +// UI Macros +// #define makeknob( name, x, y, hint, unit, oname ) \ name = new knob( knobStyled, view ); \ @@ -85,7 +88,7 @@ name .addItem( tr( "Exponential wave" ), static_cast( new PluginPixmapLoader( "exp" ) ) ); \ name .addItem( tr( "Random" ), static_cast( new PluginPixmapLoader( "rand" ) ) ); - +// UI constants const int O1ROW = 22; const int O2ROW = 22 + 39; const int O3ROW = 22 + 39 * 2; @@ -127,6 +130,7 @@ const int MATROW6 = 22 + 39*5; const int OPVIEW = 0; const int MATVIEW = 1; +// waveform enumerators const int WAVE_SINE = 0; const int WAVE_TRI = 1; const int WAVE_SAW = 2; @@ -139,6 +143,7 @@ const int WAVE_EXP = 8; const int WAVE_NOISE = 9; const int NUM_WAVES = 10; +// modulation enumerators const int MOD_MIX = 0; const int MOD_AM = 1; const int MOD_FM = 2; @@ -150,6 +155,11 @@ const float MODCLIP = 2.0; const float MIN_FREQ = 18.0f; const float MAX_FREQ = 48000.0f; +// constants for amp delta capping - these will be divided by samplerate by the synth +const float ADCAP1 = 44100 / 4; +const float ADCAP2 = 44100 / 4.5; + + class MonstroInstrument; class MonstroView; @@ -269,8 +279,8 @@ private: sample_t m_l_last; sample_t m_r_last; - float m_adcap3; - float m_adcap4; + float m_adcap1; + float m_adcap2; }; class MonstroInstrument : public Instrument