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