Monstro.cpp 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841
  1. /*
  2. * Monstro.cpp - a monstrous semi-modular 3-osc synth with modulation matrix
  3. *
  4. * Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #include <QDomElement>
  25. #include "Monstro.h"
  26. #include "Engine.h"
  27. #include "InstrumentTrack.h"
  28. #include "gui_templates.h"
  29. #include "ToolTip.h"
  30. #include "Song.h"
  31. #include "lmms_math.h"
  32. #include "interpolation.h"
  33. #include "embed.h"
  34. #include "plugin_export.h"
  35. extern "C"
  36. {
  37. Plugin::Descriptor PLUGIN_EXPORT monstro_plugin_descriptor =
  38. {
  39. STRINGIFY( PLUGIN_NAME ),
  40. "Monstro",
  41. QT_TRANSLATE_NOOP( "PluginBrowser",
  42. "Monstrous 3-oscillator synth with modulation matrix" ),
  43. "Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>",
  44. 0x0100,
  45. Plugin::Instrument,
  46. new PluginPixmapLoader( "logo" ),
  47. NULL,
  48. NULL
  49. } ;
  50. }
  51. MonstroSynth::MonstroSynth( MonstroInstrument * _i, NotePlayHandle * _nph ) :
  52. m_parent( _i ),
  53. m_nph( _nph )
  54. {
  55. m_osc1l_phase = 0.0f;
  56. m_osc1r_phase = 0.0f;
  57. m_osc2l_phase = 0.0f;
  58. m_osc2r_phase = 0.0f;
  59. m_osc3l_phase = 0.0f;
  60. m_osc3r_phase = 0.0f;
  61. m_ph2l_last = 0.0f;
  62. m_ph2r_last = 0.0f;
  63. m_ph3l_last = 0.0f;
  64. m_ph3r_last = 0.0f;
  65. m_env_phase[0] = 0.0f;
  66. m_env_phase[1] = 0.0f;
  67. m_lfo_phase[0] = 0.0f;
  68. m_lfo_phase[1] = 0.0f;
  69. m_lfo_next[0] = Oscillator::noiseSample( 0.0f );
  70. m_lfo_next[1] = Oscillator::noiseSample( 0.0f );
  71. m_osc1l_last = 0.0f;
  72. m_osc1r_last = 0.0f;
  73. m_l_last = 0.0f;
  74. m_r_last = 0.0f;
  75. m_invert2l = false;
  76. m_invert2r = false;
  77. m_invert3l = false;
  78. m_invert3r = false;
  79. m_counter2l = 0;
  80. m_counter2r = 0;
  81. m_counter3l = 0;
  82. m_counter3r = 0;
  83. m_lfo[0].resize( m_parent->m_fpp );
  84. m_lfo[1].resize( m_parent->m_fpp );
  85. m_env[0].resize( m_parent->m_fpp );
  86. m_env[1].resize( m_parent->m_fpp );
  87. }
  88. MonstroSynth::~MonstroSynth()
  89. {
  90. }
  91. void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf )
  92. {
  93. float modtmp; // temp variable for freq modulation
  94. // macros for modulating with env/lfos
  95. #define modulatefreq( car, mod ) \
  96. modtmp = 0.0f; \
  97. if( mod##_e1 != 0.0f ) modtmp += m_env[0][f] * mod##_e1; \
  98. if( mod##_e2 != 0.0f ) modtmp += m_env[1][f] * mod##_e2; \
  99. if( mod##_l1 != 0.0f ) modtmp += m_lfo[0][f] * mod##_l1; \
  100. if( mod##_l2 != 0.0f ) modtmp += m_lfo[1][f] * mod##_l2; \
  101. car = qBound( MIN_FREQ, car * powf( 2.0f, modtmp ), MAX_FREQ );
  102. #define modulateabs( car, mod ) \
  103. if( mod##_e1 != 0.0f ) car += m_env[0][f] * mod##_e1; \
  104. if( mod##_e2 != 0.0f ) car += m_env[1][f] * mod##_e2; \
  105. if( mod##_l1 != 0.0f ) car += m_lfo[0][f] * mod##_l1; \
  106. if( mod##_l2 != 0.0f ) car += m_lfo[1][f] * mod##_l2;
  107. #define modulatephs( car, mod ) \
  108. if( mod##_e1 != 0.0f ) car += m_env[0][f] * mod##_e1; \
  109. if( mod##_e2 != 0.0f ) car += m_env[1][f] * mod##_e2; \
  110. if( mod##_l1 != 0.0f ) car += m_lfo[0][f] * mod##_l1; \
  111. if( mod##_l2 != 0.0f ) car += m_lfo[1][f] * mod##_l2;
  112. #define modulatevol( car, mod ) \
  113. if( mod##_e1 > 0.0f ) car *= ( 1.0f - mod##_e1 + mod##_e1 * m_env[0][f] ); \
  114. if( mod##_e1 < 0.0f ) car *= ( 1.0f + mod##_e1 * m_env[0][f] ); \
  115. if( mod##_e2 > 0.0f ) car *= ( 1.0f - mod##_e2 + mod##_e2 * m_env[1][f] ); \
  116. if( mod##_e2 < 0.0f ) car *= ( 1.0f + mod##_e2 * m_env[1][f] ); \
  117. if( mod##_l1 != 0.0f ) car *= ( 1.0f + mod##_l1 * m_lfo[0][f] ); \
  118. if( mod##_l2 != 0.0f ) car *= ( 1.0f + mod##_l2 * m_lfo[1][f] ); \
  119. car = qBound( -MODCLIP, car, MODCLIP );
  120. ////////////////////
  121. // //
  122. // MODULATORS //
  123. // //
  124. ////////////////////
  125. // LFO phase offsets
  126. const float lfo1_po = m_parent->m_lfo1Phs.value() / 360.0f;
  127. const float lfo2_po = m_parent->m_lfo2Phs.value() / 360.0f;
  128. // remove cruft from phase counters to prevent overflow, add phase offset
  129. m_lfo_phase[0] = absFraction( m_lfo_phase[0] + lfo1_po );
  130. m_lfo_phase[1] = absFraction( m_lfo_phase[1] + lfo2_po );
  131. // LFO rates and increment
  132. m_lfo_rate[0] = ( m_parent->m_lfo1Rate.value() * 0.001f * m_parent->m_samplerate );
  133. m_lfo_rate[1] = ( m_parent->m_lfo2Rate.value() * 0.001f * m_parent->m_samplerate );
  134. m_lfo_inc[0] = 1.0f / m_lfo_rate[0];
  135. m_lfo_inc[1] = 1.0f / m_lfo_rate[1];
  136. m_env_sus[0] = m_parent-> m_env1Sus.value();
  137. m_env_sus[1] = m_parent-> m_env2Sus.value();
  138. m_lfovalue[0] = m_parent->m_lfo1Wave.value();
  139. m_lfovalue[1] = m_parent->m_lfo2Wave.value();
  140. m_lfoatt[0] = m_parent->m_lfo1_att;
  141. m_lfoatt[1] = m_parent->m_lfo2_att;
  142. m_env_pre[0] = m_parent->m_env1_pre;
  143. m_env_att[0] = m_parent->m_env1_att;
  144. m_env_hold[0] = m_parent->m_env1_hold;
  145. m_env_dec[0] = m_parent->m_env1_dec;
  146. m_env_rel[0] = m_parent->m_env1_rel;
  147. m_env_pre[1] = m_parent->m_env2_pre;
  148. m_env_att[1] = m_parent->m_env2_att;
  149. m_env_hold[1] = m_parent->m_env2_hold;
  150. m_env_dec[1] = m_parent->m_env2_dec;
  151. m_env_rel[1] = m_parent->m_env2_rel;
  152. // get updated osc1 values
  153. // get pulse width
  154. const float pw = ( m_parent->m_osc1Pw.value() * 0.01f );
  155. const float o1pw_e1 = ( m_parent->m_pw1env1.value() );
  156. const float o1pw_e2 = ( m_parent->m_pw1env2.value() );
  157. const float o1pw_l1 = ( m_parent->m_pw1lfo1.value() * 0.5f );
  158. const float o1pw_l2 = ( m_parent->m_pw1lfo2.value() * 0.5f );
  159. const bool o1pw_mod = o1pw_e1 != 0.0f || o1pw_e2 != 0.0f || o1pw_l1 != 0.0f || o1pw_l2 != 0.0f;
  160. // get phases
  161. const float o1lpo = m_parent->m_osc1l_po;
  162. const float o1rpo = m_parent->m_osc1r_po;
  163. const float o1p_e1 = ( m_parent->m_phs1env1.value() );
  164. const float o1p_e2 = ( m_parent->m_phs1env2.value() );
  165. const float o1p_l1 = ( m_parent->m_phs1lfo1.value() * 0.5f );
  166. const float o1p_l2 = ( m_parent->m_phs1lfo2.value() * 0.5f );
  167. const bool o1p_mod = o1p_e1 != 0.0f || o1p_e2 != 0.0f || o1p_l1 != 0.0f || o1p_l2 != 0.0f;
  168. // get pitch
  169. const float o1lfb = ( m_parent->m_osc1l_freq * m_nph->frequency() );
  170. const float o1rfb = ( m_parent->m_osc1r_freq * m_nph->frequency() );
  171. const float o1f_e1 = ( m_parent->m_pit1env1.value() * 2.0f );
  172. const float o1f_e2 = ( m_parent->m_pit1env2.value() * 2.0f );
  173. const float o1f_l1 = ( m_parent->m_pit1lfo1.value() );
  174. const float o1f_l2 = ( m_parent->m_pit1lfo2.value() );
  175. const bool o1f_mod = o1f_e1 != 0.0f || o1f_e2 != 0.0f || o1f_l1 != 0.0f || o1f_l2 != 0.0f;
  176. // get volumes
  177. const float o1lv = m_parent->m_osc1l_vol;
  178. const float o1rv = m_parent->m_osc1r_vol;
  179. const float o1v_e1 = ( m_parent->m_vol1env1.value() );
  180. const float o1v_e2 = ( m_parent->m_vol1env2.value() );
  181. const float o1v_l1 = ( m_parent->m_vol1lfo1.value() );
  182. const float o1v_l2 = ( m_parent->m_vol1lfo2.value() );
  183. const bool o1v_mod = o1v_e1 != 0.0f || o1v_e2 != 0.0f || o1v_l1 != 0.0f || o1v_l2 != 0.0f;
  184. // update osc2
  185. // get waveform
  186. const int o2w = m_parent->m_osc2Wave.value();
  187. // get phases
  188. const float o2lpo = m_parent->m_osc2l_po;
  189. const float o2rpo = m_parent->m_osc2r_po;
  190. const float o2p_e1 = ( m_parent->m_phs2env1.value() );
  191. const float o2p_e2 = ( m_parent->m_phs2env2.value() );
  192. const float o2p_l1 = ( m_parent->m_phs2lfo1.value() * 0.5f );
  193. const float o2p_l2 = ( m_parent->m_phs2lfo2.value() * 0.5f );
  194. const bool o2p_mod = o2p_e1 != 0.0f || o2p_e2 != 0.0f || o2p_l1 != 0.0f || o2p_l2 != 0.0f;
  195. // get pitch
  196. const float o2lfb = ( m_parent->m_osc2l_freq * m_nph->frequency() );
  197. const float o2rfb = ( m_parent->m_osc2r_freq * m_nph->frequency() );
  198. const float o2f_e1 = ( m_parent->m_pit2env1.value() * 2.0f );
  199. const float o2f_e2 = ( m_parent->m_pit2env2.value() * 2.0f );
  200. const float o2f_l1 = ( m_parent->m_pit2lfo1.value() );
  201. const float o2f_l2 = ( m_parent->m_pit2lfo2.value() );
  202. const bool o2f_mod = o2f_e1 != 0.0f || o2f_e2 != 0.0f || o2f_l1 != 0.0f || o2f_l2 != 0.0f;
  203. // get volumes
  204. const float o2lv = m_parent->m_osc2l_vol;
  205. const float o2rv = m_parent->m_osc2r_vol;
  206. const float o2v_e1 = ( m_parent->m_vol2env1.value() );
  207. const float o2v_e2 = ( m_parent->m_vol2env2.value() );
  208. const float o2v_l1 = ( m_parent->m_vol2lfo1.value() );
  209. const float o2v_l2 = ( m_parent->m_vol2lfo2.value() );
  210. const bool o2v_mod = o2v_e1 != 0.0f || o2v_e2 != 0.0f || o2v_l1 != 0.0f || o2v_l2 != 0.0f;
  211. // update osc3
  212. // get waveforms
  213. const int o3w1 = m_parent->m_osc3Wave1.value();
  214. const int o3w2 = m_parent->m_osc3Wave2.value();
  215. // get phases
  216. const float o3lpo = m_parent->m_osc3l_po;
  217. const float o3rpo = m_parent->m_osc3r_po;
  218. const float o3p_e1 = ( m_parent->m_phs3env1.value() );
  219. const float o3p_e2 = ( m_parent->m_phs3env2.value() );
  220. const float o3p_l1 = ( m_parent->m_phs3lfo1.value() * 0.5f );
  221. const float o3p_l2 = ( m_parent->m_phs3lfo2.value() * 0.5f );
  222. const bool o3p_mod = o3p_e1 != 0.0f || o3p_e2 != 0.0f || o3p_l1 != 0.0f || o3p_l2 != 0.0f;
  223. // get pitch modulators
  224. const float o3fb = ( m_parent->m_osc3_freq * m_nph->frequency() );
  225. const float o3f_e1 = ( m_parent->m_pit3env1.value() * 2.0f );
  226. const float o3f_e2 = ( m_parent->m_pit3env2.value() * 2.0f );
  227. const float o3f_l1 = ( m_parent->m_pit3lfo1.value() );
  228. const float o3f_l2 = ( m_parent->m_pit3lfo2.value() );
  229. const bool o3f_mod = o3f_e1 != 0.0f || o3f_e2 != 0.0f || o3f_l1 != 0.0f || o3f_l2 != 0.0f;
  230. // get volumes
  231. const float o3lv = m_parent->m_osc3l_vol;
  232. const float o3rv = m_parent->m_osc3r_vol;
  233. const float o3v_e1 = ( m_parent->m_vol3env1.value() );
  234. const float o3v_e2 = ( m_parent->m_vol3env2.value() );
  235. const float o3v_l1 = ( m_parent->m_vol3lfo1.value() );
  236. const float o3v_l2 = ( m_parent->m_vol3lfo2.value() );
  237. const bool o3v_mod = o3v_e1 != 0.0f || o3v_e2 != 0.0f || o3v_l1 != 0.0f || o3v_l2 != 0.0f;
  238. // get sub
  239. const float o3sub = ( m_parent->m_osc3Sub.value() + 100.0f ) / 200.0f;
  240. const float o3s_e1 = ( m_parent->m_sub3env1.value() );
  241. const float o3s_e2 = ( m_parent->m_sub3env2.value() );
  242. const float o3s_l1 = ( m_parent->m_sub3lfo1.value() * 0.5f );
  243. const float o3s_l2 = ( m_parent->m_sub3lfo2.value() * 0.5f );
  244. const bool o3s_mod = o3s_e1 != 0.0f || o3s_e2 != 0.0f || o3s_l1 != 0.0f || o3s_l2 != 0.0f;
  245. //o2-o3 modulation
  246. const int omod = m_parent->m_o23Mod.value();
  247. // sync information
  248. const bool o1ssr = m_parent->m_osc1SSR.value();
  249. const bool o1ssf = m_parent->m_osc1SSF.value();
  250. const bool o2sync = m_parent->m_osc2SyncH.value();
  251. const bool o3sync = m_parent->m_osc3SyncH.value();
  252. const bool o2syncr = m_parent->m_osc2SyncR.value();
  253. const bool o3syncr = m_parent->m_osc3SyncR.value();
  254. ///////////////////////////
  255. // //
  256. // start buffer loop //
  257. // //
  258. ///////////////////////////
  259. // declare working variables for for loop
  260. // phase manipulation vars - these can be reused by all oscs
  261. float leftph;
  262. float rightph;
  263. float pd_l;
  264. float pd_r;
  265. float len_l;
  266. float len_r;
  267. // osc1 vars
  268. float o1l_f;
  269. float o1r_f;
  270. float o1l_p = m_osc1l_phase + o1lpo; // we add phase offset here so we don't have to do it every frame
  271. float o1r_p = m_osc1r_phase + o1rpo; // then subtract it again after loop...
  272. float o1_pw;
  273. // osc2 vars
  274. float o2l_f;
  275. float o2r_f;
  276. float o2l_p = m_osc2l_phase + o2lpo;
  277. float o2r_p = m_osc2r_phase + o2rpo;
  278. // osc3 vars
  279. float o3l_f;
  280. float o3r_f;
  281. float o3l_p = m_osc3l_phase + o3lpo;
  282. float o3r_p = m_osc3r_phase + o3rpo;
  283. float sub;
  284. // render modulators: envelopes, lfos
  285. updateModulators( m_env[0].data(), m_env[1].data(), m_lfo[0].data(), m_lfo[1].data(), _frames );
  286. // begin for loop
  287. for( f_cnt_t f = 0; f < _frames; ++f )
  288. {
  289. /* // debug code
  290. if( f % 10 == 0 ) {
  291. qDebug( "env1 %f -- env1 phase %f", m_env1_buf[f], m_env1_phase );
  292. qDebug( "env1 pre %f att %f dec %f rel %f ", m_parent->m_env1_pre, m_parent->m_env1_att,
  293. m_parent->m_env1_dec, m_parent->m_env1_rel );
  294. }*/
  295. /////////////////////////////
  296. // //
  297. // OSC 1 //
  298. // //
  299. /////////////////////////////
  300. // calc and mod frequencies
  301. o1l_f = o1lfb;
  302. o1r_f = o1rfb;
  303. if( o1f_mod )
  304. {
  305. modulatefreq( o1l_f, o1f )
  306. modulatefreq( o1r_f, o1f )
  307. }
  308. // calc and modulate pulse
  309. o1_pw = pw;
  310. if( o1pw_mod )
  311. {
  312. modulateabs( o1_pw, o1pw )
  313. o1_pw = qBound( PW_MIN, o1_pw, PW_MAX );
  314. }
  315. // calc and modulate phase
  316. leftph = o1l_p;
  317. rightph = o1r_p;
  318. if( o1p_mod )
  319. {
  320. modulatephs( leftph, o1p )
  321. modulatephs( rightph, o1p )
  322. }
  323. // pulse wave osc
  324. sample_t O1L = ( absFraction( leftph ) < o1_pw ) ? 1.0f : -1.0f;
  325. sample_t O1R = ( absFraction( rightph ) < o1_pw ) ? 1.0f : -1.0f;
  326. // check for rise/fall, and sync if appropriate
  327. // sync on rise
  328. if( o1ssr )
  329. {
  330. // hard sync
  331. if( o2sync )
  332. {
  333. if( O1L > m_osc1l_last ) { o2l_p = o2lpo; m_counter2l = m_parent->m_counterMax; }
  334. if( O1R > m_osc1r_last ) { o2r_p = o2rpo; m_counter2r = m_parent->m_counterMax; }
  335. }
  336. if( o3sync )
  337. {
  338. if( O1L > m_osc1l_last ) { o3l_p = o3lpo; m_counter3l = m_parent->m_counterMax; }
  339. if( O1R > m_osc1r_last ) { o3r_p = o3rpo; m_counter3r = m_parent->m_counterMax; }
  340. }
  341. // reverse sync
  342. if( o2syncr )
  343. {
  344. if( O1L > m_osc1l_last ) { m_invert2l = !m_invert2l; m_counter2l = m_parent->m_counterMax; }
  345. if( O1R > m_osc1r_last ) { m_invert2r = !m_invert2r; m_counter2r = m_parent->m_counterMax; }
  346. }
  347. if( o3syncr )
  348. {
  349. if( O1L > m_osc1l_last ) { m_invert3l = !m_invert3l; m_counter3l = m_parent->m_counterMax; }
  350. if( O1R > m_osc1r_last ) { m_invert3r = !m_invert3r; m_counter3r = m_parent->m_counterMax; }
  351. }
  352. }
  353. // sync on fall
  354. if( o1ssf )
  355. {
  356. // hard sync
  357. if( o2sync )
  358. {
  359. if( O1L < m_osc1l_last ) { o2l_p = o2lpo; m_counter2l = m_parent->m_counterMax; }
  360. if( O1R < m_osc1r_last ) { o2r_p = o2rpo; m_counter2r = m_parent->m_counterMax; }
  361. }
  362. if( o3sync )
  363. {
  364. if( O1L < m_osc1l_last ) { o3l_p = o3lpo; m_counter3l = m_parent->m_counterMax; }
  365. if( O1R < m_osc1r_last ) { o3r_p = o3rpo; m_counter3r = m_parent->m_counterMax; }
  366. }
  367. // reverse sync
  368. if( o2syncr )
  369. {
  370. if( O1L < m_osc1l_last ) { m_invert2l = !m_invert2l; m_counter2l = m_parent->m_counterMax; }
  371. if( O1R < m_osc1r_last ) { m_invert2r = !m_invert2r; m_counter2r = m_parent->m_counterMax; }
  372. }
  373. if( o3syncr )
  374. {
  375. if( O1L < m_osc1l_last ) { m_invert3l = !m_invert3l; m_counter3l = m_parent->m_counterMax; }
  376. if( O1R < m_osc1r_last ) { m_invert3r = !m_invert3r; m_counter3r = m_parent->m_counterMax; }
  377. }
  378. }
  379. // update last before signal is touched
  380. // also do a very simple amp delta cap
  381. const sample_t tmpl = m_osc1l_last;
  382. const sample_t tmpr = m_osc1r_last;
  383. m_osc1l_last = O1L;
  384. m_osc1r_last = O1R;
  385. if( tmpl != O1L ) O1L = 0.0f;
  386. if( tmpr != O1R ) O1R = 0.0f;
  387. // modulate volume
  388. O1L *= o1lv;
  389. O1R *= o1rv;
  390. if( o1v_mod )
  391. {
  392. modulatevol( O1L, o1v )
  393. modulatevol( O1R, o1v )
  394. }
  395. // update osc1 phase working variable
  396. o1l_p += 1.0f / ( static_cast<float>( m_parent->m_samplerate ) / o1l_f );
  397. o1r_p += 1.0f / ( static_cast<float>( m_parent->m_samplerate ) / o1r_f );
  398. /////////////////////////////
  399. // //
  400. // OSC 2 //
  401. // //
  402. /////////////////////////////
  403. // calc and mod frequencies
  404. o2l_f = o2lfb;
  405. o2r_f = o2rfb;
  406. if( o2f_mod )
  407. {
  408. modulatefreq( o2l_f, o2f )
  409. modulatefreq( o2r_f, o2f )
  410. }
  411. // calc and modulate phase
  412. leftph = o2l_p;
  413. rightph = o2r_p;
  414. if( o2p_mod )
  415. {
  416. modulatephs( leftph, o2p )
  417. modulatephs( rightph, o2p )
  418. }
  419. leftph = absFraction( leftph );
  420. rightph = absFraction( rightph );
  421. // phase delta
  422. pd_l = qAbs( leftph - m_ph2l_last );
  423. if( pd_l > 0.5 ) pd_l = 1.0 - pd_l;
  424. pd_r = qAbs( rightph - m_ph2r_last );
  425. if( pd_r > 0.5 ) pd_r = 1.0 - pd_r;
  426. // multi-wave DC Oscillator
  427. len_l = BandLimitedWave::pdToLen( pd_l );
  428. len_r = BandLimitedWave::pdToLen( pd_r );
  429. if( m_counter2l > 0 ) { len_l /= m_counter2l; m_counter2l--; }
  430. if( m_counter2r > 0 ) { len_r /= m_counter2r; m_counter2r--; }
  431. sample_t O2L = oscillate( o2w, leftph, len_l );
  432. sample_t O2R = oscillate( o2w, rightph, len_r );
  433. // modulate volume
  434. O2L *= o2lv;
  435. O2R *= o2rv;
  436. if( o2v_mod )
  437. {
  438. modulatevol( O2L, o2v )
  439. modulatevol( O2R, o2v )
  440. }
  441. // reverse sync - invert waveforms when needed
  442. if( m_invert2l ) O2L *= -1.0;
  443. if( m_invert2r ) O2R *= -1.0;
  444. // update osc2 phases
  445. m_ph2l_last = leftph;
  446. m_ph2r_last = rightph;
  447. o2l_p += 1.0f / ( static_cast<float>( m_parent->m_samplerate ) / o2l_f );
  448. o2r_p += 1.0f / ( static_cast<float>( m_parent->m_samplerate ) / o2r_f );
  449. /////////////////////////////
  450. // //
  451. // OSC 3 //
  452. // //
  453. /////////////////////////////
  454. // calc and mod frequencies
  455. o3l_f = o3fb;
  456. o3r_f = o3fb;
  457. if( o3f_mod )
  458. {
  459. modulatefreq( o3l_f, o3f )
  460. modulatefreq( o3r_f, o3f )
  461. }
  462. // calc and modulate phase
  463. leftph = o3l_p;
  464. rightph = o3r_p;
  465. if( o3p_mod )
  466. {
  467. modulatephs( leftph, o3p )
  468. modulatephs( rightph, o3p )
  469. }
  470. // o2 modulation?
  471. if( omod == MOD_PM )
  472. {
  473. leftph += O2L * 0.5f;
  474. rightph += O2R * 0.5f;
  475. }
  476. leftph = absFraction( leftph );
  477. rightph = absFraction( rightph );
  478. // phase delta
  479. pd_l = qAbs( leftph - m_ph3l_last );
  480. if( pd_l > 0.5 ) pd_l = 1.0 - pd_l;
  481. pd_r = qAbs( rightph - m_ph3r_last );
  482. if( pd_r > 0.5 ) pd_r = 1.0 - pd_r;
  483. // multi-wave DC Oscillator
  484. len_l = BandLimitedWave::pdToLen( pd_l );
  485. len_r = BandLimitedWave::pdToLen( pd_r );
  486. if( m_counter3l > 0 ) { len_l /= m_counter3l; m_counter3l--; }
  487. if( m_counter3r > 0 ) { len_r /= m_counter3r; m_counter3r--; }
  488. // sub-osc 1
  489. sample_t O3AL = oscillate( o3w1, leftph, len_l );
  490. sample_t O3AR = oscillate( o3w1, rightph, len_r );
  491. // multi-wave DC Oscillator, sub-osc 2
  492. sample_t O3BL = oscillate( o3w2, leftph, len_l );
  493. sample_t O3BR = oscillate( o3w2, rightph, len_r );
  494. // calc and modulate sub
  495. sub = o3sub;
  496. if( o3s_mod )
  497. {
  498. modulateabs( sub, o3s )
  499. sub = qBound( 0.0f, sub, 1.0f );
  500. }
  501. sample_t O3L = linearInterpolate( O3AL, O3BL, sub );
  502. sample_t O3R = linearInterpolate( O3AR, O3BR, sub );
  503. // modulate volume
  504. O3L *= o3lv;
  505. O3R *= o3rv;
  506. if( o3v_mod )
  507. {
  508. modulatevol( O3L, o3v )
  509. modulatevol( O3R, o3v )
  510. }
  511. // o2 modulation?
  512. if( omod == MOD_AM )
  513. {
  514. O3L = qBound( -MODCLIP, O3L * qMax( 0.0f, 1.0f + O2L ), MODCLIP );
  515. O3R = qBound( -MODCLIP, O3R * qMax( 0.0f, 1.0f + O2R ), MODCLIP );
  516. }
  517. // reverse sync - invert waveforms when needed
  518. if( m_invert3l ) O3L *= -1.0;
  519. if( m_invert3r ) O3R *= -1.0;
  520. // update osc3 phases
  521. m_ph3l_last = leftph;
  522. m_ph3r_last = rightph;
  523. len_l = 1.0f / ( static_cast<float>( m_parent->m_samplerate ) / o3l_f );
  524. len_r = 1.0f / ( static_cast<float>( m_parent->m_samplerate ) / o3r_f );
  525. // handle FM as PM
  526. if( omod == MOD_FM )
  527. {
  528. len_l += O2L * m_parent->m_fmCorrection;
  529. len_r += O2R * m_parent->m_fmCorrection;
  530. }
  531. o3l_p += len_l;
  532. o3r_p += len_r;
  533. // integrator - very simple filter
  534. sample_t L = O1L + O3L + ( omod == MOD_MIX ? O2L : 0.0f );
  535. sample_t R = O1R + O3R + ( omod == MOD_MIX ? O2R : 0.0f );
  536. _buf[f][0] = linearInterpolate( L, m_l_last, m_parent->m_integrator );
  537. _buf[f][1] = linearInterpolate( R, m_r_last, m_parent->m_integrator );
  538. m_l_last = L;
  539. m_r_last = R;
  540. }
  541. // update phases
  542. m_osc1l_phase = absFraction( o1l_p - o1lpo );
  543. m_osc1r_phase = absFraction( o1r_p - o1rpo );
  544. m_osc2l_phase = absFraction( o2l_p - o2lpo );
  545. m_osc2r_phase = absFraction( o2r_p - o2rpo );
  546. m_osc3l_phase = absFraction( o3l_p - o3lpo );
  547. m_osc3r_phase = absFraction( o3r_p - o3rpo );
  548. m_lfo_phase[0] = absFraction( m_lfo_phase[0] - lfo1_po );
  549. m_lfo_phase[1] = absFraction( m_lfo_phase[1] - lfo2_po );
  550. }
  551. inline void MonstroSynth::updateModulators( float * env1, float * env2, float * lfo1, float * lfo2, int frames )
  552. {
  553. // frames played before
  554. const f_cnt_t tfp = m_nph->totalFramesPlayed();
  555. float * lfo [2];
  556. float * env [2];
  557. lfo[0] = lfo1;
  558. lfo[1] = lfo2;
  559. env[0] = env1;
  560. env[1] = env2;
  561. for( int i = 0; i < 2; ++i )
  562. {
  563. switch( m_lfovalue[i] )
  564. {
  565. case WAVE_SINE:
  566. for( f_cnt_t f = 0; f < frames; ++f )
  567. {
  568. lfo[i][f] = Oscillator::sinSample( m_lfo_phase[i] );
  569. m_lfo_phase[i] += m_lfo_inc[i];
  570. }
  571. break;
  572. case WAVE_TRI:
  573. for( f_cnt_t f = 0; f < frames; ++f )
  574. {
  575. lfo[i][f] = Oscillator::triangleSample( m_lfo_phase[i] );
  576. m_lfo_phase[i] += m_lfo_inc[i];
  577. }
  578. break;
  579. case WAVE_SAW:
  580. for( f_cnt_t f = 0; f < frames; ++f )
  581. {
  582. lfo[i][f] = Oscillator::sawSample( m_lfo_phase[i] );
  583. m_lfo_phase[i] += m_lfo_inc[i];
  584. }
  585. break;
  586. case WAVE_RAMP:
  587. for( f_cnt_t f = 0; f < frames; ++f )
  588. {
  589. lfo[i][f] = Oscillator::sawSample( m_lfo_phase[i] ) * -1.0f;
  590. m_lfo_phase[i] += m_lfo_inc[i];
  591. }
  592. break;
  593. case WAVE_SQR:
  594. for( f_cnt_t f = 0; f < frames; ++f )
  595. {
  596. lfo[i][f] = Oscillator::squareSample( m_lfo_phase[i] );
  597. m_lfo_phase[i] += m_lfo_inc[i];
  598. }
  599. break;
  600. case WAVE_SQRSOFT:
  601. for( f_cnt_t f = 0; f < frames; ++f )
  602. {
  603. lfo[i][f] = oscillate( WAVE_SQRSOFT, m_lfo_phase[i], 0 );
  604. m_lfo_phase[i] += m_lfo_inc[i];
  605. }
  606. break;
  607. case WAVE_MOOG:
  608. for( f_cnt_t f = 0; f < frames; ++f )
  609. {
  610. lfo[i][f] = Oscillator::moogSawSample( m_lfo_phase[i] );
  611. m_lfo_phase[i] += m_lfo_inc[i];
  612. }
  613. break;
  614. case WAVE_SINABS:
  615. for( f_cnt_t f = 0; f < frames; ++f )
  616. {
  617. lfo[i][f] = oscillate( WAVE_SINABS, m_lfo_phase[i], 0 );
  618. m_lfo_phase[i] += m_lfo_inc[i];
  619. }
  620. break;
  621. case WAVE_EXP:
  622. for( f_cnt_t f = 0; f < frames; ++f )
  623. {
  624. lfo[i][f] = Oscillator::expSample( m_lfo_phase[i] );
  625. m_lfo_phase[i] += m_lfo_inc[i];
  626. }
  627. break;
  628. case WAVE_RANDOM:
  629. for( f_cnt_t f = 0; f < frames; ++f )
  630. {
  631. if( ( tfp + f ) % static_cast<int>( m_lfo_rate[i] ) == 0 ) m_lfo_last[i] = Oscillator::noiseSample( 0.0f );
  632. lfo[i][f] = m_lfo_last[i];
  633. m_lfo_phase[i] += m_lfo_inc[i];
  634. }
  635. break;
  636. case WAVE_RANDOM_SMOOTH:
  637. for( f_cnt_t f = 0; f < frames; ++f )
  638. {
  639. const f_cnt_t tm = ( tfp + f ) % static_cast<int>( m_lfo_rate[i] );
  640. if( tm == 0 )
  641. {
  642. m_lfo_last[i] = m_lfo_next[i];
  643. m_lfo_next[i] = Oscillator::noiseSample( 0.0f );
  644. }
  645. lfo[i][f] = cosinusInterpolate( m_lfo_last[i], m_lfo_next[i], static_cast<float>( tm ) / m_lfo_rate[i] );
  646. m_lfo_phase[i] += m_lfo_inc[i];
  647. }
  648. break;
  649. }
  650. // attack
  651. for( f_cnt_t f = 0; f < frames; ++f )
  652. {
  653. if( tfp + f < m_lfoatt[i] ) lfo[i][f] *= ( static_cast<sample_t>( tfp ) / m_lfoatt[i] );
  654. }
  655. /////////////////////////////////////////////
  656. // //
  657. // //
  658. // envelopes //
  659. // //
  660. // //
  661. /////////////////////////////////////////////
  662. for( f_cnt_t f = 0; f < frames; ++f )
  663. {
  664. if( m_env_phase[i] < 4.0f && m_nph->isReleased() && f >= m_nph->framesBeforeRelease() )
  665. {
  666. if( m_env_phase[i] < 1.0f ) m_env_phase[i] = 5.0f;
  667. else if( m_env_phase[i] < 2.0f ) m_env_phase[i] = 5.0f - fraction( m_env_phase[i] );
  668. else if( m_env_phase[i] < 3.0f ) m_env_phase[i] = 4.0f;
  669. else m_env_phase[i] = 4.0f + fraction( m_env_phase[i] );
  670. }
  671. // process envelope
  672. if( m_env_phase[i] < 1.0f ) // pre-delay phase
  673. {
  674. env[i][f] = 0.0f;
  675. m_env_phase[i] = qMin( 1.0f, m_env_phase[i] + m_env_pre[i] );
  676. }
  677. else if( m_env_phase[i] < 2.0f ) // attack phase
  678. {
  679. env[i][f] = calcSlope( i, fraction( m_env_phase[i] ) );
  680. m_env_phase[i] = qMin( 2.0f, m_env_phase[i] + m_env_att[i] );
  681. }
  682. else if( m_env_phase[i] < 3.0f ) // hold phase
  683. {
  684. env[i][f] = 1.0f;
  685. m_env_phase[i] = qMin( 3.0f, m_env_phase[i] + m_env_hold[i] );
  686. }
  687. else if( m_env_phase[i] < 4.0f ) // decay phase
  688. {
  689. const sample_t s = calcSlope( i, 1.0f - fraction( m_env_phase[i] ) );
  690. if( s <= m_env_sus[i] )
  691. {
  692. env[i][f] = m_env_sus[i];
  693. }
  694. else
  695. {
  696. env[i][f] = s;
  697. m_env_phase[i] = qMin( 4.0f - m_env_sus[i], m_env_phase[i] + m_env_dec[i] );
  698. if( m_env_phase[i] == 4.0f ) m_env_phase[i] = 5.0f; // jump over release if sustain is zero - fix for clicking
  699. }
  700. }
  701. else if( m_env_phase[i] < 5.0f ) // release phase
  702. {
  703. env[i][f] = calcSlope( i, 1.0f - fraction( m_env_phase[i] ) );
  704. m_env_phase[i] += m_env_rel[i];
  705. }
  706. else env[i][f] = 0.0f;
  707. }
  708. }
  709. }
  710. inline sample_t MonstroSynth::calcSlope( int slope, sample_t s )
  711. {
  712. if( m_parent->m_slope[slope] == 1.0f ) return s;
  713. if( s == 0.0f ) return s;
  714. return fastPow( s, m_parent->m_slope[slope] );
  715. }
  716. MonstroInstrument::MonstroInstrument( InstrumentTrack * _instrument_track ) :
  717. Instrument( _instrument_track, &monstro_plugin_descriptor ),
  718. m_osc1Vol( 33.0, 0.0, 200.0, 0.1, this, tr( "Osc 1 volume" ) ),
  719. m_osc1Pan( 0.0, -100.0, 100.0, 0.1, this, tr( "Osc 1 panning" ) ),
  720. m_osc1Crs( 0.0, -24.0, 24.0, 1.0, this, tr( "Osc 1 coarse detune" ) ),
  721. m_osc1Ftl( 0.0, -100.0, 100.0, 1.0, this, tr( "Osc 1 fine detune left" ) ),
  722. m_osc1Ftr( 0.0, -100.0, 100.0, 1.0, this, tr( "Osc 1 fine detune right" ) ),
  723. m_osc1Spo( 0.0, -180.0, 180.0, 0.1, this, tr( "Osc 1 stereo phase offset" ) ),
  724. m_osc1Pw( 50.0, PW_MIN, PW_MAX, 0.01, this, tr( "Osc 1 pulse width" ) ),
  725. m_osc1SSR( false, this, tr( "Osc 1 sync send on rise" ) ),
  726. m_osc1SSF( false, this, tr( "Osc 1 sync send on fall" ) ),
  727. m_osc2Vol( 33.0, 0.0, 200.0, 0.1, this, tr( "Osc 2 volume" ) ),
  728. m_osc2Pan( 0.0, -100.0, 100.0, 0.1, this, tr( "Osc 2 panning" ) ),
  729. m_osc2Crs( 0.0, -24.0, 24.0, 1.0, this, tr( "Osc 2 coarse detune" ) ),
  730. m_osc2Ftl( 0.0, -100.0, 100.0, 1.0, this, tr( "Osc 2 fine detune left" ) ),
  731. m_osc2Ftr( 0.0, -100.0, 100.0, 1.0, this, tr( "Osc 2 fine detune right" ) ),
  732. m_osc2Spo( 0.0, -180.0, 180.0, 0.1, this, tr( "Osc 2 stereo phase offset" ) ),
  733. m_osc2Wave( this, tr( "Osc 2 waveform" ) ),
  734. m_osc2SyncH( false, this, tr( "Osc 2 sync hard" ) ),
  735. m_osc2SyncR( false, this, tr( "Osc 2 sync reverse" ) ),
  736. m_osc3Vol( 33.0, 0.0, 200.0, 0.1, this, tr( "Osc 3 volume" ) ),
  737. m_osc3Pan( 0.0, -100.0, 100.0, 0.1, this, tr( "Osc 3 panning" ) ),
  738. m_osc3Crs( 0.0, -24.0, 24.0, 1.0, this, tr( "Osc 3 coarse detune" ) ),
  739. m_osc3Spo( 0.0, -180.0, 180.0, 0.1, this, tr( "Osc 3 Stereo phase offset" ) ),
  740. m_osc3Sub( 0.0, -100.0, 100.0, 0.1, this, tr( "Osc 3 sub-oscillator mix" ) ),
  741. m_osc3Wave1( this, tr( "Osc 3 waveform 1" ) ),
  742. m_osc3Wave2( this, tr( "Osc 3 waveform 2" ) ),
  743. m_osc3SyncH( false, this, tr( "Osc 3 sync hard" ) ),
  744. m_osc3SyncR( false, this, tr( "Osc 3 Sync reverse" ) ),
  745. m_lfo1Wave( this, tr( "LFO 1 waveform" ) ),
  746. m_lfo1Att( 0.0f, 0.0f, 2000.0f, 1.0f, 2000.0f, this, tr( "LFO 1 attack" ) ),
  747. m_lfo1Rate( 1.0f, 0.1, 10000.0, 0.1, 10000.0f, this, tr( "LFO 1 rate" ) ),
  748. m_lfo1Phs( 0.0, -180.0, 180.0, 0.1, this, tr( "LFO 1 phase" ) ),
  749. m_lfo2Wave( this, tr( "LFO 2 waveform" ) ),
  750. m_lfo2Att( 0.0f, 0.0f, 2000.0f, 1.0f, 2000.0f, this, tr( "LFO 2 attack" ) ),
  751. m_lfo2Rate( 1.0f, 0.1, 10000.0, 0.1, 10000.0f, this, tr( "LFO 2 rate" ) ),
  752. m_lfo2Phs( 0.0, -180.0, 180.0, 0.1, this, tr( "LFO 2 phase" ) ),
  753. m_env1Pre( 0.0f, 0.0f, 2000.0f, 1.0f, 2000.0f, this, tr( "Env 1 pre-delay" ) ),
  754. m_env1Att( 0.0f, 0.0f, 2000.0f, 1.0f, 2000.0f, this, tr( "Env 1 attack" ) ),
  755. m_env1Hold( 0.0f, 0.0f, 4000.0f, 1.0f, 4000.0f, this, tr( "Env 1 hold" ) ),
  756. m_env1Dec( 0.0f, 0.0f, 4000.0f, 1.0f, 4000.0f, this, tr( "Env 1 decay" ) ),
  757. m_env1Sus( 1.0f, 0.0f, 1.0f, 0.001f, this, tr( "Env 1 sustain" ) ),
  758. m_env1Rel( 0.0f, 0.0f, 4000.0f, 1.0f, 4000.0f, this, tr( "Env 1 release" ) ),
  759. m_env1Slope( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Env 1 slope" ) ),
  760. m_env2Pre( 0.0f, 0.0f, 2000.0f, 1.0f, 2000.0f, this, tr( "Env 2 pre-delay" ) ),
  761. m_env2Att( 0.0f, 0.0f, 2000.0f, 1.0f, 2000.0f, this, tr( "Env 2 attack" ) ),
  762. m_env2Hold( 0.0f, 0.0f, 4000.0f, 1.0f, 4000.0f, this, tr( "Env 2 hold" ) ),
  763. m_env2Dec( 0.0f, 0.0f, 4000.0f, 1.0f, 4000.0f, this, tr( "Env 2 decay" ) ),
  764. m_env2Sus( 1.0f, 0.0f, 1.0f, 0.001f, this, tr( "Env 2 sustain" ) ),
  765. m_env2Rel( 0.0f, 0.0f, 4000.0f, 1.0f, 4000.0f, this, tr( "Env 2 release" ) ),
  766. m_env2Slope( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Env 2 slope" ) ),
  767. m_o23Mod( 0, 0, NUM_MODS - 1, this, tr( "Osc 2+3 modulation" ) ),
  768. m_selectedView( 0, 0, 1, this, tr( "Selected view" ) ),
  769. m_vol1env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - Vol env 1" ) ),
  770. m_vol1env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - Vol env 2" ) ),
  771. m_vol1lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - Vol LFO 1" ) ),
  772. m_vol1lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - Vol LFO 2" ) ),
  773. m_vol2env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 2 - Vol env 1" ) ),
  774. m_vol2env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 2 - Vol env 2" ) ),
  775. m_vol2lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 2 - Vol LFO 1" ) ),
  776. m_vol2lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 2 - Vol LFO 2" ) ),
  777. m_vol3env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Vol env 1" ) ),
  778. m_vol3env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Vol env 2" ) ),
  779. m_vol3lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Vol LFO 1" ) ),
  780. m_vol3lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Vol LFO 2" ) ),
  781. m_phs1env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - Phs env 1" ) ),
  782. m_phs1env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - Phs env 2" ) ),
  783. m_phs1lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - Phs LFO 1" ) ),
  784. m_phs1lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - Phs LFO 2" ) ),
  785. m_phs2env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 2 - Phs env 1" ) ),
  786. m_phs2env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 2 - Phs env 2" ) ),
  787. m_phs2lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 2 - Phs LFO 1" ) ),
  788. m_phs2lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 2 - Phs LFO 2" ) ),
  789. m_phs3env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Phs env 1" ) ),
  790. m_phs3env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Phs env 2" ) ),
  791. m_phs3lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Phs LFO 1" ) ),
  792. m_phs3lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Phs LFO 2" ) ),
  793. m_pit1env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - Pit env 1" ) ),
  794. m_pit1env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - Pit env 2" ) ),
  795. m_pit1lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - Pit LFO 1" ) ),
  796. m_pit1lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - Pit LFO 2" ) ),
  797. m_pit2env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 2 - Pit env 1" ) ),
  798. m_pit2env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 2 - Pit env 2" ) ),
  799. m_pit2lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 2 - Pit LFO 1" ) ),
  800. m_pit2lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 2 - Pit LFO 2" ) ),
  801. m_pit3env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Pit env 1" ) ),
  802. m_pit3env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Pit env 2" ) ),
  803. m_pit3lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Pit LFO 1" ) ),
  804. m_pit3lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Pit LFO 2" ) ),
  805. m_pw1env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - PW env 1" ) ),
  806. m_pw1env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - PW env 2" ) ),
  807. m_pw1lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - PW LFO 1" ) ),
  808. m_pw1lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 1 - PW LFO 2" ) ),
  809. m_sub3env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Sub env 1" ) ),
  810. m_sub3env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Sub env 2" ) ),
  811. m_sub3lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Sub LFO 1" ) ),
  812. m_sub3lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Osc 3 - Sub LFO 2" ) )
  813. {
  814. // setup waveboxes
  815. setwavemodel( m_osc2Wave )
  816. setwavemodel( m_osc3Wave1 )
  817. setwavemodel( m_osc3Wave2 )
  818. setlfowavemodel( m_lfo1Wave )
  819. setlfowavemodel( m_lfo2Wave )
  820. // make connections:
  821. // updateVolumes
  822. connect( &m_osc1Vol, SIGNAL( dataChanged() ), this, SLOT( updateVolume1() ), Qt::DirectConnection );
  823. connect( &m_osc1Pan, SIGNAL( dataChanged() ), this, SLOT( updateVolume1() ), Qt::DirectConnection );
  824. connect( &m_osc2Vol, SIGNAL( dataChanged() ), this, SLOT( updateVolume2() ), Qt::DirectConnection );
  825. connect( &m_osc2Pan, SIGNAL( dataChanged() ), this, SLOT( updateVolume2() ), Qt::DirectConnection );
  826. connect( &m_osc3Vol, SIGNAL( dataChanged() ), this, SLOT( updateVolume3() ), Qt::DirectConnection );
  827. connect( &m_osc3Pan, SIGNAL( dataChanged() ), this, SLOT( updateVolume3() ), Qt::DirectConnection );
  828. // updateFreq
  829. connect( &m_osc1Crs, SIGNAL( dataChanged() ), this, SLOT( updateFreq1() ), Qt::DirectConnection );
  830. connect( &m_osc2Crs, SIGNAL( dataChanged() ), this, SLOT( updateFreq2() ), Qt::DirectConnection );
  831. connect( &m_osc3Crs, SIGNAL( dataChanged() ), this, SLOT( updateFreq3() ), Qt::DirectConnection );
  832. connect( &m_osc1Ftl, SIGNAL( dataChanged() ), this, SLOT( updateFreq1() ), Qt::DirectConnection );
  833. connect( &m_osc2Ftl, SIGNAL( dataChanged() ), this, SLOT( updateFreq2() ), Qt::DirectConnection );
  834. connect( &m_osc1Ftr, SIGNAL( dataChanged() ), this, SLOT( updateFreq1() ), Qt::DirectConnection );
  835. connect( &m_osc2Ftr, SIGNAL( dataChanged() ), this, SLOT( updateFreq2() ), Qt::DirectConnection );
  836. // updatePO
  837. connect( &m_osc1Spo, SIGNAL( dataChanged() ), this, SLOT( updatePO1() ), Qt::DirectConnection );
  838. connect( &m_osc2Spo, SIGNAL( dataChanged() ), this, SLOT( updatePO2() ), Qt::DirectConnection );
  839. connect( &m_osc3Spo, SIGNAL( dataChanged() ), this, SLOT( updatePO3() ), Qt::DirectConnection );
  840. // updateEnvelope1
  841. connect( &m_env1Pre, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope1() ), Qt::DirectConnection );
  842. connect( &m_env1Att, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope1() ), Qt::DirectConnection );
  843. connect( &m_env1Hold, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope1() ), Qt::DirectConnection );
  844. connect( &m_env1Dec, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope1() ), Qt::DirectConnection );
  845. connect( &m_env1Rel, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope1() ), Qt::DirectConnection );
  846. connect( &m_env1Slope, SIGNAL( dataChanged() ), this, SLOT( updateSlope1() ), Qt::DirectConnection );
  847. // updateEnvelope2
  848. connect( &m_env2Pre, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope2() ), Qt::DirectConnection );
  849. connect( &m_env2Att, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope2() ), Qt::DirectConnection );
  850. connect( &m_env2Hold, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope2() ), Qt::DirectConnection );
  851. connect( &m_env2Dec, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope2() ), Qt::DirectConnection );
  852. connect( &m_env2Rel, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope2() ), Qt::DirectConnection );
  853. connect( &m_env2Slope, SIGNAL( dataChanged() ), this, SLOT( updateSlope2() ), Qt::DirectConnection );
  854. // updateLFOAtts
  855. connect( &m_lfo1Att, SIGNAL( dataChanged() ), this, SLOT( updateLFOAtts() ), Qt::DirectConnection );
  856. connect( &m_lfo2Att, SIGNAL( dataChanged() ), this, SLOT( updateLFOAtts() ), Qt::DirectConnection );
  857. // updateSampleRate
  858. connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSamplerate() ) );
  859. m_fpp = Engine::mixer()->framesPerPeriod();
  860. updateSamplerate();
  861. updateVolume1();
  862. updateVolume2();
  863. updateVolume3();
  864. updateFreq1();
  865. updateFreq2();
  866. updateFreq3();
  867. updatePO1();
  868. updatePO2();
  869. updatePO3();
  870. updateSlope1();
  871. updateSlope2();
  872. }
  873. MonstroInstrument::~MonstroInstrument()
  874. {
  875. }
  876. void MonstroInstrument::playNote( NotePlayHandle * _n,
  877. sampleFrame * _working_buffer )
  878. {
  879. const fpp_t frames = _n->framesLeftForCurrentPeriod();
  880. const f_cnt_t offset = _n->noteOffset();
  881. if ( _n->totalFramesPlayed() == 0 || _n->m_pluginData == NULL )
  882. {
  883. _n->m_pluginData = new MonstroSynth( this, _n );
  884. }
  885. MonstroSynth * ms = static_cast<MonstroSynth *>( _n->m_pluginData );
  886. ms->renderOutput( frames, _working_buffer + offset );
  887. //applyRelease( _working_buffer, _n ); // we have our own release
  888. instrumentTrack()->processAudioBuffer( _working_buffer, frames + offset, _n );
  889. }
  890. void MonstroInstrument::deleteNotePluginData( NotePlayHandle * _n )
  891. {
  892. delete static_cast<MonstroSynth *>( _n->m_pluginData );
  893. }
  894. void MonstroInstrument::saveSettings( QDomDocument & _doc,
  895. QDomElement & _this )
  896. {
  897. m_osc1Vol.saveSettings( _doc, _this, "o1vol" );
  898. m_osc1Pan.saveSettings( _doc, _this, "o1pan" );
  899. m_osc1Crs.saveSettings( _doc, _this, "o1crs" );
  900. m_osc1Ftl.saveSettings( _doc, _this, "o1ftl" );
  901. m_osc1Ftr.saveSettings( _doc, _this, "o1ftr" );
  902. m_osc1Spo.saveSettings( _doc, _this, "o1spo" );
  903. m_osc1Pw.saveSettings( _doc, _this, "o1pw" );
  904. m_osc1SSR.saveSettings( _doc, _this, "o1ssr" );
  905. m_osc1SSF.saveSettings( _doc, _this, "o1ssf" );
  906. m_osc2Vol.saveSettings( _doc, _this, "o2vol" );
  907. m_osc2Pan.saveSettings( _doc, _this, "o2pan" );
  908. m_osc2Crs.saveSettings( _doc, _this, "o2crs" );
  909. m_osc2Ftl.saveSettings( _doc, _this, "o2ftl" );
  910. m_osc2Ftr.saveSettings( _doc, _this, "o2ftr" );
  911. m_osc2Spo.saveSettings( _doc, _this, "o2spo" );
  912. m_osc2Wave.saveSettings( _doc, _this, "o2wav" );
  913. m_osc2SyncH.saveSettings( _doc, _this, "o2syn" );
  914. m_osc2SyncR.saveSettings( _doc, _this, "o2synr" );
  915. m_osc3Vol.saveSettings( _doc, _this, "o3vol" );
  916. m_osc3Pan.saveSettings( _doc, _this, "o3pan" );
  917. m_osc3Crs.saveSettings( _doc, _this, "o3crs" );
  918. m_osc3Spo.saveSettings( _doc, _this, "o3spo" );
  919. m_osc3Sub.saveSettings( _doc, _this, "o3sub" );
  920. m_osc3Wave1.saveSettings( _doc, _this, "o3wav1" );
  921. m_osc3Wave2.saveSettings( _doc, _this, "o3wav2" );
  922. m_osc3SyncH.saveSettings( _doc, _this, "o3syn" );
  923. m_osc3SyncR.saveSettings( _doc, _this, "o3synr" );
  924. m_lfo1Wave.saveSettings( _doc, _this, "l1wav" );
  925. m_lfo1Att.saveSettings( _doc, _this, "l1att" );
  926. m_lfo1Rate.saveSettings( _doc, _this, "l1rat" );
  927. m_lfo1Phs.saveSettings( _doc, _this, "l1phs" );
  928. m_lfo2Wave.saveSettings( _doc, _this, "l2wav" );
  929. m_lfo2Att.saveSettings( _doc, _this, "l2att" );
  930. m_lfo2Rate.saveSettings( _doc, _this, "l2rat" );
  931. m_lfo2Phs.saveSettings( _doc, _this, "l2phs" );
  932. m_env1Pre.saveSettings( _doc, _this, "e1pre" );
  933. m_env1Att.saveSettings( _doc, _this, "e1att" );
  934. m_env1Hold.saveSettings( _doc, _this, "e1hol" );
  935. m_env1Dec.saveSettings( _doc, _this, "e1dec" );
  936. m_env1Sus.saveSettings( _doc, _this, "e1sus" );
  937. m_env1Rel.saveSettings( _doc, _this, "e1rel" );
  938. m_env1Slope.saveSettings( _doc, _this, "e1slo" );
  939. m_env2Pre.saveSettings( _doc, _this, "e2pre" );
  940. m_env2Att.saveSettings( _doc, _this, "e2att" );
  941. m_env2Hold.saveSettings( _doc, _this, "e2hol" );
  942. m_env2Dec.saveSettings( _doc, _this, "e2dec" );
  943. m_env2Sus.saveSettings( _doc, _this, "e2sus" );
  944. m_env2Rel.saveSettings( _doc, _this, "e2rel" );
  945. m_env2Slope.saveSettings( _doc, _this, "e2slo" );
  946. m_o23Mod.saveSettings( _doc, _this, "o23mo" );
  947. m_vol1env1.saveSettings( _doc, _this, "v1e1" );
  948. m_vol1env2.saveSettings( _doc, _this, "v1e2" );
  949. m_vol1lfo1.saveSettings( _doc, _this, "v1l1" );
  950. m_vol1lfo2.saveSettings( _doc, _this, "v1l2" );
  951. m_vol2env1.saveSettings( _doc, _this, "v2e1" );
  952. m_vol2env2.saveSettings( _doc, _this, "v2e2" );
  953. m_vol2lfo1.saveSettings( _doc, _this, "v2l1" );
  954. m_vol2lfo2.saveSettings( _doc, _this, "v2l2" );
  955. m_vol3env1.saveSettings( _doc, _this, "v3e1" );
  956. m_vol3env2.saveSettings( _doc, _this, "v3e2" );
  957. m_vol3lfo1.saveSettings( _doc, _this, "v3l1" );
  958. m_vol3lfo2.saveSettings( _doc, _this, "v3l2" );
  959. m_phs1env1.saveSettings( _doc, _this, "p1e1" );
  960. m_phs1env2.saveSettings( _doc, _this, "p1e2" );
  961. m_phs1lfo1.saveSettings( _doc, _this, "p1l1" );
  962. m_phs1lfo2.saveSettings( _doc, _this, "p1l2" );
  963. m_phs2env1.saveSettings( _doc, _this, "p2e1" );
  964. m_phs2env2.saveSettings( _doc, _this, "p2e2" );
  965. m_phs2lfo1.saveSettings( _doc, _this, "p2l1" );
  966. m_phs2lfo2.saveSettings( _doc, _this, "p2l2" );
  967. m_phs3env1.saveSettings( _doc, _this, "p3e1" );
  968. m_phs3env2.saveSettings( _doc, _this, "p3e2" );
  969. m_phs3lfo1.saveSettings( _doc, _this, "p3l1" );
  970. m_phs3lfo2.saveSettings( _doc, _this, "p3l2" );
  971. m_pit1env1.saveSettings( _doc, _this, "f1e1" );
  972. m_pit1env2.saveSettings( _doc, _this, "f1e2" );
  973. m_pit1lfo1.saveSettings( _doc, _this, "f1l1" );
  974. m_pit1lfo2.saveSettings( _doc, _this, "f1l2" );
  975. m_pit2env1.saveSettings( _doc, _this, "f2e1" );
  976. m_pit2env2.saveSettings( _doc, _this, "f2e2" );
  977. m_pit2lfo1.saveSettings( _doc, _this, "f2l1" );
  978. m_pit2lfo2.saveSettings( _doc, _this, "f2l2" );
  979. m_pit3env1.saveSettings( _doc, _this, "f3e1" );
  980. m_pit3env2.saveSettings( _doc, _this, "f3e2" );
  981. m_pit3lfo1.saveSettings( _doc, _this, "f3l1" );
  982. m_pit3lfo2.saveSettings( _doc, _this, "f3l2" );
  983. m_pw1env1.saveSettings( _doc, _this, "w1e1" );
  984. m_pw1env2.saveSettings( _doc, _this, "w1e2" );
  985. m_pw1lfo1.saveSettings( _doc, _this, "w1l1" );
  986. m_pw1lfo2.saveSettings( _doc, _this, "w1l2" );
  987. m_sub3env1.saveSettings( _doc, _this, "s3e1" );
  988. m_sub3env2.saveSettings( _doc, _this, "s3e2" );
  989. m_sub3lfo1.saveSettings( _doc, _this, "s3l1" );
  990. m_sub3lfo2.saveSettings( _doc, _this, "s3l2" );
  991. }
  992. void MonstroInstrument::loadSettings( const QDomElement & _this )
  993. {
  994. m_osc1Vol.loadSettings( _this, "o1vol" );
  995. m_osc1Pan.loadSettings( _this, "o1pan" );
  996. m_osc1Crs.loadSettings( _this, "o1crs" );
  997. m_osc1Ftl.loadSettings( _this, "o1ftl" );
  998. m_osc1Ftr.loadSettings( _this, "o1ftr" );
  999. m_osc1Spo.loadSettings( _this, "o1spo" );
  1000. m_osc1Pw.loadSettings( _this, "o1pw" );
  1001. m_osc1SSR.loadSettings( _this, "o1ssr" );
  1002. m_osc1SSF.loadSettings( _this, "o1ssf" );
  1003. m_osc2Vol.loadSettings( _this, "o2vol" );
  1004. m_osc2Pan.loadSettings( _this, "o2pan" );
  1005. m_osc2Crs.loadSettings( _this, "o2crs" );
  1006. m_osc2Ftl.loadSettings( _this, "o2ftl" );
  1007. m_osc2Ftr.loadSettings( _this, "o2ftr" );
  1008. m_osc2Spo.loadSettings( _this, "o2spo" );
  1009. m_osc2Wave.loadSettings( _this, "o2wav" );
  1010. m_osc2SyncH.loadSettings( _this, "o2syn" );
  1011. m_osc2SyncR.loadSettings( _this, "o2synr" );
  1012. m_osc3Vol.loadSettings( _this, "o3vol" );
  1013. m_osc3Pan.loadSettings( _this, "o3pan" );
  1014. m_osc3Crs.loadSettings( _this, "o3crs" );
  1015. m_osc3Spo.loadSettings( _this, "o3spo" );
  1016. m_osc3Sub.loadSettings( _this, "o3sub" );
  1017. m_osc3Wave1.loadSettings( _this, "o3wav1" );
  1018. m_osc3Wave2.loadSettings( _this, "o3wav2" );
  1019. m_osc3SyncH.loadSettings( _this, "o3syn" );
  1020. m_osc3SyncR.loadSettings( _this, "o3synr" );
  1021. m_lfo1Wave.loadSettings( _this, "l1wav" );
  1022. m_lfo1Att.loadSettings( _this, "l1att" );
  1023. m_lfo1Rate.loadSettings( _this, "l1rat" );
  1024. m_lfo1Phs.loadSettings( _this, "l1phs" );
  1025. m_lfo2Wave.loadSettings( _this, "l2wav" );
  1026. m_lfo2Att.loadSettings( _this, "l2att" );
  1027. m_lfo2Rate.loadSettings( _this, "l2rat" );
  1028. m_lfo2Phs.loadSettings( _this, "l2phs" );
  1029. m_env1Pre.loadSettings( _this, "e1pre" );
  1030. m_env1Att.loadSettings( _this, "e1att" );
  1031. m_env1Hold.loadSettings( _this, "e1hol" );
  1032. m_env1Dec.loadSettings( _this, "e1dec" );
  1033. m_env1Sus.loadSettings( _this, "e1sus" );
  1034. m_env1Rel.loadSettings( _this, "e1rel" );
  1035. m_env1Slope.loadSettings( _this, "e1slo" );
  1036. m_env2Pre.loadSettings( _this, "e2pre" );
  1037. m_env2Att.loadSettings( _this, "e2att" );
  1038. m_env2Hold.loadSettings( _this, "e2hol" );
  1039. m_env2Dec.loadSettings( _this, "e2dec" );
  1040. m_env2Sus.loadSettings( _this, "e2sus" );
  1041. m_env2Rel.loadSettings( _this, "e2rel" );
  1042. m_env2Slope.loadSettings( _this, "e2slo" );
  1043. m_o23Mod.loadSettings( _this, "o23mo" );
  1044. m_vol1env1.loadSettings( _this, "v1e1" );
  1045. m_vol1env2.loadSettings( _this, "v1e2" );
  1046. m_vol1lfo1.loadSettings( _this, "v1l1" );
  1047. m_vol1lfo2.loadSettings( _this, "v1l2" );
  1048. m_vol2env1.loadSettings( _this, "v2e1" );
  1049. m_vol2env2.loadSettings( _this, "v2e2" );
  1050. m_vol2lfo1.loadSettings( _this, "v2l1" );
  1051. m_vol2lfo2.loadSettings( _this, "v2l2" );
  1052. m_vol3env1.loadSettings( _this, "v3e1" );
  1053. m_vol3env2.loadSettings( _this, "v3e2" );
  1054. m_vol3lfo1.loadSettings( _this, "v3l1" );
  1055. m_vol3lfo2.loadSettings( _this, "v3l2" );
  1056. m_phs1env1.loadSettings( _this, "p1e1" );
  1057. m_phs1env2.loadSettings( _this, "p1e2" );
  1058. m_phs1lfo1.loadSettings( _this, "p1l1" );
  1059. m_phs1lfo2.loadSettings( _this, "p1l2" );
  1060. m_phs2env1.loadSettings( _this, "p2e1" );
  1061. m_phs2env2.loadSettings( _this, "p2e2" );
  1062. m_phs2lfo1.loadSettings( _this, "p2l1" );
  1063. m_phs2lfo2.loadSettings( _this, "p2l2" );
  1064. m_phs3env1.loadSettings( _this, "p3e1" );
  1065. m_phs3env2.loadSettings( _this, "p3e2" );
  1066. m_phs3lfo1.loadSettings( _this, "p3l1" );
  1067. m_phs3lfo2.loadSettings( _this, "p3l2" );
  1068. m_pit1env1.loadSettings( _this, "f1e1" );
  1069. m_pit1env2.loadSettings( _this, "f1e2" );
  1070. m_pit1lfo1.loadSettings( _this, "f1l1" );
  1071. m_pit1lfo2.loadSettings( _this, "f1l2" );
  1072. m_pit2env1.loadSettings( _this, "f2e1" );
  1073. m_pit2env2.loadSettings( _this, "f2e2" );
  1074. m_pit2lfo1.loadSettings( _this, "f2l1" );
  1075. m_pit2lfo2.loadSettings( _this, "f2l2" );
  1076. m_pit3env1.loadSettings( _this, "f3e1" );
  1077. m_pit3env2.loadSettings( _this, "f3e2" );
  1078. m_pit3lfo1.loadSettings( _this, "f3l1" );
  1079. m_pit3lfo2.loadSettings( _this, "f3l2" );
  1080. m_pw1env1.loadSettings( _this, "w1e1" );
  1081. m_pw1env2.loadSettings( _this, "w1e2" );
  1082. m_pw1lfo1.loadSettings( _this, "w1l1" );
  1083. m_pw1lfo2.loadSettings( _this, "w1l2" );
  1084. m_sub3env1.loadSettings( _this, "s3e1" );
  1085. m_sub3env2.loadSettings( _this, "s3e2" );
  1086. m_sub3lfo1.loadSettings( _this, "s3l1" );
  1087. m_sub3lfo2.loadSettings( _this, "s3l2" );
  1088. }
  1089. QString MonstroInstrument::nodeName() const
  1090. {
  1091. return monstro_plugin_descriptor.name;
  1092. }
  1093. f_cnt_t MonstroInstrument::desiredReleaseFrames() const
  1094. {
  1095. return qMax( 64, qMax( m_env1_relF, m_env2_relF ) );
  1096. }
  1097. PluginView * MonstroInstrument::instantiateView( QWidget * _parent )
  1098. {
  1099. return( new MonstroView( this, _parent ) );
  1100. }
  1101. void MonstroInstrument::updateVolume1()
  1102. {
  1103. m_osc1l_vol = leftCh( m_osc1Vol.value(), m_osc1Pan.value() );
  1104. m_osc1r_vol = rightCh( m_osc1Vol.value(), m_osc1Pan.value() );
  1105. }
  1106. void MonstroInstrument::updateVolume2()
  1107. {
  1108. m_osc2l_vol = leftCh( m_osc2Vol.value(), m_osc2Pan.value() );
  1109. m_osc2r_vol = rightCh( m_osc2Vol.value(), m_osc2Pan.value() );
  1110. }
  1111. void MonstroInstrument::updateVolume3()
  1112. {
  1113. m_osc3l_vol = leftCh( m_osc3Vol.value(), m_osc3Pan.value() );
  1114. m_osc3r_vol = rightCh( m_osc3Vol.value(), m_osc3Pan.value() );
  1115. }
  1116. void MonstroInstrument::updateFreq1()
  1117. {
  1118. m_osc1l_freq = powf( 2.0f, m_osc1Crs.value() / 12.0f ) *
  1119. powf( 2.0f, m_osc1Ftl.value() / 1200.0f );
  1120. m_osc1r_freq = powf( 2.0f, m_osc1Crs.value() / 12.0f ) *
  1121. powf( 2.0f, m_osc1Ftr.value() / 1200.0f );
  1122. }
  1123. void MonstroInstrument::updateFreq2()
  1124. {
  1125. m_osc2l_freq = powf( 2.0f, m_osc2Crs.value() / 12.0f ) *
  1126. powf( 2.0f, m_osc2Ftl.value() / 1200.0f );
  1127. m_osc2r_freq = powf( 2.0f, m_osc2Crs.value() / 12.0f ) *
  1128. powf( 2.0f, m_osc2Ftr.value() / 1200.0f );
  1129. }
  1130. void MonstroInstrument::updateFreq3()
  1131. {
  1132. m_osc3_freq = powf( 2.0f, m_osc3Crs.value() / 12.0f );
  1133. }
  1134. void MonstroInstrument::updatePO1()
  1135. {
  1136. m_osc1l_po = m_osc1Spo.value() / 720.0f;
  1137. m_osc1r_po = ( m_osc1Spo.value() * -1.0 ) / 720.0f;
  1138. }
  1139. void MonstroInstrument::updatePO2()
  1140. {
  1141. m_osc2l_po = m_osc2Spo.value() / 720.0f;
  1142. m_osc2r_po = ( m_osc2Spo.value() * -1.0 ) / 720.0f;
  1143. }
  1144. void MonstroInstrument::updatePO3()
  1145. {
  1146. m_osc3l_po = m_osc3Spo.value() / 720.0f;
  1147. m_osc3r_po = ( m_osc3Spo.value() * -1.0 ) / 720.0f;
  1148. }
  1149. void MonstroInstrument::updateEnvelope1()
  1150. {
  1151. if( m_env1Pre.value() == 0.0f ) m_env1_pre = 1.0;
  1152. else m_env1_pre = 1.0f / ( m_env1Pre.value() / 1000.0f ) / m_samplerate;
  1153. if( m_env1Att.value() == 0.0f ) m_env1_att = 1.0;
  1154. else m_env1_att = 1.0f / ( m_env1Att.value() / 1000.0f ) / m_samplerate;
  1155. if( m_env1Hold.value() == 0.0f ) m_env1_hold = 1.0;
  1156. else m_env1_hold = 1.0f / ( m_env1Hold.value() / 1000.0f ) / m_samplerate;
  1157. if( m_env1Dec.value() == 0.0f ) m_env1_dec = 1.0;
  1158. else m_env1_dec = 1.0f / ( m_env1Dec.value() / 1000.0f ) / m_samplerate;
  1159. if( m_env1Rel.value() == 0.0f ) m_env1_rel = 1.0;
  1160. else m_env1_rel = 1.0f / ( m_env1Rel.value() / 1000.0f ) / m_samplerate;
  1161. m_env1_len = ( m_env1Pre.value() + m_env1Att.value() + m_env1Hold.value() + m_env1Dec.value() ) * m_samplerate / 1000.0f;
  1162. m_env1_relF = m_env1Rel.value() * m_samplerate / 1000.0f;
  1163. }
  1164. void MonstroInstrument::updateEnvelope2()
  1165. {
  1166. if( m_env2Pre.value() == 0.0f ) m_env2_pre = 1.0;
  1167. else m_env2_pre = 1.0f / ( m_env2Pre.value() / 1000.0f ) / m_samplerate;
  1168. if( m_env2Att.value() == 0.0f ) m_env2_att = 1.0;
  1169. else m_env2_att = 1.0f / ( m_env2Att.value() / 1000.0f ) / m_samplerate;
  1170. if( m_env2Hold.value() == 0.0f ) m_env2_hold = 1.0;
  1171. else m_env2_hold = 1.0f / ( m_env2Hold.value() / 1000.0f ) / m_samplerate;
  1172. if( m_env2Dec.value() == 0.0f ) m_env2_dec = 1.0;
  1173. else m_env2_dec = 1.0f / ( m_env2Dec.value() / 1000.0f ) / m_samplerate;
  1174. if( m_env2Rel.value() == 0.0f ) m_env2_rel = 1.0;
  1175. else m_env2_rel = 1.0f / ( m_env2Rel.value() / 1000.0f ) / m_samplerate;
  1176. m_env2_len = ( m_env2Pre.value() + m_env2Att.value() + m_env2Hold.value() + m_env2Dec.value() ) * m_samplerate / 1000.0f;
  1177. m_env2_relF = m_env2Rel.value() * m_samplerate / 1000.0f;
  1178. }
  1179. void MonstroInstrument::updateLFOAtts()
  1180. {
  1181. m_lfo1_att = m_lfo1Att.value() * m_samplerate / 1000.0f;
  1182. m_lfo2_att = m_lfo2Att.value() * m_samplerate / 1000.0f;
  1183. }
  1184. void MonstroInstrument::updateSamplerate()
  1185. {
  1186. m_samplerate = Engine::mixer()->processingSampleRate();
  1187. m_integrator = 0.5f - ( 0.5f - INTEGRATOR ) * 44100.0f / m_samplerate;
  1188. m_fmCorrection = 44100.f / m_samplerate * FM_AMOUNT;
  1189. m_counterMax = ( m_samplerate * 5 ) / 44100;
  1190. updateEnvelope1();
  1191. updateEnvelope2();
  1192. updateLFOAtts();
  1193. }
  1194. void MonstroInstrument::updateSlope1()
  1195. {
  1196. const float slope = m_env1Slope.value();
  1197. m_slope[0] = exp10( slope * -1.0f );
  1198. }
  1199. void MonstroInstrument::updateSlope2()
  1200. {
  1201. const float slope = m_env2Slope.value();
  1202. m_slope[1] = exp10( slope * -1.0f );
  1203. }
  1204. MonstroView::MonstroView( Instrument * _instrument,
  1205. QWidget * _parent ) :
  1206. InstrumentViewFixedSize( _instrument, _parent )
  1207. {
  1208. m_operatorsView = setupOperatorsView( this );
  1209. setWidgetBackground( m_operatorsView, "artwork_op" );
  1210. m_operatorsView->show();
  1211. m_operatorsView->move( 0, 0 );
  1212. m_matrixView = setupMatrixView( this );
  1213. setWidgetBackground( m_matrixView, "artwork_mat" );
  1214. m_matrixView->hide();
  1215. m_matrixView->move( 0, 0 );
  1216. // "tab buttons"
  1217. PixmapButton * m_opViewButton = new PixmapButton( this, NULL );
  1218. m_opViewButton -> move( 0,0 );
  1219. m_opViewButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "opview_active" ) );
  1220. m_opViewButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "opview_inactive" ) );
  1221. ToolTip::add( m_opViewButton, tr( "Operators view" ) );
  1222. PixmapButton * m_matViewButton = new PixmapButton( this, NULL );
  1223. m_matViewButton -> move( 125,0 );
  1224. m_matViewButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "matview_active" ) );
  1225. m_matViewButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "matview_inactive" ) );
  1226. ToolTip::add( m_matViewButton, tr( "Matrix view" ) );
  1227. m_selectedViewGroup = new automatableButtonGroup( this );
  1228. m_selectedViewGroup -> addButton( m_opViewButton );
  1229. m_selectedViewGroup -> addButton( m_matViewButton );
  1230. connect( m_opViewButton, SIGNAL( clicked() ), this, SLOT( updateLayout() ) );
  1231. connect( m_matViewButton, SIGNAL( clicked() ), this, SLOT( updateLayout() ) );
  1232. }
  1233. MonstroView::~MonstroView()
  1234. {
  1235. }
  1236. void MonstroView::updateLayout()
  1237. {
  1238. switch( m_selectedViewGroup->model()->value() )
  1239. {
  1240. case OPVIEW:
  1241. m_operatorsView->show();
  1242. m_matrixView->hide();
  1243. break;
  1244. case MATVIEW:
  1245. m_operatorsView->hide();
  1246. m_matrixView->show();
  1247. break;
  1248. }
  1249. }
  1250. void MonstroView::modelChanged()
  1251. {
  1252. MonstroInstrument * m = castModel<MonstroInstrument>();
  1253. m_osc1VolKnob-> setModel( &m-> m_osc1Vol );
  1254. m_osc1PanKnob-> setModel( &m-> m_osc1Pan );
  1255. m_osc1CrsKnob-> setModel( &m-> m_osc1Crs );
  1256. m_osc1FtlKnob-> setModel( &m-> m_osc1Ftl );
  1257. m_osc1FtrKnob-> setModel( &m-> m_osc1Ftr );
  1258. m_osc1SpoKnob-> setModel( &m-> m_osc1Spo );
  1259. m_osc1PwKnob-> setModel( &m-> m_osc1Pw );
  1260. m_osc1SSRButton-> setModel( &m-> m_osc1SSR );
  1261. m_osc1SSFButton-> setModel( &m-> m_osc1SSF );
  1262. m_osc2VolKnob-> setModel( &m-> m_osc2Vol );
  1263. m_osc2PanKnob-> setModel( &m-> m_osc2Pan );
  1264. m_osc2CrsKnob-> setModel( &m-> m_osc2Crs );
  1265. m_osc2FtlKnob-> setModel( &m-> m_osc2Ftl );
  1266. m_osc2FtrKnob-> setModel( &m-> m_osc2Ftr );
  1267. m_osc2SpoKnob-> setModel( &m-> m_osc2Spo );
  1268. m_osc2WaveBox-> setModel( &m-> m_osc2Wave );
  1269. m_osc2SyncHButton-> setModel( &m-> m_osc2SyncH );
  1270. m_osc2SyncRButton-> setModel( &m-> m_osc2SyncR );
  1271. m_osc3VolKnob-> setModel( &m-> m_osc3Vol );
  1272. m_osc3PanKnob-> setModel( &m-> m_osc3Pan );
  1273. m_osc3CrsKnob-> setModel( &m-> m_osc3Crs );
  1274. m_osc3SpoKnob-> setModel( &m-> m_osc3Spo );
  1275. m_osc3SubKnob-> setModel( &m-> m_osc3Sub );
  1276. m_osc3Wave1Box-> setModel( &m-> m_osc3Wave1 );
  1277. m_osc3Wave2Box-> setModel( &m-> m_osc3Wave2 );
  1278. m_osc3SyncHButton-> setModel( &m-> m_osc3SyncH );
  1279. m_osc3SyncRButton-> setModel( &m-> m_osc3SyncR );
  1280. m_lfo1WaveBox-> setModel( &m-> m_lfo1Wave );
  1281. m_lfo1AttKnob-> setModel( &m-> m_lfo1Att );
  1282. m_lfo1RateKnob-> setModel( &m-> m_lfo1Rate );
  1283. m_lfo1PhsKnob-> setModel( &m-> m_lfo1Phs );
  1284. m_lfo2WaveBox-> setModel( &m-> m_lfo2Wave );
  1285. m_lfo2AttKnob-> setModel( &m-> m_lfo2Att );
  1286. m_lfo2RateKnob-> setModel( &m-> m_lfo2Rate );
  1287. m_lfo2PhsKnob-> setModel( &m-> m_lfo2Phs );
  1288. m_env1PreKnob-> setModel( &m-> m_env1Pre );
  1289. m_env1AttKnob-> setModel( &m-> m_env1Att );
  1290. m_env1HoldKnob-> setModel( &m-> m_env1Hold );
  1291. m_env1DecKnob-> setModel( &m-> m_env1Dec );
  1292. m_env1SusKnob-> setModel( &m-> m_env1Sus );
  1293. m_env1RelKnob-> setModel( &m-> m_env1Rel );
  1294. m_env1SlopeKnob-> setModel( &m-> m_env1Slope );
  1295. m_env2PreKnob-> setModel( &m-> m_env2Pre );
  1296. m_env2AttKnob-> setModel( &m-> m_env2Att );
  1297. m_env2HoldKnob-> setModel( &m-> m_env2Hold );
  1298. m_env2DecKnob-> setModel( &m-> m_env2Dec );
  1299. m_env2SusKnob-> setModel( &m-> m_env2Sus );
  1300. m_env2RelKnob-> setModel( &m-> m_env2Rel );
  1301. m_env2SlopeKnob-> setModel( &m-> m_env2Slope );
  1302. m_o23ModGroup-> setModel( &m-> m_o23Mod );
  1303. m_selectedViewGroup-> setModel( &m-> m_selectedView );
  1304. m_vol1env1Knob-> setModel( &m-> m_vol1env1 );
  1305. m_vol1env2Knob-> setModel( &m-> m_vol1env2 );
  1306. m_vol1lfo1Knob-> setModel( &m-> m_vol1lfo1 );
  1307. m_vol1lfo2Knob-> setModel( &m-> m_vol1lfo2 );
  1308. m_vol2env1Knob-> setModel( &m-> m_vol2env1 );
  1309. m_vol2env2Knob-> setModel( &m-> m_vol2env2 );
  1310. m_vol2lfo1Knob-> setModel( &m-> m_vol2lfo1 );
  1311. m_vol2lfo2Knob-> setModel( &m-> m_vol2lfo2 );
  1312. m_vol3env1Knob-> setModel( &m-> m_vol3env1 );
  1313. m_vol3env2Knob-> setModel( &m-> m_vol3env2 );
  1314. m_vol3lfo1Knob-> setModel( &m-> m_vol3lfo1 );
  1315. m_vol3lfo2Knob-> setModel( &m-> m_vol3lfo2 );
  1316. m_phs1env1Knob-> setModel( &m-> m_phs1env1 );
  1317. m_phs1env2Knob-> setModel( &m-> m_phs1env2 );
  1318. m_phs1lfo1Knob-> setModel( &m-> m_phs1lfo1 );
  1319. m_phs1lfo2Knob-> setModel( &m-> m_phs1lfo2 );
  1320. m_phs2env1Knob-> setModel( &m-> m_phs2env1 );
  1321. m_phs2env2Knob-> setModel( &m-> m_phs2env2 );
  1322. m_phs2lfo1Knob-> setModel( &m-> m_phs2lfo1 );
  1323. m_phs2lfo2Knob-> setModel( &m-> m_phs2lfo2 );
  1324. m_phs3env1Knob-> setModel( &m-> m_phs3env1 );
  1325. m_phs3env2Knob-> setModel( &m-> m_phs3env2 );
  1326. m_phs3lfo1Knob-> setModel( &m-> m_phs3lfo1 );
  1327. m_phs3lfo2Knob-> setModel( &m-> m_phs3lfo2 );
  1328. m_pit1env1Knob-> setModel( &m-> m_pit1env1 );
  1329. m_pit1env2Knob-> setModel( &m-> m_pit1env2 );
  1330. m_pit1lfo1Knob-> setModel( &m-> m_pit1lfo1 );
  1331. m_pit1lfo2Knob-> setModel( &m-> m_pit1lfo2 );
  1332. m_pit2env1Knob-> setModel( &m-> m_pit2env1 );
  1333. m_pit2env2Knob-> setModel( &m-> m_pit2env2 );
  1334. m_pit2lfo1Knob-> setModel( &m-> m_pit2lfo1 );
  1335. m_pit2lfo2Knob-> setModel( &m-> m_pit2lfo2 );
  1336. m_pit3env1Knob-> setModel( &m-> m_pit3env1 );
  1337. m_pit3env2Knob-> setModel( &m-> m_pit3env2 );
  1338. m_pit3lfo1Knob-> setModel( &m-> m_pit3lfo1 );
  1339. m_pit3lfo2Knob-> setModel( &m-> m_pit3lfo2 );
  1340. m_pw1env1Knob-> setModel( &m-> m_pw1env1 );
  1341. m_pw1env2Knob-> setModel( &m-> m_pw1env2 );
  1342. m_pw1lfo1Knob-> setModel( &m-> m_pw1lfo1 );
  1343. m_pw1lfo2Knob-> setModel( &m-> m_pw1lfo2 );
  1344. m_sub3env1Knob-> setModel( &m-> m_sub3env1 );
  1345. m_sub3env2Knob-> setModel( &m-> m_sub3env2 );
  1346. m_sub3lfo1Knob-> setModel( &m-> m_sub3lfo1 );
  1347. m_sub3lfo2Knob-> setModel( &m-> m_sub3lfo2 );
  1348. }
  1349. void MonstroView::setWidgetBackground( QWidget * _widget, const QString & _pic )
  1350. {
  1351. _widget->setAutoFillBackground( true );
  1352. QPalette pal;
  1353. pal.setBrush( _widget->backgroundRole(),
  1354. PLUGIN_NAME::getIconPixmap( _pic.toLatin1().constData() ) );
  1355. _widget->setPalette( pal );
  1356. }
  1357. QWidget * MonstroView::setupOperatorsView( QWidget * _parent )
  1358. {
  1359. // operators view
  1360. QWidget * view = new QWidget( _parent );
  1361. view-> setFixedSize( 250, 250 );
  1362. makeknob( m_osc1VolKnob, KNOBCOL1, O1ROW, tr( "Volume" ), "%", "osc1Knob" )
  1363. makeknob( m_osc1PanKnob, KNOBCOL2, O1ROW, tr( "Panning" ), "", "osc1Knob" )
  1364. makeknob( m_osc1CrsKnob, KNOBCOL3, O1ROW, tr( "Coarse detune" ), tr( " semitones" ), "osc1Knob" )
  1365. makeknob( m_osc1FtlKnob, KNOBCOL4, O1ROW, tr( "Fine tune left" ), tr( " cents" ), "osc1Knob" )
  1366. makeknob( m_osc1FtrKnob, KNOBCOL5, O1ROW, tr( "Fine tune right" ), tr( " cents" ), "osc1Knob" )
  1367. makeknob( m_osc1SpoKnob, KNOBCOL6, O1ROW, tr( "Stereo phase offset" ), tr( " deg" ), "osc1Knob" )
  1368. makeknob( m_osc1PwKnob, KNOBCOL7, O1ROW, tr( "Pulse width" ), "%", "osc1Knob" )
  1369. m_osc1VolKnob -> setVolumeKnob( true );
  1370. maketinyled( m_osc1SSRButton, 230, 34, tr( "Send sync on pulse rise" ) )
  1371. maketinyled( m_osc1SSFButton, 230, 44, tr( "Send sync on pulse fall" ) )
  1372. makeknob( m_osc2VolKnob, KNOBCOL1, O2ROW, tr( "Volume" ), "%", "osc2Knob" )
  1373. makeknob( m_osc2PanKnob, KNOBCOL2, O2ROW, tr( "Panning" ), "", "osc2Knob" )
  1374. makeknob( m_osc2CrsKnob, KNOBCOL3, O2ROW, tr( "Coarse detune" ), tr( " semitones" ), "osc2Knob" )
  1375. makeknob( m_osc2FtlKnob, KNOBCOL4, O2ROW, tr( "Fine tune left" ), tr( " cents" ), "osc2Knob" )
  1376. makeknob( m_osc2FtrKnob, KNOBCOL5, O2ROW, tr( "Fine tune right" ), tr( " cents" ), "osc2Knob" )
  1377. makeknob( m_osc2SpoKnob, KNOBCOL6, O2ROW, tr( "Stereo phase offset" ), tr( " deg" ), "osc2Knob" )
  1378. m_osc2VolKnob -> setVolumeKnob( true );
  1379. m_osc2WaveBox = new ComboBox( view );
  1380. m_osc2WaveBox -> setGeometry( 204, O2ROW + 7, 42, ComboBox::DEFAULT_HEIGHT );
  1381. m_osc2WaveBox->setFont( pointSize<8>( m_osc2WaveBox->font() ) );
  1382. maketinyled( m_osc2SyncHButton, 212, O2ROW - 3, tr( "Hard sync oscillator 2" ) )
  1383. maketinyled( m_osc2SyncRButton, 191, O2ROW - 3, tr( "Reverse sync oscillator 2" ) )
  1384. makeknob( m_osc3VolKnob, KNOBCOL1, O3ROW, tr( "Volume" ), "%", "osc3Knob" )
  1385. makeknob( m_osc3PanKnob, KNOBCOL2, O3ROW, tr( "Panning" ), "", "osc3Knob" )
  1386. makeknob( m_osc3CrsKnob, KNOBCOL3, O3ROW, tr( "Coarse detune" ), tr( " semitones" ), "osc3Knob" )
  1387. makeknob( m_osc3SpoKnob, KNOBCOL4, O3ROW, tr( "Stereo phase offset" ), tr( " deg" ), "osc3Knob" )
  1388. makeknob( m_osc3SubKnob, KNOBCOL5, O3ROW, tr( "Sub-osc mix" ), "", "osc3Knob" )
  1389. m_osc3VolKnob -> setVolumeKnob( true );
  1390. m_osc3Wave1Box = new ComboBox( view );
  1391. m_osc3Wave1Box -> setGeometry( 160, O3ROW + 7, 42, ComboBox::DEFAULT_HEIGHT );
  1392. m_osc3Wave1Box->setFont( pointSize<8>( m_osc3Wave1Box->font() ) );
  1393. m_osc3Wave2Box = new ComboBox( view );
  1394. m_osc3Wave2Box -> setGeometry( 204, O3ROW + 7, 42, ComboBox::DEFAULT_HEIGHT );
  1395. m_osc3Wave2Box->setFont( pointSize<8>( m_osc3Wave2Box->font() ) );
  1396. maketinyled( m_osc3SyncHButton, 212, O3ROW - 3, tr( "Hard sync oscillator 3" ) )
  1397. maketinyled( m_osc3SyncRButton, 191, O3ROW - 3, tr( "Reverse sync oscillator 3" ) )
  1398. m_lfo1WaveBox = new ComboBox( view );
  1399. m_lfo1WaveBox -> setGeometry( 2, LFOROW + 7, 42, ComboBox::DEFAULT_HEIGHT );
  1400. m_lfo1WaveBox->setFont( pointSize<8>( m_lfo1WaveBox->font() ) );
  1401. maketsknob( m_lfo1AttKnob, LFOCOL1, LFOROW, tr( "Attack" ), " ms", "lfoKnob" )
  1402. maketsknob( m_lfo1RateKnob, LFOCOL2, LFOROW, tr( "Rate" ), " ms", "lfoKnob" )
  1403. makeknob( m_lfo1PhsKnob, LFOCOL3, LFOROW, tr( "Phase" ), tr( " deg" ), "lfoKnob" )
  1404. m_lfo2WaveBox = new ComboBox( view );
  1405. m_lfo2WaveBox -> setGeometry( 127, LFOROW + 7, 42, ComboBox::DEFAULT_HEIGHT );
  1406. m_lfo2WaveBox->setFont( pointSize<8>( m_lfo2WaveBox->font() ) );
  1407. maketsknob( m_lfo2AttKnob, LFOCOL4, LFOROW, tr( "Attack" ), " ms", "lfoKnob" )
  1408. maketsknob( m_lfo2RateKnob, LFOCOL5, LFOROW, tr( "Rate" ), " ms", "lfoKnob" )
  1409. makeknob( m_lfo2PhsKnob, LFOCOL6, LFOROW, tr( "Phase" ), tr( " deg" ), "lfoKnob" )
  1410. maketsknob( m_env1PreKnob, KNOBCOL1, E1ROW, tr( "Pre-delay" ), " ms", "envKnob" )
  1411. maketsknob( m_env1AttKnob, KNOBCOL2, E1ROW, tr( "Attack" ), " ms", "envKnob" )
  1412. maketsknob( m_env1HoldKnob, KNOBCOL3, E1ROW, tr( "Hold" ), " ms", "envKnob" )
  1413. maketsknob( m_env1DecKnob, KNOBCOL4, E1ROW, tr( "Decay" ), " ms", "envKnob" )
  1414. makeknob( m_env1SusKnob, KNOBCOL5, E1ROW, tr( "Sustain" ), "", "envKnob" )
  1415. maketsknob( m_env1RelKnob, KNOBCOL6, E1ROW, tr( "Release" ), " ms", "envKnob" )
  1416. makeknob( m_env1SlopeKnob, KNOBCOL7, E1ROW, tr( "Slope" ), "", "envKnob" )
  1417. maketsknob( m_env2PreKnob, KNOBCOL1, E2ROW, tr( "Pre-delay" ), " ms", "envKnob" )
  1418. maketsknob( m_env2AttKnob, KNOBCOL2, E2ROW, tr( "Attack" ), " ms", "envKnob" )
  1419. maketsknob( m_env2HoldKnob, KNOBCOL3, E2ROW, tr( "Hold" ), " ms", "envKnob" )
  1420. maketsknob( m_env2DecKnob, KNOBCOL4, E2ROW, tr( "Decay" ), " ms", "envKnob" )
  1421. makeknob( m_env2SusKnob, KNOBCOL5, E2ROW, tr( "Sustain" ), "", "envKnob" )
  1422. maketsknob( m_env2RelKnob, KNOBCOL6, E2ROW, tr( "Release" ), " ms", "envKnob" )
  1423. makeknob( m_env2SlopeKnob, KNOBCOL7, E2ROW, tr( "Slope" ), "", "envKnob" )
  1424. // mod selector
  1425. PixmapButton * m_mixButton = new PixmapButton( view, NULL );
  1426. m_mixButton -> move( 225, 185 );
  1427. m_mixButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "mix_active" ) );
  1428. m_mixButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "mix_inactive" ) );
  1429. ToolTip::add( m_mixButton, tr( "Mix osc 2 with osc 3" ) );
  1430. PixmapButton * m_amButton = new PixmapButton( view, NULL );
  1431. m_amButton -> move( 225, 185 + 15 );
  1432. m_amButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "am_active" ) );
  1433. m_amButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "am_inactive" ) );
  1434. ToolTip::add( m_amButton, tr( "Modulate amplitude of osc 3 by osc 2" ) );
  1435. PixmapButton * m_fmButton = new PixmapButton( view, NULL );
  1436. m_fmButton -> move( 225, 185 + 15*2 );
  1437. m_fmButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "fm_active" ) );
  1438. m_fmButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "fm_inactive" ) );
  1439. ToolTip::add( m_fmButton, tr( "Modulate frequency of osc 3 by osc 2" ) );
  1440. PixmapButton * m_pmButton = new PixmapButton( view, NULL );
  1441. m_pmButton -> move( 225, 185 + 15*3 );
  1442. m_pmButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "pm_active" ) );
  1443. m_pmButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "pm_inactive" ) );
  1444. ToolTip::add( m_pmButton, tr( "Modulate phase of osc 3 by osc 2" ) );
  1445. m_o23ModGroup = new automatableButtonGroup( view );
  1446. m_o23ModGroup-> addButton( m_mixButton );
  1447. m_o23ModGroup-> addButton( m_amButton );
  1448. m_o23ModGroup-> addButton( m_fmButton );
  1449. m_o23ModGroup-> addButton( m_pmButton );
  1450. return( view );
  1451. }
  1452. QWidget * MonstroView::setupMatrixView( QWidget * _parent )
  1453. {
  1454. // matrix view
  1455. QWidget * view = new QWidget( _parent );
  1456. view-> setFixedSize( 250, 250 );
  1457. makeknob( m_vol1env1Knob, MATCOL1, MATROW1, tr( "Modulation amount" ), "", "matrixKnob" )
  1458. makeknob( m_vol1env2Knob, MATCOL2, MATROW1, tr( "Modulation amount" ), "", "matrixKnob" )
  1459. makeknob( m_vol1lfo1Knob, MATCOL3, MATROW1, tr( "Modulation amount" ), "", "matrixKnob" )
  1460. makeknob( m_vol1lfo2Knob, MATCOL4, MATROW1, tr( "Modulation amount" ), "", "matrixKnob" )
  1461. makeknob( m_vol2env1Knob, MATCOL1, MATROW3, tr( "Modulation amount" ), "", "matrixKnob" )
  1462. makeknob( m_vol2env2Knob, MATCOL2, MATROW3, tr( "Modulation amount" ), "", "matrixKnob" )
  1463. makeknob( m_vol2lfo1Knob, MATCOL3, MATROW3, tr( "Modulation amount" ), "", "matrixKnob" )
  1464. makeknob( m_vol2lfo2Knob, MATCOL4, MATROW3, tr( "Modulation amount" ), "", "matrixKnob" )
  1465. makeknob( m_vol3env1Knob, MATCOL1, MATROW5, tr( "Modulation amount" ), "", "matrixKnob" )
  1466. makeknob( m_vol3env2Knob, MATCOL2, MATROW5, tr( "Modulation amount" ), "", "matrixKnob" )
  1467. makeknob( m_vol3lfo1Knob, MATCOL3, MATROW5, tr( "Modulation amount" ), "", "matrixKnob" )
  1468. makeknob( m_vol3lfo2Knob, MATCOL4, MATROW5, tr( "Modulation amount" ), "", "matrixKnob" )
  1469. makeknob( m_phs1env1Knob, MATCOL1, MATROW2, tr( "Modulation amount" ), "", "matrixKnob" )
  1470. makeknob( m_phs1env2Knob, MATCOL2, MATROW2, tr( "Modulation amount" ), "", "matrixKnob" )
  1471. makeknob( m_phs1lfo1Knob, MATCOL3, MATROW2, tr( "Modulation amount" ), "", "matrixKnob" )
  1472. makeknob( m_phs1lfo2Knob, MATCOL4, MATROW2, tr( "Modulation amount" ), "", "matrixKnob" )
  1473. makeknob( m_phs2env1Knob, MATCOL1, MATROW4, tr( "Modulation amount" ), "", "matrixKnob" )
  1474. makeknob( m_phs2env2Knob, MATCOL2, MATROW4, tr( "Modulation amount" ), "", "matrixKnob" )
  1475. makeknob( m_phs2lfo1Knob, MATCOL3, MATROW4, tr( "Modulation amount" ), "", "matrixKnob" )
  1476. makeknob( m_phs2lfo2Knob, MATCOL4, MATROW4, tr( "Modulation amount" ), "", "matrixKnob" )
  1477. makeknob( m_phs3env1Knob, MATCOL1, MATROW6, tr( "Modulation amount" ), "", "matrixKnob" )
  1478. makeknob( m_phs3env2Knob, MATCOL2, MATROW6, tr( "Modulation amount" ), "", "matrixKnob" )
  1479. makeknob( m_phs3lfo1Knob, MATCOL3, MATROW6, tr( "Modulation amount" ), "", "matrixKnob" )
  1480. makeknob( m_phs3lfo2Knob, MATCOL4, MATROW6, tr( "Modulation amount" ), "", "matrixKnob" )
  1481. makeknob( m_pit1env1Knob, MATCOL5, MATROW1, tr( "Modulation amount" ), "", "matrixKnob" )
  1482. makeknob( m_pit1env2Knob, MATCOL6, MATROW1, tr( "Modulation amount" ), "", "matrixKnob" )
  1483. makeknob( m_pit1lfo1Knob, MATCOL7, MATROW1, tr( "Modulation amount" ), "", "matrixKnob" )
  1484. makeknob( m_pit1lfo2Knob, MATCOL8, MATROW1, tr( "Modulation amount" ), "", "matrixKnob" )
  1485. makeknob( m_pit2env1Knob, MATCOL5, MATROW3, tr( "Modulation amount" ), "", "matrixKnob" )
  1486. makeknob( m_pit2env2Knob, MATCOL6, MATROW3, tr( "Modulation amount" ), "", "matrixKnob" )
  1487. makeknob( m_pit2lfo1Knob, MATCOL7, MATROW3, tr( "Modulation amount" ), "", "matrixKnob" )
  1488. makeknob( m_pit2lfo2Knob, MATCOL8, MATROW3, tr( "Modulation amount" ), "", "matrixKnob" )
  1489. makeknob( m_pit3env1Knob, MATCOL5, MATROW5, tr( "Modulation amount" ), "", "matrixKnob" )
  1490. makeknob( m_pit3env2Knob, MATCOL6, MATROW5, tr( "Modulation amount" ), "", "matrixKnob" )
  1491. makeknob( m_pit3lfo1Knob, MATCOL7, MATROW5, tr( "Modulation amount" ), "", "matrixKnob" )
  1492. makeknob( m_pit3lfo2Knob, MATCOL8, MATROW5, tr( "Modulation amount" ), "", "matrixKnob" )
  1493. makeknob( m_pw1env1Knob, MATCOL5, MATROW2, tr( "Modulation amount" ), "", "matrixKnob" )
  1494. makeknob( m_pw1env2Knob, MATCOL6, MATROW2, tr( "Modulation amount" ), "", "matrixKnob" )
  1495. makeknob( m_pw1lfo1Knob, MATCOL7, MATROW2, tr( "Modulation amount" ), "", "matrixKnob" )
  1496. makeknob( m_pw1lfo2Knob, MATCOL8, MATROW2, tr( "Modulation amount" ), "", "matrixKnob" )
  1497. makeknob( m_sub3env1Knob, MATCOL5, MATROW6, tr( "Modulation amount" ), "", "matrixKnob" )
  1498. makeknob( m_sub3env2Knob, MATCOL6, MATROW6, tr( "Modulation amount" ), "", "matrixKnob" )
  1499. makeknob( m_sub3lfo1Knob, MATCOL7, MATROW6, tr( "Modulation amount" ), "", "matrixKnob" )
  1500. makeknob( m_sub3lfo2Knob, MATCOL8, MATROW6, tr( "Modulation amount" ), "", "matrixKnob" )
  1501. return( view );
  1502. }
  1503. extern "C"
  1504. {
  1505. // necessary for getting instance out of shared lib
  1506. PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * )
  1507. {
  1508. return new MonstroInstrument( static_cast<InstrumentTrack *>( m ) );
  1509. }
  1510. }