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.

184 lines
5.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 "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);
  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);
  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);
  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);
  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);
  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);
  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. //// Callbacks ////
  95. inline void DiskWriterPluginGUI::cb_Open_i(Fl_Button* o, void* v)
  96. {
  97. if (o->value())
  98. {
  99. char *fn=fl_file_chooser("Pick a Wav file to save to", "*.wav", NULL);
  100. char t[256];
  101. sprintf(t,"%s",fn);
  102. if (fn && fn!="")
  103. {
  104. m_GUICH->SetData("Filename",(void*)t);
  105. m_GUICH->SetCommand(DiskWriterPlugin::OPENWAV);
  106. }
  107. else
  108. {
  109. m_GUICH->SetCommand(DiskWriterPlugin::CLOSEWAV);
  110. o->value(false);
  111. }
  112. }
  113. else
  114. {
  115. m_GUICH->SetCommand(DiskWriterPlugin::CLOSEWAV);
  116. }
  117. }
  118. void DiskWriterPluginGUI::cb_Open(Fl_Button* o, void* v)
  119. { ((DiskWriterPluginGUI*)(o->parent()))->cb_Open_i(o,v); }
  120. inline void DiskWriterPluginGUI::cb_Record_i(Fl_Button* o, void* v)
  121. {
  122. if (o->value()) m_GUICH->SetCommand(DiskWriterPlugin::RECORD);
  123. else m_GUICH->SetCommand(DiskWriterPlugin::STOP);
  124. }
  125. void DiskWriterPluginGUI::cb_Record(Fl_Button* o, void* v)
  126. { ((DiskWriterPluginGUI*)(o->parent()))->cb_Record_i(o,v); }
  127. inline void DiskWriterPluginGUI::cb_16bits_i(Fl_Button* o, void* v)
  128. {
  129. m_GUICH->Set("BitsPerSample",16);
  130. }
  131. void DiskWriterPluginGUI::cb_16bits(Fl_Button* o, void* v)
  132. { ((DiskWriterPluginGUI*)(o->parent()))->cb_16bits_i(o,v); }
  133. inline void DiskWriterPluginGUI::cb_24bits_i(Fl_Button* o, void* v)
  134. {
  135. m_GUICH->Set("BitsPerSample",24);
  136. }
  137. void DiskWriterPluginGUI::cb_24bits(Fl_Button* o, void* v)
  138. { ((DiskWriterPluginGUI*)(o->parent()))->cb_24bits_i(o,v); }
  139. inline void DiskWriterPluginGUI::cb_32bits_i(Fl_Button* o, void* v)
  140. {
  141. m_GUICH->Set("BitsPerSample",32);
  142. }
  143. void DiskWriterPluginGUI::cb_32bits(Fl_Button* o, void* v)
  144. { ((DiskWriterPluginGUI*)(o->parent()))->cb_32bits_i(o,v); }
  145. inline void DiskWriterPluginGUI::cb_Stereo_i(Fl_Button* o, void* v)
  146. {
  147. m_GUICH->Set("Stereo",o->value());
  148. }
  149. void DiskWriterPluginGUI::cb_Stereo(Fl_Button* o, void* v)
  150. { ((DiskWriterPluginGUI*)(o->parent()))->cb_Stereo_i(o,v); }
  151. const string DiskWriterPluginGUI::GetHelpText(const string &loc){
  152. return string("")
  153. + "One way of recording your creations to disk. First open a file\n"
  154. + "you wish to save to, then hit record to start recording.\n"
  155. + "You are able to stop and restart recording without closing the\n"
  156. + "file, which should make life a little easier if you are doing\n"
  157. + "things like recording lots of little samples.";
  158. }