TripleOscillator.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. #ifndef _TRIPLE_OSCILLATOR_H
  26. #define _TRIPLE_OSCILLATOR_H
  27. #include "Instrument.h"
  28. #include "InstrumentView.h"
  29. #include "Oscillator.h"
  30. #include "AutomatableModel.h"
  31. class automatableButtonGroup;
  32. class Knob;
  33. class NotePlayHandle;
  34. class PixmapButton;
  35. class SampleBuffer;
  36. const int NUM_OF_OSCILLATORS = 3;
  37. class OscillatorObject : public Model
  38. {
  39. MM_OPERATORS
  40. Q_OBJECT
  41. public:
  42. OscillatorObject( Model * _parent, int _idx );
  43. virtual ~OscillatorObject();
  44. private:
  45. FloatModel m_volumeModel;
  46. FloatModel m_panModel;
  47. FloatModel m_coarseModel;
  48. FloatModel m_fineLeftModel;
  49. FloatModel m_fineRightModel;
  50. FloatModel m_phaseOffsetModel;
  51. FloatModel m_stereoPhaseDetuningModel;
  52. IntModel m_waveShapeModel;
  53. IntModel m_modulationAlgoModel;
  54. SampleBuffer* m_sampleBuffer;
  55. float m_volumeLeft;
  56. float m_volumeRight;
  57. // normalized detuning -> x/sampleRate
  58. float m_detuningLeft;
  59. float m_detuningRight;
  60. // normalized offset -> x/360
  61. float m_phaseOffsetLeft;
  62. float m_phaseOffsetRight;
  63. friend class TripleOscillator;
  64. friend class TripleOscillatorView;
  65. private slots:
  66. void oscUserDefWaveDblClick();
  67. void updateVolume();
  68. void updateDetuningLeft();
  69. void updateDetuningRight();
  70. void updatePhaseOffsetLeft();
  71. void updatePhaseOffsetRight();
  72. } ;
  73. class TripleOscillator : public Instrument
  74. {
  75. Q_OBJECT
  76. public:
  77. TripleOscillator( InstrumentTrack * _track );
  78. virtual ~TripleOscillator();
  79. virtual void playNote( NotePlayHandle * _n,
  80. sampleFrame * _working_buffer );
  81. virtual void deleteNotePluginData( NotePlayHandle * _n );
  82. virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
  83. virtual void loadSettings( const QDomElement & _this );
  84. virtual QString nodeName() const;
  85. virtual f_cnt_t desiredReleaseFrames() const
  86. {
  87. return( 128 );
  88. }
  89. virtual PluginView * instantiateView( QWidget * _parent );
  90. protected slots:
  91. void updateAllDetuning();
  92. private:
  93. OscillatorObject * m_osc[NUM_OF_OSCILLATORS];
  94. struct oscPtr
  95. {
  96. MM_OPERATORS
  97. Oscillator * oscLeft;
  98. Oscillator * oscRight;
  99. } ;
  100. friend class TripleOscillatorView;
  101. } ;
  102. class TripleOscillatorView : public InstrumentViewFixedSize
  103. {
  104. Q_OBJECT
  105. public:
  106. TripleOscillatorView( Instrument * _instrument, QWidget * _parent );
  107. virtual ~TripleOscillatorView();
  108. private:
  109. virtual void modelChanged();
  110. automatableButtonGroup * m_mod1BtnGrp;
  111. automatableButtonGroup * m_mod2BtnGrp;
  112. struct OscillatorKnobs
  113. {
  114. MM_OPERATORS
  115. OscillatorKnobs( Knob * v,
  116. Knob * p,
  117. Knob * c,
  118. Knob * fl,
  119. Knob * fr,
  120. Knob * po,
  121. Knob * spd,
  122. PixmapButton * uwb,
  123. automatableButtonGroup * wsbg ) :
  124. m_volKnob( v ),
  125. m_panKnob( p ),
  126. m_coarseKnob( c ),
  127. m_fineLeftKnob( fl ),
  128. m_fineRightKnob( fr ),
  129. m_phaseOffsetKnob( po ),
  130. m_stereoPhaseDetuningKnob( spd ),
  131. m_userWaveButton( uwb ),
  132. m_waveShapeBtnGrp( wsbg )
  133. {
  134. }
  135. OscillatorKnobs()
  136. {
  137. }
  138. Knob * m_volKnob;
  139. Knob * m_panKnob;
  140. Knob * m_coarseKnob;
  141. Knob * m_fineLeftKnob;
  142. Knob * m_fineRightKnob;
  143. Knob * m_phaseOffsetKnob;
  144. Knob * m_stereoPhaseDetuningKnob;
  145. PixmapButton * m_userWaveButton;
  146. automatableButtonGroup * m_waveShapeBtnGrp;
  147. } ;
  148. OscillatorKnobs m_oscKnobs[NUM_OF_OSCILLATORS];
  149. } ;
  150. #endif