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.

166 lines
5.4KB

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