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.

211 lines
5.4KB

  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 "DiskWriterPluginGUI.h"
  19. #include <FL/fl_draw.h>
  20. #include <FL/fl_file_chooser.H>
  21. using namespace std;
  22. DiskWriterPluginGUI::DiskWriterPluginGUI(int w, int h, SpiralPlugin *o, ChannelHandler *ch,const HostInfo *Info) :
  23. SpiralPluginGUI(w,h,o,ch)
  24. {
  25. m_16bits = new Fl_LED_Button (0, 15, 23, 23, "16bit");
  26. m_16bits->type (FL_RADIO_BUTTON);
  27. m_16bits->labelsize(10);
  28. m_16bits->set();
  29. m_16bits->callback((Fl_Callback*)cb_16bits, this);
  30. m_24bits = new Fl_LED_Button (0, 38, 23, 23, "24bit");
  31. m_24bits->type (FL_RADIO_BUTTON);
  32. m_24bits->labelsize(10);
  33. m_24bits->callback((Fl_Callback*)cb_24bits, this);
  34. m_32bits = new Fl_LED_Button (0, 61, 23, 23, "32bit");
  35. m_32bits->type (FL_RADIO_BUTTON);
  36. m_32bits->labelsize(10);
  37. m_32bits->callback((Fl_Callback*)cb_32bits, this);
  38. // 7 seg displays
  39. for (int dis=0; dis<4; dis++) {
  40. m_Display[dis] = new Fl_SevenSeg (50 + 27*dis, 20, 27, 38);
  41. m_Display[dis] -> bar_width (4);
  42. m_Display[dis] -> color (Info->SCOPE_FG_COLOUR);
  43. m_Display[dis] -> color2 (Info->SCOPE_BG_COLOUR);
  44. if (dis > 0 && dis % 2 == 0) m_Display[dis] -> dp (colon);
  45. add (m_Display[dis]);
  46. }
  47. m_Stereo = new Fl_Check_Button (105, 63, 10, 18, "Stereo");
  48. m_Stereo->type (1);
  49. m_Stereo->value (1);
  50. m_Stereo->labelsize(12);
  51. m_Stereo->callback((Fl_Callback*)cb_Stereo, this);
  52. Open = new Fl_Button(0, 85, 75, 20, "Open");
  53. Open->type(1);
  54. Open->box (FL_PLASTIC_UP_BOX);
  55. Open->color (Info->GUI_COLOUR);
  56. Open->selection_color (Info->GUI_COLOUR);
  57. Open->labelsize(10);
  58. Open->callback((Fl_Callback*)cb_Open, this);
  59. Record = new Fl_Button(85, 85, 75, 20, "Record");
  60. Record->type(1);
  61. Record->box (FL_PLASTIC_UP_BOX);
  62. Record->color (Info->GUI_COLOUR);
  63. Record->selection_color (Info->GUI_COLOUR);
  64. Record->labelsize(10);
  65. Record->callback((Fl_Callback*)cb_Record, this);
  66. end();
  67. }
  68. void DiskWriterPluginGUI::Update()
  69. {
  70. float t=m_GUICH->GetFloat ("TimeRecorded");
  71. bool recording=m_GUICH->GetBool ("Recording");
  72. if (recording)
  73. {
  74. m_16bits->deactivate();
  75. m_24bits->deactivate();
  76. m_32bits->deactivate();
  77. m_Stereo->deactivate();
  78. }
  79. else
  80. {
  81. m_16bits->activate();
  82. m_24bits->activate();
  83. m_32bits->activate();
  84. m_Stereo->activate();
  85. }
  86. m_Display[3]->value ((int)t % 10);
  87. m_Display[2]->value ((int)(t/10) % 6);
  88. m_Display[1]->value ((int)(t/60) % 10);
  89. m_Display[0]->value ((int)(t/600) % 10);
  90. redraw();
  91. }
  92. void DiskWriterPluginGUI::UpdateValues (SpiralPlugin *o)
  93. {
  94. DiskWriterPlugin* Plugin = (DiskWriterPlugin*)o;
  95. switch (Plugin->GetBitsPerSample())
  96. {
  97. case 32 :
  98. {
  99. m_32bits->value(1);
  100. m_24bits->value(0);
  101. m_16bits->value(0);
  102. }
  103. break;
  104. case 24 :
  105. {
  106. m_32bits->value(0);
  107. m_24bits->value(1);
  108. m_16bits->value(0);
  109. }
  110. break;
  111. case 16 :
  112. default:
  113. {
  114. m_32bits->value(0);
  115. m_24bits->value(0);
  116. m_16bits->value(1);
  117. }
  118. }
  119. m_Stereo->value(Plugin->GetStereo());
  120. redraw();
  121. }
  122. //// Callbacks ////
  123. inline void DiskWriterPluginGUI::cb_Open_i(Fl_Button* o)
  124. {
  125. if (o->value())
  126. {
  127. char *fn=fl_file_chooser("Pick a Wav file to save to", "*.wav", NULL);
  128. char t[256];
  129. sprintf(t,"%s",fn);
  130. if (fn && fn!="")
  131. {
  132. m_GUICH->SetData("Filename",(void*)t);
  133. m_GUICH->SetCommand(DiskWriterPlugin::OPENWAV);
  134. }
  135. else
  136. {
  137. m_GUICH->SetCommand(DiskWriterPlugin::CLOSEWAV);
  138. o->value(false);
  139. }
  140. }
  141. else
  142. {
  143. m_GUICH->SetCommand(DiskWriterPlugin::CLOSEWAV);
  144. }
  145. }
  146. inline void DiskWriterPluginGUI::cb_Record_i(Fl_Button* o)
  147. {
  148. if (o->value())
  149. {
  150. m_GUICH->SetCommand(DiskWriterPlugin::RECORD);
  151. }
  152. else
  153. {
  154. m_GUICH->SetCommand(DiskWriterPlugin::STOP);
  155. }
  156. }
  157. inline void DiskWriterPluginGUI::cb_16bits_i(Fl_Button* o)
  158. {
  159. m_GUICH->Set("BitsPerSample",16);
  160. }
  161. inline void DiskWriterPluginGUI::cb_24bits_i(Fl_Button* o)
  162. {
  163. m_GUICH->Set("BitsPerSample",24);
  164. }
  165. inline void DiskWriterPluginGUI::cb_32bits_i(Fl_Button* o)
  166. {
  167. m_GUICH->Set("BitsPerSample",32);
  168. }
  169. inline void DiskWriterPluginGUI::cb_Stereo_i(Fl_Button* o)
  170. {
  171. m_GUICH->Set("Stereo",o->value());
  172. }
  173. const string DiskWriterPluginGUI::GetHelpText(const string &loc)
  174. {
  175. return string("")
  176. + "One way of recording your creations to disk. First open a file\n"
  177. + "you wish to save to, then hit record to start recording.\n"
  178. + "You are able to stop and restart recording without closing the\n"
  179. + "file, which should make life a little easier if you are doing\n"
  180. + "things like recording lots of little samples.";
  181. }