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.

126 lines
4.2KB

  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 "MasherPluginGUI.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. MasherPluginGUI::MasherPluginGUI(int w, int h,MasherPlugin *o,ChannelHandler *ch,const HostInfo *Info) :
  26. SpiralPluginGUI(w,h,o,ch)
  27. {
  28. m_Plugin=o;
  29. m_Pitch = new Fl_Knob(5,15,40,40,"GrainPitch");
  30. m_Pitch->type(Fl_Knob::DOTLIN);
  31. m_Pitch->color(GUI_COLOUR);
  32. m_Pitch->labelsize(10);
  33. m_Pitch->maximum(5);
  34. m_Pitch->step(0.001);
  35. m_Pitch->value(1);
  36. m_Pitch->callback((Fl_Callback*)cb_Pitch);
  37. m_Random = new Fl_Knob(70,15,40,40,"Randomness");
  38. m_Random->type(Fl_Knob::DOTLIN);
  39. m_Random->color(GUI_COLOUR);
  40. m_Random->labelsize(10);
  41. m_Random->maximum(100);
  42. m_Random->step(1);
  43. m_Random->value(1);
  44. m_Random->callback((Fl_Callback*)cb_Random);
  45. m_GrainStoreSize = new Fl_Knob(5,70,40,40,"Num Grains");
  46. m_GrainStoreSize->type(Fl_Knob::DOTLIN);
  47. m_GrainStoreSize->color(GUI_COLOUR);
  48. m_GrainStoreSize->labelsize(10);
  49. m_GrainStoreSize->maximum(MAX_GRAINSTORE_SIZE-2);
  50. m_GrainStoreSize->step(1);
  51. m_GrainStoreSize->value(1);
  52. m_GrainStoreSize->callback((Fl_Callback*)cb_GrainStoreSize);
  53. m_Density = new Fl_Knob(70,70,40,40,"Density");
  54. m_Density->type(Fl_Knob::DOTLIN);
  55. m_Density->color(GUI_COLOUR);
  56. m_Density->labelsize(10);
  57. m_Density->maximum(MAX_GRAINSTORE_SIZE);
  58. m_Density->step(1);
  59. m_Density->value(1);
  60. m_Density->callback((Fl_Callback*)cb_Density);
  61. end();
  62. }
  63. extern "C" int sprintf(char *,const char *,...);
  64. void MasherPluginGUI::UpdateValues(SpiralPlugin *o)
  65. {
  66. MasherPlugin* Plugin = (MasherPlugin*)o;
  67. m_Pitch->value(Plugin->GetGrainPitch());
  68. m_Random->value(Plugin->GetRandomness());
  69. m_GrainStoreSize->value(Plugin->GetGrainStoreSize());
  70. m_Density->value(Plugin->GetDensity());
  71. }
  72. inline void MasherPluginGUI::cb_Random_i(Fl_Knob* o, void* v)
  73. {
  74. m_GUICH->Set("Randomness",(int)o->value());
  75. }
  76. void MasherPluginGUI::cb_Random(Fl_Knob* o, void* v)
  77. { ((MasherPluginGUI*)(o->parent()))->cb_Random_i(o,v); }
  78. inline void MasherPluginGUI::cb_Pitch_i(Fl_Knob* o, void* v)
  79. {
  80. m_GUICH->Set("GrainPitch",(float)o->value());
  81. }
  82. void MasherPluginGUI::cb_Pitch(Fl_Knob* o, void* v)
  83. { ((MasherPluginGUI*)(o->parent()))->cb_Pitch_i(o,v); }
  84. inline void MasherPluginGUI::cb_MinGrainSize_i(Fl_Knob* o, void* v)
  85. {
  86. m_GUICH->Set("Period",(int)o->value()+1);
  87. }
  88. void MasherPluginGUI::cb_MinGrainSize(Fl_Knob* o, void* v)
  89. { ((MasherPluginGUI*)(o->parent()))->cb_MinGrainSize_i(o,v); }
  90. inline void MasherPluginGUI::cb_GrainStoreSize_i(Fl_Knob* o, void* v)
  91. {
  92. m_GUICH->Set("GrainStoreSize",(int)o->value()+1);
  93. }
  94. void MasherPluginGUI::cb_GrainStoreSize(Fl_Knob* o, void* v)
  95. { ((MasherPluginGUI*)(o->parent()))->cb_GrainStoreSize_i(o,v); }
  96. inline void MasherPluginGUI::cb_Density_i(Fl_Knob* o, void* v)
  97. {
  98. m_GUICH->Set("Density",(int)o->value());
  99. }
  100. void MasherPluginGUI::cb_Density(Fl_Knob* o, void* v)
  101. { ((MasherPluginGUI*)(o->parent()))->cb_Density_i(o,v); }
  102. const string MasherPluginGUI::GetHelpText(const string &loc){
  103. return string("")
  104. + "Top secret sample masher plugin. Granulates the incoming stream and\n"
  105. + "carries out various patented algorithms on the result.\n\n"
  106. + "Truth is I don't really know how it works, but makes sounds like\n"
  107. + "tttttthhhIIiissssSSSSSSsssssSsSSsS.";
  108. }