You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.6KB

  1. /* SpiralSound
  2. * Copyleft (C) 2001 David Griffiths <dave@pawfal.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include "../SpiralPlugin.h"
  19. #include <FL/Fl_Pixmap.H>
  20. #ifndef MatrixPLUGIN
  21. #define MatrixPLUGIN
  22. static const int MATX = 64;
  23. static const int MATY = 32;
  24. static const int NUM_PATTERNS = 16;
  25. static const int NUM_PATSEQ = 16;
  26. struct Pattern
  27. {
  28. int Length;
  29. float Speed;
  30. int Octave;
  31. float Volume[MATX][MATY];
  32. bool Matrix[MATX][MATY];
  33. };
  34. class MatrixPlugin : public SpiralPlugin
  35. {
  36. public:
  37. MatrixPlugin();
  38. virtual ~MatrixPlugin();
  39. virtual PluginInfo &Initialise(const HostInfo *Host);
  40. virtual SpiralGUIType *CreateGUI();
  41. virtual void Execute();
  42. virtual void Reset();
  43. virtual void ExecuteCommands();
  44. virtual void StreamOut(std::ostream &s);
  45. virtual void StreamIn(std::istream &s);
  46. bool GetNoteCut() { return m_NoteCut; }
  47. int GetCurrent() { return m_Current; }
  48. float GetStepTime() { return m_StepTime; }
  49. Pattern* GetPattern() { return &m_Matrix[m_Current]; }
  50. int GetPatSeq(int n) { return m_PatSeq[n]; }
  51. enum GUICommands{NONE,MAT_LENGTH,MAT_SPEED,MAT_ACTIVATE,MAT_DEACTIVATE,
  52. MAT_OCTAVE,COPY,PASTE,CLEAR,TUP,TDOWN,MAT_VOLUME,
  53. SET_CURRENT,SET_PATSEQ};
  54. struct GUIArgs
  55. {
  56. int Num;
  57. int Length;
  58. float Speed;
  59. int X,Y;
  60. int Octave;
  61. float Volume;
  62. };
  63. private:
  64. GUIArgs m_GUIArgs;
  65. void PastePattern();
  66. void ClearPattern();
  67. void TransposeUp();
  68. bool CanTransposeUp();
  69. void TransposeDown();
  70. bool CanTransposeDown();
  71. float m_TickTime;
  72. float m_StepTime;
  73. float m_Time;
  74. int m_Step;
  75. bool m_Loop;
  76. bool m_NoteCut;
  77. int m_Current;
  78. int m_GUICurrent;
  79. Pattern m_Matrix[NUM_PATTERNS];
  80. float m_TriggerLevel[MATY];
  81. int m_PatSeq[NUM_PATSEQ];
  82. int m_CurPatSeq;
  83. float m_CurrentNoteCV;
  84. float m_CurrentTriggerCV;
  85. bool m_Triggered;
  86. bool m_ClockHigh;
  87. int m_CopyPattern;
  88. bool m_PatAdvance;
  89. bool m_PatReset;
  90. };
  91. #endif