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.

106 lines
3.6KB

  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 <FL/Fl_Pixmap.H>
  20. #ifndef PoshSamplerPLUGIN
  21. #define PoshSamplerPLUGIN
  22. static const int NUM_SAMPLES = 8;
  23. struct SampleDesc
  24. {
  25. string Pathname;
  26. float Volume;
  27. float Velocity;
  28. float Pitch;
  29. float PitchMod;
  30. bool Loop;
  31. bool PingPong;
  32. int Note;
  33. int Octave;
  34. bool TriggerUp;
  35. float SamplePos;
  36. int SampleRate;
  37. bool Stereo;
  38. long PlayStart;
  39. long LoopStart;
  40. long LoopEnd;
  41. };
  42. class PoshSamplerPlugin : public SpiralPlugin
  43. {
  44. public:
  45. PoshSamplerPlugin();
  46. virtual ~PoshSamplerPlugin();
  47. virtual PluginInfo &Initialise(const HostInfo *Host);
  48. virtual SpiralGUIType *CreateGUI();
  49. virtual void Execute();
  50. virtual void StreamOut(ostream &s);
  51. virtual void StreamIn(istream &s);
  52. virtual bool SaveExternalFiles(const string &Dir);
  53. virtual void LoadExternalFiles(const string &Dir);
  54. void LoadSample(int n, const string &Name);
  55. void SaveSample(int n, const string &Name);
  56. Sample* GetSample(int n) { return m_SampleVec[n]; }
  57. void SetVolume(int n, float s) { m_SampleDescVec[n]->Volume=s; }
  58. float GetVolume(int n) { return m_SampleDescVec[n]->Volume; }
  59. void SetPitch(int n, float s) { m_SampleDescVec[n]->PitchMod=s; }
  60. float GetPitch(int n) { return m_SampleDescVec[n]->PitchMod; }
  61. void SetLoop(int n, bool s) { m_SampleDescVec[n]->Loop=s; }
  62. bool GetLoop(int n) { return m_SampleDescVec[n]->Loop; }
  63. void SetPingPong(int n, bool s){ m_SampleDescVec[n]->PingPong=s; }
  64. bool GetPingPong(int n) { return m_SampleDescVec[n]->PingPong; }
  65. void SetNote(int n, int s) { m_SampleDescVec[n]->Note=s; }
  66. int GetNote(int n) { return m_SampleDescVec[n]->Note; }
  67. void SetOctave(int n, int s) { m_SampleDescVec[n]->Octave=s-6; }
  68. int GetOctave(int n) { return m_SampleDescVec[n]->Octave+6; }
  69. //void SetSampleNum(int n, int s){ m_SampleDescVec[n]->Note=s; }
  70. //int GetSampleNum(int n) { return m_SampleDescVec[n]->Note; }
  71. void SetPlayStart(int n, long s) { m_SampleDescVec[n]->PlayStart=s; }
  72. long GetPlayStart(int n) { return m_SampleDescVec[n]->PlayStart; }
  73. void SetLoopStart(int n, long s) { m_SampleDescVec[n]->LoopStart=s; }
  74. long GetLoopStart(int n) { return m_SampleDescVec[n]->LoopStart; }
  75. void SetLoopEnd(int n, long s) { m_SampleDescVec[n]->LoopEnd=s; }
  76. long GetLoopEnd(int n) { return m_SampleDescVec[n]->LoopEnd; }
  77. void SetRecord(bool s) { m_Recording=s; }
  78. void Cut(int n, long s, long e);
  79. void Copy(int n, long s, long e);
  80. void Paste(int n, long s, long e);
  81. void Mix(int n, long s, long e);
  82. void Crop(int n, long s, long e);
  83. void Reverse(int n, long s, long e);
  84. void Amp(int n, long s, long e);
  85. vector<Sample*> m_SampleVec;
  86. vector<SampleDesc*> m_SampleDescVec;
  87. private:
  88. Sample m_CopyBuffer;
  89. bool m_Recording;
  90. };
  91. #endif