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.

115 lines
2.9KB

  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 "ScopePluginGUI.h"
  19. #include <FL/fl_draw.h>
  20. #include <FL/fl_draw.H>
  21. static const int GUI_COLOUR = 179;
  22. static const int GUIBG_COLOUR = 144;
  23. static const int GUIBG2_COLOUR = 145;
  24. ScopeWidget::ScopeWidget(int x,int y,int w,int h,const char *l, int BUFSIZE) :
  25. Fl_Widget(x,y,w,h,l),
  26. m_Data(NULL),
  27. m_Channels(1),
  28. m_Bufsize(BUFSIZE)
  29. {
  30. m_Data = new float[BUFSIZE];
  31. }
  32. ScopeWidget::~ScopeWidget()
  33. {
  34. delete[] m_Data;
  35. }
  36. void ScopeWidget::draw()
  37. {
  38. int ho=h()/2;
  39. fl_color(GUIBG_COLOUR);
  40. fl_rectf(x(), y(), w(), h());
  41. if (!m_Data) return;
  42. fl_push_clip(x(), y(), w(), h());
  43. float Value=0,NextValue=0;
  44. fl_color(FL_WHITE);
  45. for(int n=0; n<m_Bufsize-1 && n<w(); n++)
  46. {
  47. Value = NextValue;
  48. NextValue = m_Data[n]*ho;
  49. fl_line((int)(x()+n-2), (int)(y()+ho-Value),
  50. (int)(x()+n-1), (int)(y()+ho-NextValue));
  51. }
  52. fl_pop_clip();
  53. }
  54. ////////////////////////////////////////////
  55. ScopePluginGUI::ScopePluginGUI(int w, int h, SpiralPlugin *o, ChannelHandler *ch, const HostInfo *Info) :
  56. SpiralPluginGUI(w,h,o,ch),
  57. m_Bypass(false)
  58. {
  59. m_Scope = new ScopeWidget(5, 20, 210, 85, "Scope", Info->BUFSIZE);
  60. Bypass = new Fl_Button(175, 107, 40, 16, "Bypass");
  61. Bypass->labelsize(10);
  62. Bypass->type(1);
  63. Bypass->callback((Fl_Callback*)cb_Bypass);
  64. end();
  65. }
  66. void ScopePluginGUI::Display(const float *data)
  67. {
  68. //m_Scope->m_Data=data;
  69. if (!m_Bypass) m_Scope->redraw();
  70. }
  71. void ScopePluginGUI::Update()
  72. {
  73. redraw();
  74. }
  75. void ScopePluginGUI::draw()
  76. {
  77. SpiralGUIType::draw();
  78. const float *data;
  79. //cerr<<"getting and drawing..."<<endl;
  80. m_GUICH->GetData("AudioData",(void*)m_Scope->m_Data);
  81. Display(data);
  82. }
  83. void ScopePluginGUI::UpdateValues(SpiralPlugin* o)
  84. {
  85. }
  86. void ScopePluginGUI::cb_Bypass_i(Fl_Button* o, void* v)
  87. {m_Bypass=o->value();}
  88. void ScopePluginGUI::cb_Bypass(Fl_Button* o, void* v)
  89. {((ScopePluginGUI*)(o->parent()))->cb_Bypass_i(o,v);}
  90. const string ScopePluginGUI::GetHelpText(const string &loc){
  91. return string("")
  92. + "The Scope lets you see a visual representation of the\n"
  93. + "data flowing through it. It does nothing to the signal,\n"
  94. + "but its very useful for checking the layouts, looking at\n"
  95. + "CV value etc.\n";
  96. }