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.

305 lines
10KB

  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 "MidiPluginGUI.h"
  19. #include <FL/fl_draw.h>
  20. #include <FL/fl_file_chooser.H>
  21. #include <FL/Fl_Hold_Browser.H>
  22. #include <FL/Fl_Double_Window.H>
  23. ////////////////////////////////////////////////////////////////////////
  24. int OptionsList(const vector<string> &List)
  25. {
  26. Fl_Double_Window *Win = new Fl_Double_Window(300,300);
  27. Fl_Button *Ok = new Fl_Button(10,275,40,20,"Ok");
  28. Ok->labelsize(10);
  29. Fl_Button *Cancel = new Fl_Button(50,275,40,20,"Cancel");
  30. Cancel->labelsize(10);
  31. Fl_Hold_Browser* Browser = new Fl_Hold_Browser(5,5,290,265,"");
  32. for (vector<string>::const_iterator i = List.begin();
  33. i!=List.end(); i++)
  34. {
  35. Browser->add(i->c_str());
  36. }
  37. Win->show();
  38. int Choice=-1;
  39. for (;;)
  40. {
  41. Fl::wait();
  42. Fl_Widget* o = Fl::readqueue();
  43. if (o==Ok || o==Browser)
  44. {
  45. Choice=Browser->value();
  46. Win->hide();
  47. delete Win;
  48. break;
  49. }
  50. if (o==Cancel)
  51. {
  52. Choice=-1;
  53. Win->hide();
  54. delete Win;
  55. break;
  56. }
  57. if (o==Win) break;
  58. }
  59. return Choice;
  60. }
  61. ////////////////////////////////////////////////////////////////////////
  62. MidiPluginGUI::MidiPluginGUI(int w, int h,MidiPlugin *o,ChannelHandler *ch,const HostInfo *Info) :
  63. SpiralPluginGUI(w,h,o,ch)
  64. {
  65. m_DeviceNum = new Fl_Counter(20,30,40,20,"Channel");
  66. m_DeviceNum->type(FL_SIMPLE_COUNTER);
  67. m_DeviceNum->step(1);
  68. m_DeviceNum->value(1);
  69. m_DeviceNum->callback((Fl_Callback*)cb_DeviceNum, NULL);
  70. m_NoteCut = new Fl_Button(5,70,75,20,"Note Cut");
  71. m_NoteCut->type(1);
  72. m_NoteCut->labelsize(10);
  73. m_NoteCut->callback((Fl_Callback*)cb_NoteCut, NULL);
  74. m_ContinuousNotes = new Fl_Button(5,90,75,20,"Cont Notes");
  75. m_ContinuousNotes->type(1);
  76. m_ContinuousNotes->labelsize(10);
  77. m_ContinuousNotes->callback((Fl_Callback*)cb_ContinuousNotes, NULL);
  78. m_AddControl = new Fl_Button(5,110,75,20,"Add Control");
  79. m_AddControl->labelsize(10);
  80. m_AddControl->callback((Fl_Callback*)cb_AddControl, NULL);
  81. m_RemoveControl = new Fl_Button(5,130,75,20,"Remove Control");
  82. m_RemoveControl->labelsize(10);
  83. m_RemoveControl->callback((Fl_Callback*)cb_RemoveControl, NULL);
  84. }
  85. void MidiPluginGUI::UpdateValues(SpiralPlugin *o)
  86. {
  87. MidiPlugin *Plugin = (MidiPlugin*)o;
  88. m_DeviceNum->value(Plugin->GetDeviceNum());
  89. }
  90. //// Callbacks ////
  91. inline void MidiPluginGUI::cb_DeviceNum_i(Fl_Counter* o, void* v)
  92. {
  93. if (o->value()<1) o->value(1);
  94. if (o->value()>128) o->value(128);
  95. m_GUICH->Set("DeviceNum",(int)o->value()-1);
  96. }
  97. void MidiPluginGUI::cb_DeviceNum(Fl_Counter* o, void* v)
  98. { ((MidiPluginGUI*)(o->parent()))->cb_DeviceNum_i(o,v);}
  99. inline void MidiPluginGUI::cb_NoteCut_i(Fl_Button* o, void* v)
  100. { m_GUICH->Set("NoteCut",o->value()); }
  101. void MidiPluginGUI::cb_NoteCut(Fl_Button* o, void* v)
  102. { ((MidiPluginGUI*)(o->parent()))->cb_NoteCut_i(o,v);}
  103. inline void MidiPluginGUI::cb_ContinuousNotes_i(Fl_Button* o, void* v)
  104. { m_GUICH->Set("ContinuousNotes",o->value()); }
  105. void MidiPluginGUI::cb_ContinuousNotes(Fl_Button* o, void* v)
  106. { ((MidiPluginGUI*)(o->parent()))->cb_ContinuousNotes_i(o,v);}
  107. inline void MidiPluginGUI::cb_AddControl_i(Fl_Button* o, void* v)
  108. {
  109. vector<string> List;
  110. List.push_back("0 Bank Select");
  111. List.push_back("1 Modulation Wheel (coarse)");
  112. List.push_back("2 Breath controller (coarse)");
  113. List.push_back("3 None");
  114. List.push_back("4 Foot Pedal (coarse)");
  115. List.push_back("5 Portamento Time (coarse)");
  116. List.push_back("6 Data Entry (coarse)");
  117. List.push_back("7 Volume (coarse)");
  118. List.push_back("8 Balance (coarse)");
  119. List.push_back("9 None");
  120. List.push_back("10 Pan position (coarse)");
  121. List.push_back("11 Expression (coarse)");
  122. List.push_back("12 Effect Control 1 (coarse)");
  123. List.push_back("13 Effect Control 2 (coarse)");
  124. List.push_back("14 None");
  125. List.push_back("15 None");
  126. List.push_back("16 General Purpose Slider 1");
  127. List.push_back("17 General Purpose Slider 2");
  128. List.push_back("18 General Purpose Slider 3");
  129. List.push_back("19 General Purpose Slider 4");
  130. List.push_back("20 None");
  131. List.push_back("21 None");
  132. List.push_back("22 None");
  133. List.push_back("23 None");
  134. List.push_back("24 None");
  135. List.push_back("25 None");
  136. List.push_back("26 None");
  137. List.push_back("27 None");
  138. List.push_back("28 None");
  139. List.push_back("29 None");
  140. List.push_back("30 None");
  141. List.push_back("31 None");
  142. List.push_back("32 Bank Select (fine)");
  143. List.push_back("33 Modulation Wheel (fine)");
  144. List.push_back("34 Breath controller (fine)");
  145. List.push_back("35 None");
  146. List.push_back("36 Foot Pedal (fine)");
  147. List.push_back("37 Portamento Time (fine)");
  148. List.push_back("38 Data Entry (fine)");
  149. List.push_back("39 Volume (fine)");
  150. List.push_back("40 Balance (fine)");
  151. List.push_back("41 None");
  152. List.push_back("42 Pan position (fine)");
  153. List.push_back("43 Expression (fine)");
  154. List.push_back("44 Effect Control 1 (fine)");
  155. List.push_back("45 Effect Control 2 (fine)");
  156. List.push_back("46 None");
  157. List.push_back("47 None");
  158. List.push_back("48 None");
  159. List.push_back("49 None");
  160. List.push_back("50 None");
  161. List.push_back("51 None");
  162. List.push_back("52 None");
  163. List.push_back("53 None");
  164. List.push_back("54 None");
  165. List.push_back("55 None");
  166. List.push_back("56 None");
  167. List.push_back("57 None");
  168. List.push_back("58 None");
  169. List.push_back("59 None");
  170. List.push_back("60 None");
  171. List.push_back("61 None");
  172. List.push_back("62 None");
  173. List.push_back("63 None");
  174. List.push_back("64 Hold Pedal (on/off)");
  175. List.push_back("65 Portamento (on/off)");
  176. List.push_back("66 Sustenuto Pedal (on/off)");
  177. List.push_back("67 Soft Pedal (on/off)");
  178. List.push_back("68 Legato Pedal (on/off)");
  179. List.push_back("69 Hold 2 Pedal (on/off)");
  180. List.push_back("70 Sound Variation");
  181. List.push_back("71 Sound Timbre");
  182. List.push_back("72 Sound Release Time");
  183. List.push_back("73 Sound Attack Time");
  184. List.push_back("74 Sound Brightness");
  185. List.push_back("75 Sound Control 6");
  186. List.push_back("76 Sound Control 7");
  187. List.push_back("77 Sound Control 8");
  188. List.push_back("78 Sound Control 9");
  189. List.push_back("79 Sound Control 10");
  190. List.push_back("80 General Purpose Button 1 (on/off)");
  191. List.push_back("81 General Purpose Button 2 (on/off)");
  192. List.push_back("82 General Purpose Button 3 (on/off)");
  193. List.push_back("83 General Purpose Button 4 (on/off)");
  194. List.push_back("84 None");
  195. List.push_back("85 None");
  196. List.push_back("86 None");
  197. List.push_back("87 None");
  198. List.push_back("88 None");
  199. List.push_back("89 None");
  200. List.push_back("90 None");
  201. List.push_back("91 Effects Level");
  202. List.push_back("92 Tremulo Level");
  203. List.push_back("93 Chorus Level");
  204. List.push_back("94 Celeste Level");
  205. List.push_back("95 Phaser Level");
  206. List.push_back("96 Data Button increment");
  207. List.push_back("97 Data Button decrement");
  208. List.push_back("98 Non-registered Parameter (fine)");
  209. List.push_back("99 Non-registered Parameter (coarse)");
  210. List.push_back("100 Registered Parameter (fine)");
  211. List.push_back("101 Registered Parameter (coarse)");
  212. List.push_back("102 None");
  213. List.push_back("103 None");
  214. List.push_back("104 None");
  215. List.push_back("105 None");
  216. List.push_back("106 None");
  217. List.push_back("107 None");
  218. List.push_back("108 None");
  219. List.push_back("109 None");
  220. List.push_back("110 None");
  221. List.push_back("111 None");
  222. List.push_back("112 None");
  223. List.push_back("113 None");
  224. List.push_back("114 None");
  225. List.push_back("115 None");
  226. List.push_back("116 None");
  227. List.push_back("117 None");
  228. List.push_back("118 None");
  229. List.push_back("119 None");
  230. List.push_back("120 All Sound Off");
  231. List.push_back("121 All Controllers Off");
  232. List.push_back("122 Local Keyboard (on/off)");
  233. List.push_back("123 All Notes Off");
  234. List.push_back("124 Omni Mode Off");
  235. List.push_back("125 Omni Mode On");
  236. List.push_back("126 Mono Operation");
  237. List.push_back("127 Poly Operation");
  238. int c=OptionsList(List)-1;
  239. if (c>-1)
  240. {
  241. m_GUICH->Set("CC",c);
  242. char Temp[256];
  243. sprintf(Temp,"%s",List[c].c_str());
  244. m_GUICH->SetData("Name",Temp);
  245. m_GUICH->SetCommand(MidiPlugin::ADDCONTROL);
  246. //m_Plugin->AddControl(c,List[c]);
  247. }
  248. }
  249. void MidiPluginGUI::cb_AddControl(Fl_Button* o, void* v)
  250. { ((MidiPluginGUI*)(o->parent()))->cb_AddControl_i(o,v);}
  251. inline void MidiPluginGUI::cb_RemoveControl_i(Fl_Button* o, void* v)
  252. {
  253. m_GUICH->SetCommand(MidiPlugin::DELCONTROL);
  254. }
  255. void MidiPluginGUI::cb_RemoveControl(Fl_Button* o, void* v)
  256. { ((MidiPluginGUI*)(o->parent()))->cb_RemoveControl_i(o,v);}
  257. const string MidiPluginGUI::GetHelpText(const string &loc){
  258. return string("")
  259. + "A plugin that converts midi signals into SSM's CVs. The midi plugin\n"
  260. + "outputs a Frequency CV, which comes from the last note pressed and\n"
  261. + "Trigger CV which lets you know the timing and the velocity of the\n"
  262. + "event.\n"
  263. + "It also detects pitchbend, channel pressure and aftertouch information,\n"
  264. + "and outputs these as continuous CV data.\n\n"
  265. + "You can select the Midi device used with the selector. Devices 0-16 are\n"
  266. + "valid Midi channels. You can run multiple Midi plugins simultaneously\n"
  267. + "to get data from different device numbers to make an externally\n"
  268. + "controlled song.\n\n"
  269. + "The note frequency CV can optionally be switched into \"Note Cut\" mode,\n"
  270. + "where the frequecy is set to zero when the key is released. This is\n"
  271. + "useful for a number of things, including retriggering samples from\n"
  272. + "frequency information (see sampler).\n"
  273. + "Extra ports can be added to handle the 128 controller messages. Click\n"
  274. + "add control, and you will get a menu window to pick the controller you\n"
  275. + "need.\n"
  276. + "The MidiPlugin also supports midi note output to external devices";
  277. }