From 3b80ec74d1cd790a2529a01abfc541cbe4b0c940 Mon Sep 17 00:00:00 2001 From: Vesa Date: Sun, 30 Mar 2014 15:18:29 +0300 Subject: [PATCH] Monstro - fixes, new waveforms --- plugins/monstro/Monstro.cpp | 57 ++++++++++++++++++++++++++++++++---- plugins/monstro/Monstro.h | 36 +++++++++++++++++++---- plugins/monstro/rand.png | Bin 0 -> 407 bytes plugins/monstro/sinabs.png | Bin 0 -> 399 bytes plugins/monstro/sqrsoft.png | Bin 0 -> 393 bytes 5 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 plugins/monstro/rand.png create mode 100644 plugins/monstro/sinabs.png create mode 100644 plugins/monstro/sqrsoft.png diff --git a/plugins/monstro/Monstro.cpp b/plugins/monstro/Monstro.cpp index 28aa4c94e..1ca3837be 100644 --- a/plugins/monstro/Monstro.cpp +++ b/plugins/monstro/Monstro.cpp @@ -99,8 +99,8 @@ void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf ) #define modulatefreq( car, mod ) \ if( mod##_e1 != 0.0 ) car = qBound( MIN_FREQ, car * static_cast( fastPow( 10.0, m_env1_buf[f] * mod##_e1 ) ), MAX_FREQ ); \ if( mod##_e2 != 0.0 ) car = qBound( MIN_FREQ, car * static_cast( fastPow( 10.0, m_env2_buf[f] * mod##_e2 ) ), MAX_FREQ ); \ - if( mod##_l1 != 0.0 ) car = qBound( MIN_FREQ, car * static_cast( fastPow( 2.5, m_lfo1_buf[f] * mod##_l1 ) ), MAX_FREQ ); \ - if( mod##_l2 != 0.0 ) car = qBound( MIN_FREQ, car * static_cast( fastPow( 2.5, m_lfo2_buf[f] * mod##_l2 ) ), MAX_FREQ ); + if( mod##_l1 != 0.0 ) car = qBound( MIN_FREQ, car * static_cast( fastPow( 2.0, m_lfo1_buf[f] * mod##_l1 ) ), MAX_FREQ ); \ + if( mod##_l2 != 0.0 ) car = qBound( MIN_FREQ, car * static_cast( fastPow( 2.0, m_lfo2_buf[f] * mod##_l2 ) ), MAX_FREQ ); #define modulateabs( car, mod ) \ if( mod##_e1 != 0.0 ) car = qBound( 0.0f, car + mod##_e1 * m_env1_buf[f], 1.0f ); \ @@ -113,7 +113,6 @@ void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf ) if( mod##_e2 != 0.0 ) car = fraction( car + mod##_e2 * m_env2_buf[f] ); \ if( mod##_l1 != 0.0 ) car = fraction( car + mod##_l1 / 2 * m_lfo1_buf[f] ); \ if( mod##_l2 != 0.0 ) car = fraction( car + mod##_l2 / 2 * m_lfo2_buf[f] ); - #define modulatevol( car, mod ) \ if( mod##_e1 > 0.0 ) car = qBound( 0.0f, car * ( 1.0f - mod##_e1 + mod##_e1 * m_env1_buf[f] ), MODCLIP ); \ @@ -272,6 +271,10 @@ void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf ) float o1_pw = pw; modulateabs( o1_pw, o1pw ) + // bounds check for phase + if( o1l_p < 0 ) o1l_p += 1.0f; + if( o1r_p < 0 ) o1r_p += 1.0f; + // pulse wave osc sample_t O1L = ( o1l_p < o1_pw ) ? 1.0f : -1.0f; sample_t O1R = ( o1r_p < o1_pw ) ? 1.0f : -1.0f; @@ -303,6 +306,10 @@ void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf ) float o2r_p = m_osc2r_phase + o2rpo; modulatephs( o2l_p, o2p ) modulatephs( o2r_p, o2p ) + + // bounds check for phase + if( o2l_p < 0 ) o2l_p += 1.0f; + if( o2r_p < 0 ) o2r_p += 1.0f; // multi-wave DC Oscillator sample_t O2L = oscillate( o2w, o2l_p ); @@ -347,6 +354,10 @@ void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf ) o3l_p = fraction( o3l_p + O2L/2 ); o3r_p = fraction( o3r_p + O2R/2 ); } + + // bounds check for phase + if( o3l_p < 0 ) o3l_p += 1.0f; + if( o3r_p < 0 ) o3r_p += 1.0f; // multi-wave DC Oscillator, sub-osc 1 sample_t O3AL = oscillate( o3w1, o3l_p ); @@ -449,6 +460,15 @@ void MonstroSynth::renderModulators( fpp_t _frames ) m_lfo1_buf[f] = lfo1_s; } break; + case WAVE_SQRSOFT: + for( f_cnt_t f = 0; f < _frames; f++ ) + { + const f_cnt_t t = f + m_nph->totalFramesPlayed(); + lfo1_s = oscillate( WAVE_SQRSOFT, lfo1_p + static_cast( t ) / lfo1_r ); + if( t < m_parent->m_lfo1_att ) lfo1_s *= ( static_cast( t ) / m_parent->m_lfo1_att ); + m_lfo1_buf[f] = lfo1_s; + } + break; case WAVE_MOOG: for( f_cnt_t f = 0; f < _frames; f++ ) { @@ -458,6 +478,15 @@ void MonstroSynth::renderModulators( fpp_t _frames ) m_lfo1_buf[f] = lfo1_s; } break; + case WAVE_SINABS: + for( f_cnt_t f = 0; f < _frames; f++ ) + { + const f_cnt_t t = f + m_nph->totalFramesPlayed(); + lfo1_s = oscillate( WAVE_SINABS, lfo1_p + static_cast( t ) / lfo1_r ); + if( t < m_parent->m_lfo1_att ) lfo1_s *= ( static_cast( t ) / m_parent->m_lfo1_att ); + m_lfo1_buf[f] = lfo1_s; + } + break; case WAVE_EXP: for( f_cnt_t f = 0; f < _frames; f++ ) { @@ -529,6 +558,15 @@ void MonstroSynth::renderModulators( fpp_t _frames ) m_lfo2_buf[f] = lfo2_s; } break; + case WAVE_SQRSOFT: + for( f_cnt_t f = 0; f < _frames; f++ ) + { + const f_cnt_t t = f + m_nph->totalFramesPlayed(); + lfo2_s = oscillate( WAVE_SQRSOFT, lfo2_p + static_cast( t ) / lfo2_r ); + if( t < m_parent->m_lfo2_att ) lfo2_s *= ( static_cast( t ) / m_parent->m_lfo2_att ); + m_lfo2_buf[f] = lfo2_s; + } + break; case WAVE_MOOG: for( f_cnt_t f = 0; f < _frames; f++ ) { @@ -538,6 +576,15 @@ void MonstroSynth::renderModulators( fpp_t _frames ) m_lfo2_buf[f] = lfo2_s; } break; + case WAVE_SINABS: + for( f_cnt_t f = 0; f < _frames; f++ ) + { + const f_cnt_t t = f + m_nph->totalFramesPlayed(); + lfo2_s = oscillate( WAVE_SINABS, lfo2_p + static_cast( t ) / lfo2_r ); + if( t < m_parent->m_lfo2_att ) lfo2_s *= ( static_cast( t ) / m_parent->m_lfo2_att ); + m_lfo2_buf[f] = lfo2_s; + } + break; case WAVE_EXP: for( f_cnt_t f = 0; f < _frames; f++ ) { @@ -797,8 +844,8 @@ MonstroInstrument::MonstroInstrument( InstrumentTrack * _instrument_track ) : setwavemodel( m_osc2Wave ) setwavemodel( m_osc3Wave1 ) setwavemodel( m_osc3Wave2 ) - setwavemodel( m_lfo1Wave ) - setwavemodel( m_lfo2Wave ) + setlfowavemodel( m_lfo1Wave ) + setlfowavemodel( m_lfo2Wave ) // make connections: diff --git a/plugins/monstro/Monstro.h b/plugins/monstro/Monstro.h index e251b60b2..43dc40b7c 100644 --- a/plugins/monstro/Monstro.h +++ b/plugins/monstro/Monstro.h @@ -59,11 +59,23 @@ name .addItem( tr( "Saw wave" ), static_cast( new PluginPixmapLoader( "saw" ) ) ); \ name .addItem( tr( "Ramp wave" ), static_cast( new PluginPixmapLoader( "ramp" ) ) ); \ name .addItem( tr( "Square wave" ), static_cast( new PluginPixmapLoader( "sqr" ) ) ); \ + name .addItem( tr( "Soft square wave" ), static_cast( new PluginPixmapLoader( "sqrsoft" ) ) ); \ name .addItem( tr( "Moog saw wave" ), static_cast( new PluginPixmapLoader( "moog" ) ) ); \ + name .addItem( tr( "Abs. sine wave" ), static_cast( new PluginPixmapLoader( "sinabs" ) ) ); \ name .addItem( tr( "Exponential wave" ), static_cast( new PluginPixmapLoader( "exp" ) ) ); \ name .addItem( tr( "White noise" ), static_cast( new PluginPixmapLoader( "noise" ) ) ); - +#define setlfowavemodel( name ) \ + name .addItem( tr( "Sine wave" ), static_cast( new PluginPixmapLoader( "sin" ) ) ); \ + name .addItem( tr( "Triangle wave" ), static_cast( new PluginPixmapLoader( "tri" ) ) ); \ + name .addItem( tr( "Saw wave" ), static_cast( new PluginPixmapLoader( "saw" ) ) ); \ + name .addItem( tr( "Ramp wave" ), static_cast( new PluginPixmapLoader( "ramp" ) ) ); \ + name .addItem( tr( "Square wave" ), static_cast( new PluginPixmapLoader( "sqr" ) ) ); \ + name .addItem( tr( "Soft square wave" ), static_cast( new PluginPixmapLoader( "sqrsoft" ) ) ); \ + name .addItem( tr( "Moog saw wave" ), static_cast( new PluginPixmapLoader( "moog" ) ) ); \ + name .addItem( tr( "Abs. sine wave" ), static_cast( new PluginPixmapLoader( "sinabs" ) ) ); \ + name .addItem( tr( "Exponential wave" ), static_cast( new PluginPixmapLoader( "exp" ) ) ); \ + name .addItem( tr( "Random" ), static_cast( new PluginPixmapLoader( "rand" ) ) ); const int O1ROW = 22; @@ -112,10 +124,12 @@ const int WAVE_TRI = 1; const int WAVE_SAW = 2; const int WAVE_RAMP = 3; const int WAVE_SQR = 4; -const int WAVE_MOOG = 5; -const int WAVE_EXP = 6; -const int WAVE_NOISE = 7; -const int NUM_WAVES = 8; +const int WAVE_SQRSOFT = 5; +const int WAVE_MOOG = 6; +const int WAVE_SINABS = 7; +const int WAVE_EXP = 8; +const int WAVE_NOISE = 9; +const int NUM_WAVES = 10; const int MOD_MIX = 0; const int MOD_AM = 1; @@ -206,9 +220,21 @@ private: case WAVE_SQR: return Oscillator::squareSample( _ph ); break; + case WAVE_SQRSOFT: + { + const float ph = fraction( _ph ); + if( ph < 0.1 ) return Oscillator::sinSample( ph * 5 + 0.75 ); + else if( ph < 0.5 ) return 1.0f; + else if( ph < 0.6 ) return Oscillator::sinSample( ph * 5 + 0.75 ); + else return -1.0f; + break; + } case WAVE_MOOG: return Oscillator::moogSawSample( _ph ); break; + case WAVE_SINABS: + return qAbs( Oscillator::sinSample( _ph ) ); + break; case WAVE_EXP: return Oscillator::expSample( _ph ); break; diff --git a/plugins/monstro/rand.png b/plugins/monstro/rand.png new file mode 100644 index 0000000000000000000000000000000000000000..b857b98820cfa9d95ab85e6f7be6a04487de29b4 GIT binary patch literal 407 zcmeAS@N?(olHy`uVBq!ia0vp^d_XL~!3HGNrubO_DYhhUcNZWH1V5d3*8?fe0*}aI z1_o|n5N2eUHAey{$X?><>&kwQS&my=GvZO*44{x?iEBiObAE1aYF-J0b5UwyNotBh zd1gt5g1e`0KzJjcI8f1lPZ!4!jq_6{>Uz5binv}+oR`?-d2qc=6i?XyhWdn6Zh{** zx+?3MeI1XeWo+R}+I&KSg?+NZEVkyZqlJ=t9KYN>KAU%X@!{AvwcmIrUGYt5&N6M} zPuTjAeHIJbfpj)0cDKgcPPxpl4@eiV%t^Z=*6_CEz1RUE1GYJ?N5b?Ldv$R-FqSmD z?zpkKVcDc)VF|{LuJ+=WTQ1FEPZQcKE%|~egW>Z2S#OpJxs|ShalK w6PeQoQn#+>yHZ}7JHs~o%Hf3zcKu=tm^|gQ&g9DFVdQ&MBb@09-|zZvX%Q literal 0 HcmV?d00001 diff --git a/plugins/monstro/sinabs.png b/plugins/monstro/sinabs.png new file mode 100644 index 0000000000000000000000000000000000000000..067fa0ddb04f4f27fd56baac0416ad8553d08c61 GIT binary patch literal 399 zcmeAS@N?(olHy`uVBq!ia0vp^d_XL~!3HGNrubO_DYhhUcNZWH1V5d3*8?fe0*}aI z1_o|n5N2eUHAey{$X?><>&kwQS&mywx>HXs5-22D;u=xnoS&PUnpeW$T$GwvlA5AW zo>`Ki;O^-g5Z=fq4pj8r)5S4FV*9sifkbhOd3^}9&K`&Afgv`{Lsx09Mh)7N!)vS?#}5wjV)En&Ry02y6l4f zRq?OWa#w8K6?FYoyOrjbu(y8>9*cQe&H9GX_<^WJ`0h8njp_+3GOJ5ne6+W+@im%1 zuxj_;bYg+^10`pM8;r+he&aBS{Cvgjr20?3#>@9ASa=%Llx}roT(;5p`p1pE=jvar z>wj3L9o;+4(q*Cff$DSp+6m$j4Ch-nGDaPEVjK1}lz-Ct?LFO1!h)9{UGinUlb*ae o%VkSeen$6!_V_LJezopr0C&opi2wiq literal 0 HcmV?d00001 diff --git a/plugins/monstro/sqrsoft.png b/plugins/monstro/sqrsoft.png new file mode 100644 index 0000000000000000000000000000000000000000..d04a739474efd2a478d60f3b7ed0a43a5ddce2d7 GIT binary patch literal 393 zcmeAS@N?(olHy`uVBq!ia0vp^d_XL~!3HGNrubO_DYhhUcNZWH1V5d3*8?fe0*}aI z1_o|n5N2eUHAey{$X?><>&kwQS&my=>Ab;m0icj%iEBiObAE1aYF-J0b5UwyNotBh zd1gt5g1e`0KzJjcI8f0?PZ!4!jq`IS8G1Q8inyNt{m;oUaKlD{je#3BY%Aq#;?Q&O zSk3XyDW+j