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.

105 lines
2.7KB

  1. /* SpiralSound
  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 <iostream>
  19. #include <fstream>
  20. #include <stdlib.h>
  21. #include "FL/fl_draw.h"
  22. #include "FL/fl_message.h"
  23. #include "SpiralInfo.h"
  24. float RandFloat(float s, float e)
  25. {
  26. return s+((rand()%10000/10000.0)*(e-s));
  27. }
  28. void SpiralInfo::LoadPrefs()
  29. {
  30. string rcfn(m_HomeDir+"/"+GetResFileName());
  31. ifstream i(rcfn.c_str());
  32. if (!i)
  33. {
  34. cerr<<"Creating "<<rcfn<<endl;
  35. SavePrefs();
  36. return;
  37. }
  38. StreamInPrefs(i);
  39. }
  40. void SpiralInfo::SavePrefs()
  41. {
  42. string rcfn(m_HomeDir+"/"+GetResFileName());
  43. ofstream o(rcfn.c_str());
  44. StreamOutPrefs(o);
  45. }
  46. void SpiralInfo::StreamInPrefs(istream &s)
  47. {
  48. char temp[256];
  49. s>>temp>>temp>>temp;
  50. s>>temp>>temp>>m_Version;
  51. s>>temp>>temp>>LOCALE;
  52. s>>temp>>temp>>BUFSIZE;
  53. s>>temp>>temp>>FRAGSIZE;
  54. s>>temp>>temp>>FRAGCOUNT;
  55. s>>temp>>temp>>SAMPLERATE;
  56. s>>temp>>temp>>WANTMIDI;
  57. s>>temp>>temp>>FILTERGRAN;
  58. s>>temp>>temp>>OUTPUTFILE;
  59. s>>temp>>temp>>MIDIFILE;
  60. s>>temp>>temp>>REALTIMEOUT;
  61. s>>temp>>temp>>POLY;
  62. //s>>temp>>temp>>GUI_COLOUR;
  63. //s>>temp>>temp>>GUIBG_COLOUR;
  64. //s>>temp>>temp>>GUIBG2_COLOUR;
  65. }
  66. void SpiralInfo::StreamOutPrefs(ostream &s)
  67. {
  68. s<<"SpiralSound resource file"<<endl<<endl;
  69. s<<"Version = "<<m_Version<<endl;
  70. s<<"Locale = "<<LOCALE<<endl;
  71. s<<"BufferSize = "<<BUFSIZE<<endl;
  72. s<<"FragmentSize = "<<FRAGSIZE<<endl;
  73. s<<"FragmentCount = "<<FRAGCOUNT<<endl;
  74. s<<"Samplerate = "<<SAMPLERATE<<endl;
  75. s<<"WantMidi = "<<WANTMIDI<<endl;
  76. s<<"FilterGranularity = "<<FILTERGRAN<<endl;
  77. s<<"Output = "<<OUTPUTFILE<<endl;
  78. s<<"Midi = "<<MIDIFILE<<endl;
  79. s<<"WantRealtimeOut = "<<REALTIMEOUT<<endl;
  80. s<<"Polyphony = "<<POLY<<endl;
  81. //s<<"GUIColour = "<<GUI_COLOUR<<endl;
  82. //s<<"GUIBGColour = "<<GUIBG_COLOUR<<endl;
  83. //s<<"GUIBG2Colour = "<<GUIBG2_COLOUR<<endl;
  84. }
  85. void SpiralInfo::Alert(string Text)
  86. {
  87. fl_message(Text.c_str());
  88. }
  89. void SpiralInfo::Log(string Text)
  90. {
  91. }