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.

221 lines
6.4KB

  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. #include <sys/types.h>
  19. #include <sys/stat.h>
  20. #include <dirent.h>
  21. #include <dlfcn.h>
  22. #include "SpiralSynthModularInfo.h"
  23. #include "SpiralSynthPluginLocation.h"
  24. #include "FL/fl_draw.h"
  25. string SpiralInfo::LOCALE = "EN";
  26. int SpiralInfo::BUFSIZE = 512;
  27. int SpiralInfo::FRAGSIZE = 256;
  28. int SpiralInfo::FRAGCOUNT = 8;
  29. int SpiralInfo::SAMPLERATE = 44100;
  30. long SpiralInfo::MAXSAMPLE = 32767;
  31. float SpiralInfo::VALUECONV = 1.0f/MAXSAMPLE;
  32. bool SpiralInfo::WANTMIDI = false;
  33. int SpiralInfo::FILTERGRAN = 50;
  34. string SpiralInfo::OUTPUTFILE = "/dev/dsp";
  35. string SpiralInfo::MIDIFILE = "/dev/midi";
  36. int SpiralInfo::POLY = 1;
  37. bool SpiralInfo::REALTIMEOUT = true;
  38. //int SpiralInfo::GUI_COLOUR = 139;
  39. //int SpiralInfo::GUIBG_COLOUR = 0;
  40. //int SpiralInfo::GUIBG2_COLOUR = 49;//45;
  41. int SpiralSynthModularInfo::GUICOL_Tool=179;
  42. int SpiralSynthModularInfo::GUICOL_Button=181;
  43. int SpiralSynthModularInfo::GUICOL_Canvas=181;
  44. int SpiralSynthModularInfo::GUICOL_Device=181;
  45. string SpiralSynthModularInfo::BGIMG;
  46. vector<string> SpiralSynthModularInfo::PLUGINVEC;
  47. string SpiralSynthModularInfo::PLUGIN_PATH;
  48. SpiralSynthModularInfo* SpiralSynthModularInfo::m_SpiralSynthModularInfo=NULL;
  49. SpiralSynthModularInfo* SpiralSynthModularInfo::Get()
  50. {
  51. if (!m_SpiralSynthModularInfo)
  52. {
  53. m_SpiralSynthModularInfo = new SpiralSynthModularInfo;
  54. }
  55. return m_SpiralSynthModularInfo;
  56. }
  57. SpiralSynthModularInfo::SpiralSynthModularInfo()
  58. {
  59. BGIMG="None";
  60. // default plugins + path, check these before dist...
  61. // this is one of the two plugin lists, th other is in
  62. // the SpiralSound/Plugins/PluginList.txt for the
  63. // configure/make/install scripts
  64. PLUGIN_PATH = PLUGIN_PATH_LOCATION;
  65. #ifdef SSM_EXPLICIT_PLUGIN_LIST
  66. PLUGINVEC.push_back("OutputPlugin.so");
  67. PLUGINVEC.push_back("DiskWriterPlugin.so");
  68. PLUGINVEC.push_back("ScopePlugin.so");
  69. PLUGINVEC.push_back("MidiPlugin.so");
  70. PLUGINVEC.push_back("KeyboardPlugin.so");
  71. PLUGINVEC.push_back("ControllerPlugin.so");
  72. PLUGINVEC.push_back("MatrixPlugin.so");
  73. PLUGINVEC.push_back("SeqSelectorPlugin.so");
  74. PLUGINVEC.push_back("SequencerPlugin.so");
  75. PLUGINVEC.push_back("PoshSamplerPlugin.so");
  76. PLUGINVEC.push_back("WaveTablePlugin.so");
  77. PLUGINVEC.push_back("OscillatorPlugin.so");
  78. PLUGINVEC.push_back("LFOPlugin.so");
  79. PLUGINVEC.push_back("NoisePlugin.so");
  80. PLUGINVEC.push_back("EnvelopePlugin.so");
  81. PLUGINVEC.push_back("SampleHoldPlugin.so");
  82. PLUGINVEC.push_back("NoteSnapPlugin.so");
  83. PLUGINVEC.push_back("MixerPlugin.so");
  84. PLUGINVEC.push_back("StereoMixerPlugin.so");
  85. PLUGINVEC.push_back("AmpPlugin.so");
  86. PLUGINVEC.push_back("RingModPlugin.so");
  87. PLUGINVEC.push_back("FilterPlugin.so");
  88. PLUGINVEC.push_back("SVFilterPlugin.so");
  89. PLUGINVEC.push_back("MoogFilterPlugin.so");
  90. PLUGINVEC.push_back("FormantPlugin.so");
  91. PLUGINVEC.push_back("AnotherFilterPlugin.so");
  92. PLUGINVEC.push_back("EchoPlugin.so");
  93. PLUGINVEC.push_back("DelayPlugin.so");
  94. PLUGINVEC.push_back("EnvFollowerPlugin.so");
  95. PLUGINVEC.push_back("SmoothPlugin.so");
  96. PLUGINVEC.push_back("LADSPAPlugin.so");
  97. PLUGINVEC.push_back("XFadePlugin.so");
  98. PLUGINVEC.push_back("DistributorPlugin.so");
  99. PLUGINVEC.push_back("SplitterPlugin.so");
  100. PLUGINVEC.push_back("StreamPlugin.so");
  101. PLUGINVEC.push_back("OperatorPlugin.so");
  102. PLUGINVEC.push_back("CounterPlugin.so");
  103. PLUGINVEC.push_back("FlipflopPlugin.so");
  104. PLUGINVEC.push_back("SwitchPlugin.so");
  105. PLUGINVEC.push_back("BeatMatchPlugin.so");
  106. PLUGINVEC.push_back("LogicPlugin.so");
  107. #else
  108. // Scan plugin path for plugins.
  109. DIR *dp;
  110. struct dirent *ep;
  111. struct stat sb;
  112. void *handle;
  113. string fullpath;
  114. const char *path = PLUGIN_PATH.c_str();
  115. dp = opendir(path);
  116. if (!dp) {
  117. cerr << "WARNING: Could not open path " << path << endl;
  118. } else {
  119. while ((ep = readdir(dp))) {
  120. // Need full path
  121. fullpath = path;
  122. fullpath.append(ep->d_name);
  123. // Stat file to get type
  124. if (!stat(fullpath.c_str(), &sb)) {
  125. // We only want regular files
  126. if (S_ISREG(sb.st_mode)) {
  127. // We're not fussed about resolving symbols yet, since we are just
  128. // checking if it's a DLL.
  129. handle = dlopen(fullpath.c_str(), RTLD_LAZY);
  130. if (!handle) {
  131. cerr << "WARNING: File " << path << ep->d_name
  132. << " could not be examined" << endl;
  133. cerr << "dlerror() output:" << endl;
  134. cerr << dlerror() << endl;
  135. } else {
  136. // It's a DLL. Add name to list
  137. PLUGINVEC.push_back(ep->d_name);
  138. }
  139. }
  140. }
  141. }
  142. }
  143. #endif
  144. }
  145. void SpiralSynthModularInfo::StreamInPrefs(istream &s)
  146. {
  147. // call base class
  148. SpiralInfo::StreamInPrefs(s);
  149. char temp[256];
  150. s>>temp>>temp;
  151. s>>temp>>temp>>GUICOL_Tool;
  152. s>>temp>>temp>>GUICOL_Button;
  153. s>>temp>>temp>>GUICOL_Canvas;
  154. s>>temp>>temp>>GUICOL_Device;
  155. s>>temp>>temp>>BGIMG;
  156. s>>temp>>temp>>PLUGIN_PATH;
  157. s>>temp>>temp;
  158. string st;
  159. #ifdef SSM_EXPLICIT_PLUGIN_LIST
  160. PLUGINVEC.clear();
  161. while(st!="end" && !s.eof())
  162. {
  163. s>>st;
  164. if (st!="end") PLUGINVEC.push_back(st);
  165. }
  166. #endif
  167. #if __APPLE__
  168. // ignore custom paths, plugins are encapsulated in the app anyway
  169. // this prevents the program to fail if the user move the application icon
  170. PLUGIN_PATH = PLUGIN_PATH_LOCATION;
  171. #endif
  172. }
  173. void SpiralSynthModularInfo::StreamOutPrefs(ostream &s)
  174. {
  175. // call base class
  176. SpiralInfo::StreamOutPrefs(s);
  177. s<<endl<<"SpiralSynthModular Info:"<<endl<<endl;
  178. s<<"ToolBoxColour = "<<GUICOL_Tool<<endl;
  179. s<<"ButtonColour = "<<GUICOL_Button<<endl;
  180. s<<"CanvasColour = "<<GUICOL_Canvas<<endl;
  181. s<<"DeviceColour = "<<GUICOL_Device<<endl;
  182. s<<"BGImagePNG = "<<BGIMG<<endl<<endl;
  183. s<<"PluginPath = "<<PLUGIN_PATH<<endl<<endl;
  184. s<<"PluginList = "<<endl;
  185. for (vector<string>::iterator i=PLUGINVEC.begin();
  186. i!=PLUGINVEC.end(); i++)
  187. {
  188. s<<*i<<endl;
  189. }
  190. s<<"end"<<endl;
  191. }