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.

145 lines
4.1KB

  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 "AmpPluginGUI.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. ////////////////////////////////////////////
  25. AmpPluginGUI::AmpPluginGUI(int w, int h,AmpPlugin *o,ChannelHandler *ch,const HostInfo *Info) :
  26. SpiralPluginGUI(w,h,o,ch)
  27. {
  28. m_Plugin=o;
  29. m_Amp = new Fl_Slider(15, 20, 20, 70, "Amp");
  30. m_Amp->type(4);
  31. m_Amp->selection_color(GUI_COLOUR);
  32. m_Amp->labelsize(10);
  33. m_Amp->maximum(4);
  34. m_Amp->step(0.0001);
  35. m_Amp->value(2);
  36. m_Amp->callback((Fl_Callback*)cb_Amp);
  37. m_DC = new Fl_Slider(70, 20, 20, 70, "DC Offset");
  38. m_DC->type(4);
  39. m_DC->selection_color(GUI_COLOUR);
  40. m_DC->labelsize(10);
  41. m_DC->maximum(4);
  42. m_DC->step(0.0001);
  43. m_DC->value(2);
  44. m_DC->callback((Fl_Callback*)cb_DC);
  45. m_pop = new Fl_Button(1,h-14, 13, 13, "@>");
  46. m_pop->type(1);
  47. m_pop->box(FL_FLAT_BOX);
  48. m_pop->down_box(FL_FLAT_BOX);
  49. m_pop->labeltype(FL_SYMBOL_LABEL);
  50. m_pop->labelsize(10);
  51. m_pop->labelcolor(25);
  52. m_pop->callback((Fl_Callback*)cb_pop);
  53. m_out_gain = new Fl_Output(25,h+5,36, 15, "Gain");
  54. m_out_gain->box(FL_ENGRAVED_BOX);
  55. m_out_gain->color(16);
  56. m_out_gain->labelsize(10);
  57. m_out_gain->textsize(10);
  58. m_out_gain->hide();
  59. m_out_gain->set_output();
  60. m_out_DC = new Fl_Output(82,h+5,36, 15, "DC");
  61. m_out_DC->box(FL_ENGRAVED_BOX);
  62. m_out_DC->color(16);
  63. m_out_DC->labelsize(10);
  64. m_out_DC->textsize(10);
  65. m_out_DC->hide();
  66. m_out_DC->set_output();
  67. end();
  68. }
  69. extern "C" int sprintf(char *,const char *,...);
  70. void AmpPluginGUI::UpdateValues(SpiralPlugin *o)
  71. {
  72. AmpPlugin* Plugin = (AmpPlugin*)o;
  73. m_Amp->value(2.0f-Plugin->GetAmp());
  74. m_DC->value(2.0f-Plugin->GetDC());
  75. char str[10];
  76. sprintf(str,"%4.2f",Plugin->GetAmp());
  77. m_out_gain->value(str);
  78. sprintf(str,"%4.2f",Plugin->GetDC());
  79. m_out_DC->value(str);
  80. }
  81. inline void AmpPluginGUI::cb_Amp_i(Fl_Slider* o, void* v)
  82. {
  83. char str[10];
  84. float value=2.0f-o->value();
  85. m_GUICH->Set("Amp",value);
  86. sprintf(str,"%4.2f",value);
  87. m_out_gain->value(str);
  88. }
  89. void AmpPluginGUI::cb_Amp(Fl_Slider* o, void* v)
  90. { ((AmpPluginGUI*)(o->parent()))->cb_Amp_i(o,v); }
  91. inline void AmpPluginGUI::cb_DC_i(Fl_Slider* o, void* v)
  92. {
  93. char str[10];
  94. float value=2.0f-o->value();
  95. m_GUICH->Set("DC",value);
  96. sprintf(str,"%4.2f",value);
  97. m_out_DC->value(str);
  98. }
  99. void AmpPluginGUI::cb_DC(Fl_Slider* o, void* v)
  100. { ((AmpPluginGUI*)(o->parent()))->cb_DC_i(o,v); }
  101. inline void AmpPluginGUI::cb_pop_i(Fl_Button *o, void*) {
  102. if (o->value())
  103. {
  104. o->label("@2>");
  105. m_out_gain->show();
  106. m_out_DC->show();
  107. redraw();
  108. }
  109. else
  110. {
  111. o->label("@>");
  112. m_out_gain->hide();
  113. m_out_DC->hide();
  114. redraw();
  115. parent()->redraw();
  116. }
  117. }
  118. void AmpPluginGUI::cb_pop(Fl_Button* o, void* v) {
  119. ((AmpPluginGUI*)(o->parent()))->cb_pop_i(o,v);
  120. }
  121. const string AmpPluginGUI::GetHelpText(const string &loc){
  122. return string("")
  123. + "A CV controlled amplifer. You also can use this device to modify\n"
  124. + "the signal's DC offset (the up or down in the range of values).\n\n"
  125. + "Handy for fine tuning CV's by hand, or modulating complex\n"
  126. + "controls.";
  127. }