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.

142 lines
4.0KB

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