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.

99 lines
2.5KB

  1. /* SpiralSound
  2. * Copyleft (C) 2001 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 "../SpiralPlugin.h"
  19. #include "../../RiffWav.h"
  20. #include <FL/Fl_Pixmap.H>
  21. #ifndef StreamPLUGIN
  22. #define StreamPLUGIN
  23. static const int NUDGESIZE=44100/4;
  24. struct SampleDesc
  25. {
  26. string Pathname;
  27. float Volume;
  28. float Pitch;
  29. float PitchMod;
  30. bool Loop;
  31. int Note;
  32. bool TriggerUp;
  33. float SamplePos;
  34. int SampleRate;
  35. bool Stereo;
  36. };
  37. class StreamPlugin : public SpiralPlugin
  38. {
  39. public:
  40. enum Mode{PLAYM,STOPM};
  41. enum GUICommands{NONE,LOAD,RESTART,STOP,PLAY,HALF,RESET,DOUBLE,NUDGE,SET_TIME};
  42. StreamPlugin();
  43. virtual ~StreamPlugin();
  44. virtual PluginInfo &Initialise(const HostInfo *Host);
  45. virtual SpiralGUIType *CreateGUI();
  46. virtual void Execute();
  47. virtual void ExecuteCommands();
  48. virtual void StreamOut(ostream &s);
  49. virtual void StreamIn(istream &s);
  50. // has to be defined in the plugin
  51. virtual void UpdateGUI() { Fl::check(); }
  52. void OpenStream(const string &Name);
  53. void SetVolume(float s) { m_StreamDesc.Volume=s; }
  54. float GetVolume() { return m_StreamDesc.Volume; }
  55. void SetPitch(float s) { m_StreamDesc.PitchMod=s; }
  56. float GetPitch() { return m_StreamDesc.PitchMod; }
  57. void SetLoop(bool s) { m_StreamDesc.Loop=s; }
  58. bool GetLoop() { return m_StreamDesc.Loop; }
  59. float GetLength();
  60. float GetTime() { return m_GlobalPos/(float)m_StreamDesc.SampleRate; }
  61. void SetTime(float t);
  62. void Nudge() { m_Pos-=NUDGESIZE; }
  63. void Restart();
  64. void Play();
  65. void Stop();
  66. private:
  67. WavFile m_File;
  68. Sample m_SampleL;
  69. Sample m_SampleR;
  70. SampleDesc m_StreamDesc;
  71. int m_SampleSize;
  72. float m_Pos;
  73. int m_StreamPos;
  74. float m_GlobalPos;
  75. float m_Pitch;
  76. Mode m_Mode;
  77. char m_FileNameArg[256];
  78. float m_TimeArg;
  79. float m_TimeOut;
  80. float m_MaxTime;
  81. };
  82. #endif