bit_invader.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * bit_invader.h - declaration of class bitInvader and bSynth which
  3. * are a wavetable synthesizer
  4. *
  5. * Copyright (c) 2006-2008 Andreas Brandmaier <andy/at/brandmaier/dot/de>
  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 BIT_INVADER_H
  26. #define BIT_INVADER_H
  27. #include "Instrument.h"
  28. #include "InstrumentView.h"
  29. #include "Graph.h"
  30. #include "Knob.h"
  31. #include "PixmapButton.h"
  32. #include "LedCheckbox.h"
  33. #include "MemoryManager.h"
  34. class oscillator;
  35. class bitInvaderView;
  36. class bSynth
  37. {
  38. MM_OPERATORS
  39. public:
  40. bSynth( float * sample, NotePlayHandle * _nph,
  41. bool _interpolation, float factor,
  42. const sample_rate_t _sample_rate );
  43. virtual ~bSynth();
  44. sample_t nextStringSample( float sample_length );
  45. private:
  46. int sample_index;
  47. float sample_realindex;
  48. float* sample_shape;
  49. NotePlayHandle* nph;
  50. const sample_rate_t sample_rate;
  51. bool interpolation;
  52. } ;
  53. class bitInvader : public Instrument
  54. {
  55. Q_OBJECT
  56. public:
  57. bitInvader(InstrumentTrack * _instrument_track );
  58. virtual ~bitInvader();
  59. virtual void playNote( NotePlayHandle * _n,
  60. sampleFrame * _working_buffer );
  61. virtual void deleteNotePluginData( NotePlayHandle * _n );
  62. virtual void saveSettings( QDomDocument & _doc,
  63. QDomElement & _parent );
  64. virtual void loadSettings( const QDomElement & _this );
  65. virtual QString nodeName() const;
  66. virtual f_cnt_t desiredReleaseFrames() const
  67. {
  68. return( 64 );
  69. }
  70. virtual PluginView * instantiateView( QWidget * _parent );
  71. protected slots:
  72. void lengthChanged();
  73. void samplesChanged( int, int );
  74. void normalize();
  75. private:
  76. FloatModel m_sampleLength;
  77. graphModel m_graph;
  78. BoolModel m_interpolation;
  79. BoolModel m_normalize;
  80. float m_normalizeFactor;
  81. friend class bitInvaderView;
  82. } ;
  83. class bitInvaderView : public InstrumentViewFixedSize
  84. {
  85. Q_OBJECT
  86. public:
  87. bitInvaderView( Instrument * _instrument,
  88. QWidget * _parent );
  89. virtual ~bitInvaderView() {};
  90. protected slots:
  91. //void sampleSizeChanged( float _new_sample_length );
  92. void interpolationToggled( bool value );
  93. void normalizeToggled( bool value );
  94. void sinWaveClicked();
  95. void triangleWaveClicked();
  96. void sqrWaveClicked();
  97. void sawWaveClicked();
  98. void noiseWaveClicked();
  99. void usrWaveClicked();
  100. void smoothClicked( void );
  101. private:
  102. virtual void modelChanged();
  103. Knob * m_sampleLengthKnob;
  104. PixmapButton * m_sinWaveBtn;
  105. PixmapButton * m_triangleWaveBtn;
  106. PixmapButton * m_sqrWaveBtn;
  107. PixmapButton * m_sawWaveBtn;
  108. PixmapButton * m_whiteNoiseWaveBtn;
  109. PixmapButton * m_smoothBtn;
  110. PixmapButton * m_usrWaveBtn;
  111. static QPixmap * s_artwork;
  112. Graph * m_graph;
  113. LedCheckBox * m_interpolationToggle;
  114. LedCheckBox * m_normalizeToggle;
  115. } ;
  116. #endif