Skip to content

Commit

Permalink
MSVC: Fix Monstro instrument
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-w committed Jul 28, 2018
1 parent 57c85f4 commit b7c0997
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
1 change: 0 additions & 1 deletion plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ ENDIF("${PLUGIN_LIST}" STREQUAL "")
IF(MSVC)
SET(MSVC_INCOMPATIBLE_PLUGINS
LadspaEffect
monstro
sid
#VstEffect
Xpressive
Expand Down
47 changes: 24 additions & 23 deletions plugins/monstro/Monstro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}


Expand All @@ -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 );


Expand Down Expand Up @@ -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 )
Expand Down
4 changes: 4 additions & 0 deletions plugins/monstro/Monstro.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#ifndef MONSTRO_H
#define MONSTRO_H

#include <vector>

#include "Instrument.h"
#include "InstrumentView.h"
Expand Down Expand Up @@ -299,6 +300,9 @@ class MonstroSynth
int m_counter2r;
int m_counter3l;
int m_counter3r;

std::vector<float> m_lfo[2];
std::vector<float> m_env[2];
};

class MonstroInstrument : public Instrument
Expand Down

0 comments on commit b7c0997

Please sign in to comment.