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.

160 lines
4.8KB

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