1 /* 2 * TripleOscillator.h - declaration of class TripleOscillator a powerful 3 * instrument-plugin with 3 oscillators 4 * 5 * Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net> 6 * 7 * This file is part of LMMS - https://lmms.io 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public 11 * License as published by the Free Software Foundation; either 12 * version 2 of the License, or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public 20 * License along with this program (see COPYING); if not, write to the 21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 22 * Boston, MA 02110-1301 USA. 23 * 24 */ 25 26 #ifndef _TRIPLE_OSCILLATOR_H 27 #define _TRIPLE_OSCILLATOR_H 28 29 #include "Instrument.h" 30 #include "InstrumentView.h" 31 #include "Oscillator.h" 32 #include "AutomatableModel.h" 33 34 35 class automatableButtonGroup; 36 class Knob; 37 class NotePlayHandle; 38 class PixmapButton; 39 class SampleBuffer; 40 41 const int NUM_OF_OSCILLATORS = 3; 42 43 44 class OscillatorObject : public Model 45 { 46 MM_OPERATORS 47 Q_OBJECT 48 public: 49 OscillatorObject( Model * _parent, int _idx ); 50 virtual ~OscillatorObject(); 51 52 53 private: 54 FloatModel m_volumeModel; 55 FloatModel m_panModel; 56 FloatModel m_coarseModel; 57 FloatModel m_fineLeftModel; 58 FloatModel m_fineRightModel; 59 FloatModel m_phaseOffsetModel; 60 FloatModel m_stereoPhaseDetuningModel; 61 IntModel m_waveShapeModel; 62 IntModel m_modulationAlgoModel; 63 SampleBuffer* m_sampleBuffer; 64 65 float m_volumeLeft; 66 float m_volumeRight; 67 68 // normalized detuning -> x/sampleRate 69 float m_detuningLeft; 70 float m_detuningRight; 71 // normalized offset -> x/360 72 float m_phaseOffsetLeft; 73 float m_phaseOffsetRight; 74 75 friend class TripleOscillator; 76 friend class TripleOscillatorView; 77 78 79 private slots: 80 void oscUserDefWaveDblClick(); 81 82 void updateVolume(); 83 void updateDetuningLeft(); 84 void updateDetuningRight(); 85 void updatePhaseOffsetLeft(); 86 void updatePhaseOffsetRight(); 87 88 } ; 89 90 91 92 93 class TripleOscillator : public Instrument 94 { 95 Q_OBJECT 96 public: 97 TripleOscillator( InstrumentTrack * _track ); 98 virtual ~TripleOscillator(); 99 100 virtual void playNote( NotePlayHandle * _n, 101 sampleFrame * _working_buffer ); 102 virtual void deleteNotePluginData( NotePlayHandle * _n ); 103 104 105 virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); 106 virtual void loadSettings( const QDomElement & _this ); 107 108 virtual QString nodeName() const; 109 desiredReleaseFrames()110 virtual f_cnt_t desiredReleaseFrames() const 111 { 112 return( 128 ); 113 } 114 115 virtual PluginView * instantiateView( QWidget * _parent ); 116 117 118 protected slots: 119 void updateAllDetuning(); 120 121 122 private: 123 OscillatorObject * m_osc[NUM_OF_OSCILLATORS]; 124 125 struct oscPtr 126 { 127 MM_OPERATORS 128 Oscillator * oscLeft; 129 Oscillator * oscRight; 130 } ; 131 132 133 friend class TripleOscillatorView; 134 135 } ; 136 137 138 139 class TripleOscillatorView : public InstrumentView 140 { 141 Q_OBJECT 142 public: 143 TripleOscillatorView( Instrument * _instrument, QWidget * _parent ); 144 virtual ~TripleOscillatorView(); 145 146 147 private: 148 virtual void modelChanged(); 149 150 automatableButtonGroup * m_mod1BtnGrp; 151 automatableButtonGroup * m_mod2BtnGrp; 152 153 struct OscillatorKnobs 154 { 155 MM_OPERATORS OscillatorKnobsOscillatorKnobs156 OscillatorKnobs( Knob * v, 157 Knob * p, 158 Knob * c, 159 Knob * fl, 160 Knob * fr, 161 Knob * po, 162 Knob * spd, 163 PixmapButton * uwb, 164 automatableButtonGroup * wsbg ) : 165 m_volKnob( v ), 166 m_panKnob( p ), 167 m_coarseKnob( c ), 168 m_fineLeftKnob( fl ), 169 m_fineRightKnob( fr ), 170 m_phaseOffsetKnob( po ), 171 m_stereoPhaseDetuningKnob( spd ), 172 m_userWaveButton( uwb ), 173 m_waveShapeBtnGrp( wsbg ) 174 { 175 } OscillatorKnobsOscillatorKnobs176 OscillatorKnobs() 177 { 178 } 179 Knob * m_volKnob; 180 Knob * m_panKnob; 181 Knob * m_coarseKnob; 182 Knob * m_fineLeftKnob; 183 Knob * m_fineRightKnob; 184 Knob * m_phaseOffsetKnob; 185 Knob * m_stereoPhaseDetuningKnob; 186 PixmapButton * m_userWaveButton; 187 automatableButtonGroup * m_waveShapeBtnGrp; 188 189 } ; 190 191 OscillatorKnobs m_oscKnobs[NUM_OF_OSCILLATORS]; 192 } ; 193 194 195 196 #endif 197