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.

158 lines
4.7KB

  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 "OutputPluginGUI.h"
  19. #include <FL/fl_draw.h>
  20. #include <FL/fl_file_chooser.H>
  21. OutputPluginGUI::OutputPluginGUI(int w, int h, SpiralPlugin *o, ChannelHandler *ch,const HostInfo *Info) :
  22. SpiralPluginGUI(w,h,o,ch)
  23. {
  24. Volume = new Fl_Knob(30, 22, 40, 40, "Volume");
  25. Volume->color(Info->GUI_COLOUR);
  26. Volume->type(Fl_Knob::DOTLIN);
  27. Volume->labelsize(10);
  28. Volume->maximum(1);
  29. Volume->step(0.001);
  30. Volume->value(0.5);
  31. Volume->callback((Fl_Callback*)cb_Volume);
  32. OpenRead = new Fl_Button(2, 80, 30, 15, "Read");
  33. OpenRead->type(FL_TOGGLE_BUTTON);
  34. OpenRead->box (FL_PLASTIC_UP_BOX);
  35. OpenRead->color (Info->GUI_COLOUR);
  36. OpenRead->selection_color (Info->GUI_COLOUR);
  37. OpenRead->labelsize(10);
  38. OpenRead->callback((Fl_Callback*)cb_OpenRead);
  39. OpenDuplex = new Fl_Button(34, 80, 31, 15, "Dplx");
  40. OpenDuplex->type(FL_TOGGLE_BUTTON);
  41. OpenDuplex->box (FL_PLASTIC_UP_BOX);
  42. OpenDuplex->color (Info->GUI_COLOUR);
  43. OpenDuplex->selection_color (Info->GUI_COLOUR);
  44. OpenDuplex->labelsize(10);
  45. OpenDuplex->callback((Fl_Callback*)cb_OpenDuplex);
  46. OpenWrite = new Fl_Button(68, 80, 30, 15, "Write");
  47. OpenWrite->type(FL_TOGGLE_BUTTON);
  48. OpenWrite->box (FL_PLASTIC_UP_BOX);
  49. OpenWrite->color (Info->GUI_COLOUR);
  50. OpenWrite->selection_color (Info->GUI_COLOUR);
  51. OpenWrite->labelsize(10);
  52. OpenWrite->callback((Fl_Callback*)cb_OpenWrite);
  53. end();
  54. }
  55. void OutputPluginGUI::Update()
  56. {
  57. if (m_GUICH->GetBool ("OpenOut")) {
  58. OpenWrite->value (1);
  59. OpenRead->value (0);
  60. OpenDuplex->value (0);
  61. m_GUICH->SetCommand (OutputPlugin::CLEAR_NOTIFY);
  62. }
  63. }
  64. void OutputPluginGUI::UpdateValues(SpiralPlugin *o)
  65. {
  66. Volume->value(OSSOutput::Get()->GetVolume());
  67. }
  68. //// Callbacks ////
  69. inline void OutputPluginGUI::cb_Volume_i(Fl_Knob* o, void* v)
  70. {
  71. m_GUICH->Set("Volume",(float)o->value());
  72. m_GUICH->SetCommand(OutputPlugin::SET_VOLUME);
  73. }
  74. void OutputPluginGUI::cb_Volume(Fl_Knob* o, void* v)
  75. { ((OutputPluginGUI*)(o->parent()))->cb_Volume_i(o,v); }
  76. inline void OutputPluginGUI::cb_OpenRead_i(Fl_Button* o, void* v)
  77. {
  78. if (o->value())
  79. {
  80. OpenWrite->value(0);
  81. OpenDuplex->value(0);
  82. m_GUICH->SetCommand(OutputPlugin::CLOSE);
  83. m_GUICH->Wait();
  84. m_GUICH->SetCommand(OutputPlugin::OPENREAD);
  85. m_GUICH->Wait();
  86. }
  87. else
  88. {
  89. m_GUICH->SetCommand(OutputPlugin::CLOSE);
  90. m_GUICH->Wait();
  91. }
  92. }
  93. void OutputPluginGUI::cb_OpenRead(Fl_Button* o, void* v)
  94. { ((OutputPluginGUI*)(o->parent()))->cb_OpenRead_i(o,v); }
  95. inline void OutputPluginGUI::cb_OpenDuplex_i(Fl_Button* o, void* v)
  96. {
  97. if (o->value())
  98. {
  99. OpenWrite->value(0);
  100. OpenRead->value(0);
  101. m_GUICH->SetCommand(OutputPlugin::CLOSE);
  102. m_GUICH->Wait();
  103. m_GUICH->SetCommand(OutputPlugin::OPENDUPLEX);
  104. m_GUICH->Wait();
  105. }
  106. else
  107. {
  108. m_GUICH->SetCommand(OutputPlugin::CLOSE);
  109. m_GUICH->Wait();
  110. }
  111. }
  112. void OutputPluginGUI::cb_OpenDuplex(Fl_Button* o, void* v)
  113. { ((OutputPluginGUI*)(o->parent()))->cb_OpenDuplex_i(o,v); }
  114. inline void OutputPluginGUI::cb_OpenWrite_i(Fl_Button* o, void* v)
  115. {
  116. if (o->value())
  117. {
  118. OpenDuplex->value(0);
  119. OpenRead->value(0);
  120. m_GUICH->SetCommand(OutputPlugin::CLOSE);
  121. m_GUICH->Wait();
  122. m_GUICH->SetCommand(OutputPlugin::OPENWRITE);
  123. m_GUICH->Wait();
  124. }
  125. else
  126. {
  127. m_GUICH->SetCommand(OutputPlugin::CLOSE);
  128. m_GUICH->Wait();
  129. }
  130. }
  131. void OutputPluginGUI::cb_OpenWrite(Fl_Button* o, void* v)
  132. { ((OutputPluginGUI*)(o->parent()))->cb_OpenWrite_i(o,v); }
  133. const string OutputPluginGUI::GetHelpText(const string &loc){
  134. return string("")
  135. + "Your basic OSS i/o plugin, It opens the OSS sound driver, and outputs\n"
  136. + "whatever is passed into it's inputs to the soundcard. It works in stereo,\n"
  137. + "so you have seperate left and right inputs.\n\n"
  138. + "There are three modes of operation: read, write and duplex. You can select\n"
  139. + "read to record/process sound from your soundcard, write to play sound\n"
  140. + "(default) and if your card supports it - duplex, to play and record \n"
  141. + "simultaneously.";
  142. }