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.

203 lines
5.5KB

  1. /* SpiralSynthModular
  2. * Copyleft (C) 2002 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. #ifndef SPIRALSYNTHMODULAR
  19. #define SPIRALSYNTHMODULAR
  20. #include <FL/Fl.H>
  21. #include <FL/x.H>
  22. #include <FL/Fl_Double_Window.H>
  23. #include <FL/Fl_Group.H>
  24. #include <FL/Fl_Box.H>
  25. #include <FL/Fl_Button.H>
  26. #include <FL/Fl_Pixmap.H>
  27. #include <FL/Fl_Scroll.H>
  28. #include <FL/Fl_Pack.H>
  29. #include <FL/Fl_Tile.H>
  30. #include <sstream>
  31. #include <iostream>
  32. #include <map>
  33. #include "SpiralSynthModularInfo.h"
  34. #include "GUI/Widgets/Fl_DeviceGUI.h"
  35. #include "GUI/Widgets/Fl_CommentGUI.h"
  36. #include "GUI/Widgets/Fl_Canvas.h"
  37. #include "SpiralSound/Plugins/SpiralPlugin.h"
  38. #include "SpiralSound/ChannelHandler.h"
  39. #include "SettingsWindow.h"
  40. const static string VER_STRING = "0.2.0";
  41. typedef Fl_Double_Window SpiralWindowType;
  42. // typedef Fl_Window SpiralWindowType;
  43. class SettingsWindow;
  44. class DeviceWin
  45. {
  46. public:
  47. DeviceWin() : m_DeviceGUI(NULL) {}
  48. ~DeviceWin();
  49. int m_PluginID;
  50. SpiralPlugin* m_Device;
  51. Fl_DeviceGUI* m_DeviceGUI;
  52. };
  53. class SynthModular
  54. {
  55. public:
  56. SynthModular();
  57. ~SynthModular();
  58. SpiralWindowType * CreateWindow();
  59. void LoadPlugins(string pluginPath);
  60. void Update();
  61. void AddDevice(int n, int x, int y);
  62. void AddComment(int n);
  63. void ClearUp();
  64. void UpdateHostInfo();
  65. bool CallbackMode() { return m_CallbackUpdateMode; }
  66. bool IsBlockingOutputPluginReady() { return m_BlockingOutputPluginIsReady; }
  67. void UpdatePluginGUIs();
  68. void LoadPatch(const char *fn);
  69. void PauseAudio()
  70. {
  71. m_CH.Set("PauseAudio",true);
  72. m_CH.Wait();
  73. }
  74. void ResumeAudio()
  75. {
  76. m_CH.Set("PauseAudio",false);
  77. }
  78. // only for audio thread
  79. bool IsPaused() { return m_PauseAudio; }
  80. private:
  81. vector<string> BuildPluginList(const string &Path);
  82. DeviceWin* NewDeviceWin(int n, int x, int y);
  83. DeviceWin* NewComment(int n, int x, int y);
  84. HostInfo m_Info;
  85. static DeviceGUIInfo BuildDeviceGUIInfo(PluginInfo &PInfo);
  86. // currently static, to allow the callback
  87. // cb_UpdatePluginInfo to access the map.
  88. static map<int,DeviceWin*> m_DeviceWinMap;
  89. int m_NextID;
  90. int m_NextPluginButton;
  91. int m_NextPluginButtonXPos;
  92. int m_NextPluginButtonYPos;
  93. static bool m_CallbackUpdateMode;
  94. static bool m_BlockingOutputPluginIsReady;
  95. string m_FilePath;
  96. // Main GUI stuff
  97. void CreateGUI(int xoff=0, int yoff=0, char *name="");
  98. Fl_Group *m_MainButtons;
  99. Fl_Button *m_Load;
  100. Fl_Button *m_Save;
  101. Fl_Button *m_New;
  102. Fl_Button *m_OpenEditor;
  103. Fl_Button *m_Options;
  104. Fl_Canvas *m_Canvas;
  105. Fl_Scroll *m_CanvasScroll;
  106. Fl_Scroll *m_ToolBox;
  107. Fl_Button *m_NewComment;
  108. Fl_Box *m_GroupName;
  109. Fl_Button *m_PluginGroupLeft;
  110. Fl_Button *m_PluginGroupRight;
  111. class ToolBox
  112. {
  113. public:
  114. ToolBox(Fl_Scroll *parent, void* user);
  115. ~ToolBox() {}
  116. void AddIcon(Fl_Button *Icon);
  117. Fl_Pack *GetToolPack() { return m_ToolPack; }
  118. private:
  119. Fl_Pack *m_ToolPack;
  120. Fl_Pack *m_IconPack;
  121. int m_Icon;
  122. };
  123. map<string,ToolBox*> m_PluginGroupMap;
  124. map<string,ToolBox*>::iterator m_CurrentGroup;
  125. SettingsWindow *m_SettingsWindow;
  126. SpiralWindowType* m_TopWindow;
  127. vector<Fl_Button*> m_DeviceVec;
  128. ChannelHandler m_CH; // used for threadsafe communication
  129. bool m_PauseAudio;
  130. inline void cb_NewDevice_i(Fl_Button* o, void* v);
  131. static void cb_NewDevice(Fl_Button* o, void* v);
  132. inline void cb_NewDeviceFromMenu_i(Fl_Canvas* o, void* v);
  133. static void cb_NewDeviceFromMenu(Fl_Canvas* o, void* v);
  134. inline void cb_NewComment_i(Fl_Button* o, void* v);
  135. static void cb_NewComment(Fl_Button* o, void* v);
  136. inline void cb_Load_i(Fl_Button* o, void* v);
  137. static void cb_Load(Fl_Button* o, void* v);
  138. inline void cb_Save_i(Fl_Button* o, void* v);
  139. static void cb_Save(Fl_Button* o, void* v);
  140. inline void cb_New_i(Fl_Button* o, void* v);
  141. static void cb_New(Fl_Button* o, void* v);
  142. inline void cb_Connection_i(Fl_Canvas* o, void* v);
  143. static void cb_Connection(Fl_Canvas* o, void* v);
  144. inline void cb_Unconnect_i(Fl_Canvas* o, void* v);
  145. static void cb_Unconnect(Fl_Canvas* o, void* v);
  146. inline void cb_Close_i(Fl_Window* o, void* v);
  147. static void cb_Close(Fl_Window* o, void* v);
  148. inline void cb_PluginGroupLeft_i(Fl_Button* o, void* v);
  149. static void cb_PluginGroupLeft(Fl_Button* o, void* v);
  150. inline void cb_PluginGroupRight_i(Fl_Button* o, void* v);
  151. static void cb_PluginGroupRight(Fl_Button* o, void* v);
  152. inline void cb_Rload_i(Fl_Button* o, void* v);
  153. static void cb_Rload(Fl_Button* o, void* v);
  154. static void cb_Update(void* o, bool Mode);
  155. static void cb_Blocking(void* o, bool Mode);
  156. static void cb_UpdatePluginInfo(int ID, void *PluginInfo);
  157. friend istream &operator>>(istream &s, SynthModular &o);
  158. friend ostream &operator<<(ostream &s, SynthModular &o);
  159. };
  160. istream &operator>>(istream &s, SynthModular &o);
  161. ostream &operator<<(ostream &s, SynthModular &o);
  162. #endif