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.

168 lines
5.5KB

  1. /* SpiralPlugin
  2. * Copyleft (C) 2000 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 <FL/Fl.H>
  19. #include <FL/Fl_Window.H>
  20. #include <FL/Fl_Group.H>
  21. #include <FL/Fl_Counter.H>
  22. #include "PoshSamplerPlugin.h"
  23. #include "../SpiralPluginGUI.h"
  24. #include "../Widgets/Fl_Knob.H"
  25. #ifndef MixerGUI
  26. #define MixerGUI
  27. class Fl_WaveDisplay : public Fl_Widget
  28. {
  29. public:
  30. Fl_WaveDisplay(int x,int y,int w,int h, char* Name);
  31. ~Fl_WaveDisplay();
  32. virtual void draw();
  33. virtual int handle(int event);
  34. void SetSample(const float* s, long len);
  35. long GetRangeStart() { return m_StartPos; }
  36. long GetRangeEnd() { return m_EndPos; }
  37. long GetViewStart() { return m_ViewStart; }
  38. void SetViewStart(long s) { m_ViewStart=s; }
  39. long GetViewEnd() { return m_ViewEnd; }
  40. void SetViewEnd(long s) { m_ViewEnd=s; }
  41. void SetPlayPos(long s) { m_PlayPos=s; if(m_PosMarker) redraw(); }
  42. void SetPlayStart(long s) { m_PlayStart=s; }
  43. long GetPlayStart() { return m_PlayStart; }
  44. void SetLoopStart(long s) { m_LoopStart=s; }
  45. long GetLoopStart() { return m_LoopStart; }
  46. void SetLoopEnd(long s) { m_LoopEnd=s; }
  47. long GetLoopEnd() { return m_LoopEnd; }
  48. void SetPosMarker(bool s) { m_PosMarker=s; }
  49. void ZoomIn();
  50. void ZoomOut();
  51. void SetColours (unsigned b, unsigned f, unsigned s, unsigned i, unsigned m) {
  52. m_BGColour=(Fl_Color)b; m_FGColour=(Fl_Color)f; m_SelColour=(Fl_Color)s;
  53. m_IndColour=(Fl_Color)i; m_MrkColour=(Fl_Color)m;
  54. }
  55. private:
  56. Fl_Color m_BGColour, m_FGColour, m_SelColour, m_IndColour, m_MrkColour;
  57. Sample *m_Sample;
  58. long m_StartPos;
  59. long m_EndPos;
  60. long m_ViewStart;
  61. long m_ViewEnd;
  62. long m_PlayPos;
  63. long m_PlayStart;
  64. long m_LoopStart;
  65. long m_LoopEnd;
  66. bool m_PosMarker;
  67. };
  68. class PoshSamplerPluginGUI : public SpiralPluginGUI
  69. {
  70. public:
  71. PoshSamplerPluginGUI(int w, int h, PoshSamplerPlugin *o,ChannelHandler *ch, const HostInfo *Info);
  72. virtual void UpdateValues(SpiralPlugin *o);
  73. virtual void Update();
  74. void SetPlayPos(long s) { m_Display->SetPlayPos(s); }
  75. int GetCurrentSample() { return (int)m_SampleNum->value(); }
  76. protected:
  77. const string GetHelpText(const string &loc);
  78. private:
  79. void UpdateSampleDisplay(int num);
  80. char m_TextBuf[256];
  81. int Numbers[NUM_SAMPLES];
  82. bool m_UpdateMe;
  83. Fl_Button* m_Load;
  84. Fl_Button* m_Save;
  85. Fl_Button* m_PosMarker;
  86. Fl_Knob* m_Volume;
  87. Fl_Knob* m_Pitch;
  88. Fl_Knob* m_Octave;
  89. Fl_Button* m_Loop;
  90. Fl_Button* m_PingPong;
  91. Fl_Button* m_Record;
  92. Fl_Counter* m_Note;
  93. Fl_WaveDisplay* m_Display;
  94. Fl_Counter* m_SampleNum;
  95. Fl_Button* m_ZoomIn;
  96. Fl_Button* m_ZoomOut;
  97. Fl_Button* m_Cut;
  98. Fl_Button* m_Copy;
  99. Fl_Button* m_Paste;
  100. Fl_Button* m_Mix;
  101. Fl_Button* m_Crop;
  102. Fl_Button* m_Reverse;
  103. Fl_Button* m_Amp;
  104. //// Callbacks ////
  105. inline void cb_Load_i(Fl_Button* o, void* v);
  106. static void cb_Load(Fl_Button* o, void* v);
  107. inline void cb_Save_i(Fl_Button* o, void* v);
  108. static void cb_Save(Fl_Button* o, void* v);
  109. inline void cb_PosMarker_i(Fl_Button* o, void* v);
  110. static void cb_PosMarker(Fl_Button* o, void* v);
  111. inline void cb_Record_i(Fl_Button* o, void* v);
  112. static void cb_Record(Fl_Button* o, void* v);
  113. inline void cb_Volume_i(Fl_Knob* o, void* v);
  114. static void cb_Volume(Fl_Knob* o, void* v);
  115. inline void cb_Pitch_i(Fl_Knob* o, void* v);
  116. static void cb_Pitch(Fl_Knob* o, void* v);
  117. inline void cb_Octave_i(Fl_Knob* o, void* v);
  118. static void cb_Octave(Fl_Knob* o, void* v);
  119. inline void cb_Loop_i(Fl_Button* o, void* v);
  120. static void cb_Loop(Fl_Button* o, void* v);
  121. inline void cb_PingPong_i(Fl_Button* o, void* v);
  122. static void cb_PingPong(Fl_Button* o, void* v);
  123. inline void cb_Note_i(Fl_Counter* o, void* v);
  124. static void cb_Note(Fl_Counter* o, void* v);
  125. inline void cb_SampleNum_i(Fl_Counter* o, void* v);
  126. static void cb_SampleNum(Fl_Counter* o, void* v);
  127. inline void cb_Cut_i(Fl_Button* o, void* v);
  128. static void cb_Cut(Fl_Button* o, void* v);
  129. inline void cb_Copy_i(Fl_Button* o, void* v);
  130. static void cb_Copy(Fl_Button* o, void* v);
  131. inline void cb_Paste_i(Fl_Button* o, void* v);
  132. static void cb_Paste(Fl_Button* o, void* v);
  133. inline void cb_Mix_i(Fl_Button* o, void* v);
  134. static void cb_Mix(Fl_Button* o, void* v);
  135. inline void cb_Crop_i(Fl_Button* o, void* v);
  136. static void cb_Crop(Fl_Button* o, void* v);
  137. inline void cb_Reverse_i(Fl_Button* o, void* v);
  138. static void cb_Reverse(Fl_Button* o, void* v);
  139. inline void cb_Amp_i(Fl_Button* o, void* v);
  140. static void cb_Amp(Fl_Button* o, void* v);
  141. inline void cb_ZoomIn_i(Fl_Button* o, void* v);
  142. static void cb_ZoomIn(Fl_Button* o, void* v);
  143. inline void cb_ZoomOut_i(Fl_Button* o, void* v);
  144. static void cb_ZoomOut(Fl_Button* o, void* v);
  145. inline void cb_WaveDisplay_i(Fl_WaveDisplay* o, void* v);
  146. static void cb_WaveDisplay(Fl_WaveDisplay* o, void* v);
  147. };
  148. #endif