From b7c09974acc3644e6aaf1324c853f77cec152efa Mon Sep 17 00:00:00 2001 From: Lukas W Date: Sat, 28 Jul 2018 14:20:36 +0200 Subject: [PATCH] MSVC: Fix Monstro instrument --- plugins/CMakeLists.txt | 1 - plugins/monstro/Monstro.cpp | 47 +++++++++++++++++++------------------ plugins/monstro/Monstro.h | 4 ++++ 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 5c8000933f6..8f751b10db2 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -91,7 +91,6 @@ ENDIF("${PLUGIN_LIST}" STREQUAL "") IF(MSVC) SET(MSVC_INCOMPATIBLE_PLUGINS LadspaEffect - monstro sid #VstEffect Xpressive diff --git a/plugins/monstro/Monstro.cpp b/plugins/monstro/Monstro.cpp index 44a53510074..baee242bb78 100644 --- a/plugins/monstro/Monstro.cpp +++ b/plugins/monstro/Monstro.cpp @@ -100,6 +100,11 @@ MonstroSynth::MonstroSynth( MonstroInstrument * _i, NotePlayHandle * _nph ) : m_counter2r = 0; m_counter3l = 0; m_counter3r = 0; + + m_lfo[0].resize( m_parent->m_fpp ); + m_lfo[1].resize( m_parent->m_fpp ); + m_env[0].resize( m_parent->m_fpp ); + m_env[1].resize( m_parent->m_fpp ); } @@ -114,31 +119,31 @@ void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf ) // macros for modulating with env/lfos #define modulatefreq( car, mod ) \ modtmp = 0.0f; \ - if( mod##_e1 != 0.0f ) modtmp += env[0][f] * mod##_e1; \ - if( mod##_e2 != 0.0f ) modtmp += env[1][f] * mod##_e2; \ - if( mod##_l1 != 0.0f ) modtmp += lfo[0][f] * mod##_l1; \ - if( mod##_l2 != 0.0f ) modtmp += lfo[1][f] * mod##_l2; \ + if( mod##_e1 != 0.0f ) modtmp += m_env[0][f] * mod##_e1; \ + if( mod##_e2 != 0.0f ) modtmp += m_env[1][f] * mod##_e2; \ + if( mod##_l1 != 0.0f ) modtmp += m_lfo[0][f] * mod##_l1; \ + if( mod##_l2 != 0.0f ) modtmp += m_lfo[1][f] * mod##_l2; \ car = qBound( MIN_FREQ, car * powf( 2.0f, modtmp ), MAX_FREQ ); #define modulateabs( car, mod ) \ - if( mod##_e1 != 0.0f ) car += env[0][f] * mod##_e1; \ - if( mod##_e2 != 0.0f ) car += env[1][f] * mod##_e2; \ - if( mod##_l1 != 0.0f ) car += lfo[0][f] * mod##_l1; \ - if( mod##_l2 != 0.0f ) car += lfo[1][f] * mod##_l2; + if( mod##_e1 != 0.0f ) car += m_env[0][f] * mod##_e1; \ + if( mod##_e2 != 0.0f ) car += m_env[1][f] * mod##_e2; \ + if( mod##_l1 != 0.0f ) car += m_lfo[0][f] * mod##_l1; \ + if( mod##_l2 != 0.0f ) car += m_lfo[1][f] * mod##_l2; #define modulatephs( car, mod ) \ - if( mod##_e1 != 0.0f ) car += env[0][f] * mod##_e1; \ - if( mod##_e2 != 0.0f ) car += env[1][f] * mod##_e2; \ - if( mod##_l1 != 0.0f ) car += lfo[0][f] * mod##_l1; \ - if( mod##_l2 != 0.0f ) car += lfo[1][f] * mod##_l2; + if( mod##_e1 != 0.0f ) car += m_env[0][f] * mod##_e1; \ + if( mod##_e2 != 0.0f ) car += m_env[1][f] * mod##_e2; \ + if( mod##_l1 != 0.0f ) car += m_lfo[0][f] * mod##_l1; \ + if( mod##_l2 != 0.0f ) car += m_lfo[1][f] * mod##_l2; #define modulatevol( car, mod ) \ - if( mod##_e1 > 0.0f ) car *= ( 1.0f - mod##_e1 + mod##_e1 * env[0][f] ); \ - if( mod##_e1 < 0.0f ) car *= ( 1.0f + mod##_e1 * env[0][f] ); \ - if( mod##_e2 > 0.0f ) car *= ( 1.0f - mod##_e2 + mod##_e2 * env[1][f] ); \ - if( mod##_e2 < 0.0f ) car *= ( 1.0f + mod##_e2 * env[1][f] ); \ - if( mod##_l1 != 0.0f ) car *= ( 1.0f + mod##_l1 * lfo[0][f] ); \ - if( mod##_l2 != 0.0f ) car *= ( 1.0f + mod##_l2 * lfo[1][f] ); \ + if( mod##_e1 > 0.0f ) car *= ( 1.0f - mod##_e1 + mod##_e1 * m_env[0][f] ); \ + if( mod##_e1 < 0.0f ) car *= ( 1.0f + mod##_e1 * m_env[0][f] ); \ + if( mod##_e2 > 0.0f ) car *= ( 1.0f - mod##_e2 + mod##_e2 * m_env[1][f] ); \ + if( mod##_e2 < 0.0f ) car *= ( 1.0f + mod##_e2 * m_env[1][f] ); \ + if( mod##_l1 != 0.0f ) car *= ( 1.0f + mod##_l1 * m_lfo[0][f] ); \ + if( mod##_l2 != 0.0f ) car *= ( 1.0f + mod##_l2 * m_lfo[1][f] ); \ car = qBound( -MODCLIP, car, MODCLIP ); @@ -340,12 +345,8 @@ void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf ) float o3r_p = m_osc3r_phase + o3rpo; float sub; - // modulators - float lfo[2][ m_parent->m_fpp ]; - float env[2][ m_parent->m_fpp ]; - // render modulators: envelopes, lfos - updateModulators( &env[0][0], &env[1][0], &lfo[0][0], &lfo[1][0], _frames ); + updateModulators( m_env[0].data(), m_env[1].data(), m_lfo[0].data(), m_lfo[1].data(), _frames ); // begin for loop for( f_cnt_t f = 0; f < _frames; ++f ) diff --git a/plugins/monstro/Monstro.h b/plugins/monstro/Monstro.h index 2cf05f300e0..a8b1869044e 100644 --- a/plugins/monstro/Monstro.h +++ b/plugins/monstro/Monstro.h @@ -26,6 +26,7 @@ #ifndef MONSTRO_H #define MONSTRO_H +#include #include "Instrument.h" #include "InstrumentView.h" @@ -299,6 +300,9 @@ class MonstroSynth int m_counter2r; int m_counter3l; int m_counter3r; + + std::vector m_lfo[2]; + std::vector m_env[2]; }; class MonstroInstrument : public Instrument