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.

133 lines
5.8KB

  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. #ifndef POSH_SAMP_GUI_H
  19. #define POSH_SAMP_GUI_H
  20. #include <FL/Fl.H>
  21. #include <FL/Fl_Button.H>
  22. #include <FL/Fl_Counter.H>
  23. #include "PoshSamplerPlugin.h"
  24. #include "../SpiralPluginGUI.h"
  25. #include "../Widgets/Fl_Knob.H"
  26. class Fl_WaveDisplay : public Fl_Widget {
  27. public:
  28. Fl_WaveDisplay (int x,int y,int w,int h, char* Name);
  29. ~Fl_WaveDisplay();
  30. virtual void draw();
  31. virtual int handle (int event);
  32. void SetSample (const float* s, long len);
  33. void ClearSample (void);
  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, m_EndPos, m_ViewStart, m_ViewEnd;
  58. long m_PlayPos, m_PlayStart, m_LoopStart, m_LoopEnd;
  59. bool m_PosMarker;
  60. };
  61. class PoshSamplerPluginGUI : public SpiralPluginGUI {
  62. public:
  63. PoshSamplerPluginGUI (int w, int h, PoshSamplerPlugin *o, ChannelHandler *ch, const HostInfo *Info);
  64. virtual void UpdateValues (SpiralPlugin *o);
  65. virtual void Update();
  66. void SetPlayPos (long s) { m_Display->SetPlayPos(s); }
  67. int GetCurrentSample() { return (int)m_SampleNum->value(); }
  68. protected:
  69. const std::string GetHelpText(const std::string &loc);
  70. private:
  71. void UpdateSampleDisplay(int num);
  72. char m_TextBuf[256];
  73. int Numbers[NUM_SAMPLES];
  74. bool m_UpdateMe;
  75. Fl_Knob *m_Volume, *m_Pitch, *m_Octave;
  76. Fl_Button *m_Load, *m_Save, *m_Record, *m_Loop, *m_PingPong, *m_PosMarker, *m_Retrig;
  77. Fl_Button *m_ZoomIn, *m_ZoomOut, *m_Cut, *m_Copy, *m_Paste, *m_Mix, *m_Crop, *m_Reverse, *m_Amp;
  78. Fl_Counter *m_Note, *m_SampleNum;
  79. Fl_WaveDisplay *m_Display;
  80. //// Callbacks ////
  81. inline void cb_Load_i (Fl_Button *o, void *v);
  82. static void cb_Load (Fl_Button *o, void *v);
  83. inline void cb_Save_i (Fl_Button *o, void *v);
  84. static void cb_Save (Fl_Button *o, void *v);
  85. inline void cb_Record_i (Fl_Button *o, void *v);
  86. static void cb_Record (Fl_Button *o, void *v);
  87. inline void cb_Loop_i (Fl_Button *o, void *v);
  88. static void cb_Loop (Fl_Button *o, void *v);
  89. inline void cb_PingPong_i (Fl_Button *o, void *v);
  90. static void cb_PingPong (Fl_Button *o, void *v);
  91. inline void cb_PosMarker_i (Fl_Button *o, void *v);
  92. static void cb_PosMarker (Fl_Button *o, void *v);
  93. inline void cb_Retrig_i (Fl_Button *o, void *v);
  94. static void cb_Retrig (Fl_Button *o, void *v);
  95. inline void cb_Volume_i (Fl_Knob *o, void *v);
  96. static void cb_Volume (Fl_Knob *o, void *v);
  97. inline void cb_Pitch_i (Fl_Knob *o, void *v);
  98. static void cb_Pitch (Fl_Knob *o, void *v);
  99. inline void cb_Octave_i (Fl_Knob *o, void *v);
  100. static void cb_Octave (Fl_Knob *o, void *v);
  101. inline void cb_Note_i (Fl_Counter *o, void *v);
  102. static void cb_Note (Fl_Counter *o, void *v);
  103. inline void cb_SampleNum_i (Fl_Counter *o, void *v);
  104. static void cb_SampleNum (Fl_Counter *o, void *v);
  105. inline void cb_Cut_i (Fl_Button *o, void *v);
  106. static void cb_Cut (Fl_Button *o, void *v);
  107. inline void cb_Copy_i (Fl_Button *o, void *v);
  108. static void cb_Copy (Fl_Button *o, void *v);
  109. inline void cb_Paste_i (Fl_Button *o, void *v);
  110. static void cb_Paste (Fl_Button *o, void *v);
  111. inline void cb_Mix_i (Fl_Button *o, void *v);
  112. static void cb_Mix (Fl_Button *o, void *v);
  113. inline void cb_Crop_i (Fl_Button *o, void *v);
  114. static void cb_Crop (Fl_Button *o, void *v);
  115. inline void cb_Reverse_i (Fl_Button *o, void *v);
  116. static void cb_Reverse (Fl_Button *o, void *v);
  117. inline void cb_Amp_i (Fl_Button *o, void *v);
  118. static void cb_Amp (Fl_Button *o, void *v);
  119. inline void cb_ZoomIn_i (Fl_Button *o, void *v);
  120. static void cb_ZoomIn (Fl_Button *o, void *v);
  121. inline void cb_ZoomOut_i (Fl_Button *o, void *v);
  122. static void cb_ZoomOut (Fl_Button *o, void *v);
  123. inline void cb_WaveDisplay_i (Fl_WaveDisplay *o, void *v);
  124. static void cb_WaveDisplay (Fl_WaveDisplay *o, void *v);
  125. };
  126. #endif