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.

108 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 ExecuteCommands();
  43. virtual void StreamOut(std::ostream &s);
  44. virtual void StreamIn(std::istream &s);
  45. bool GetNoteCut() { return m_NoteCut; }
  46. int GetCurrent() { return m_Current; }
  47. float GetStepTime() { return m_StepTime; }
  48. Pattern* GetPattern() { return &m_Matrix[m_Current]; }
  49. int GetPatSeq(int n) { return m_PatSeq[n]; }
  50. enum GUICommands{NONE,MAT_LENGTH,MAT_SPEED,MAT_ACTIVATE,MAT_DEACTIVATE,
  51. MAT_OCTAVE,COPY,PASTE,CLEAR,TUP,TDOWN,MAT_VOLUME,
  52. SET_CURRENT,SET_PATSEQ};
  53. struct GUIArgs
  54. {
  55. int Num;
  56. int Length;
  57. float Speed;
  58. int X,Y;
  59. int Octave;
  60. float Volume;
  61. };
  62. private:
  63. GUIArgs m_GUIArgs;
  64. void PastePattern();
  65. void ClearPattern();
  66. void TransposeUp();
  67. bool CanTransposeUp();
  68. void TransposeDown();
  69. bool CanTransposeDown();
  70. float m_TickTime;
  71. float m_StepTime;
  72. float m_Time;
  73. int m_Step;
  74. bool m_Loop;
  75. bool m_NoteCut;
  76. int m_Current;
  77. int m_GUICurrent;
  78. Pattern m_Matrix[NUM_PATTERNS];
  79. float m_TriggerLevel[MATY];
  80. int m_PatSeq[NUM_PATSEQ];
  81. int m_CurPatSeq;
  82. float m_CurrentNoteCV;
  83. float m_CurrentTriggerCV;
  84. bool m_Triggered;
  85. bool m_ClockHigh;
  86. int m_CopyPattern;
  87. bool m_PatAdvance;
  88. bool m_PatReset;
  89. };
  90. #endif