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.

98 lines
3.8KB

  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. #ifndef PoshSamplerPLUGIN
  19. #define PoshSamplerPLUGIN
  20. #include "../SpiralPlugin.h"
  21. #include <FL/Fl_Pixmap.H>
  22. static const int NUM_SAMPLES = 8;
  23. static const int TRANSBUF_SIZE = 0x10000;
  24. struct SampleDesc {
  25. float Volume, Velocity, Pitch, PitchMod;
  26. bool Loop, PingPong;
  27. int Note, Octave;
  28. bool TriggerUp;
  29. float SamplePos;
  30. int SampleRate;
  31. bool Stereo;
  32. long PlayStart, LoopStart, LoopEnd;
  33. bool ReTrig;
  34. };
  35. class PoshSamplerPlugin : public SpiralPlugin {
  36. public:
  37. PoshSamplerPlugin();
  38. virtual ~PoshSamplerPlugin();
  39. virtual PluginInfo &Initialise (const HostInfo *Host);
  40. virtual SpiralGUIType *CreateGUI();
  41. virtual void Execute();
  42. virtual void Reset();
  43. virtual void ExecuteCommands();
  44. virtual void StreamOut (std::ostream &s);
  45. virtual void StreamIn (std::istream &s);
  46. virtual bool SaveExternalFiles (const std::string &Dir);
  47. virtual void LoadExternalFiles (const std::string &Dir, int withID=-1);
  48. enum GUICommands {NONE, LOAD, SAVE, SETVOL, SETPITCH, SETLOOP, SETPING, SETNOTE, SETOCT,
  49. SETPLAYPOINTS, SETREC, CUT, COPY, PASTE, CROP, MIX, REV, AMP, SETCURRENT,
  50. GETSAMPLE, SETRETRIG, GETLOOP, GETPING, GETRETRIG, GETVOL, GETPITCH, GETOCT,
  51. GETNOTE};
  52. struct GUIArgs {
  53. int Num, Int, IntEcho;
  54. float Value, ValEcho;
  55. bool Boole, BoolEcho;
  56. long Start, End, LoopStart;
  57. char Name[256];
  58. };
  59. void LoadSample (int n, const std::string &Name);
  60. void SaveSample (int n, const std::string &Name);
  61. Sample* GetSample (int n) { return m_SampleVec[n]; }
  62. float GetVolume (int n) { return m_SampleDescVec[n]->Volume; }
  63. float GetPitch (int n) { return m_SampleDescVec[n]->PitchMod; }
  64. bool GetReTrig (int n) { return m_SampleDescVec[n]->ReTrig; }
  65. bool GetLoop (int n) { return m_SampleDescVec[n]->Loop; }
  66. bool GetPingPong (int n) { return m_SampleDescVec[n]->PingPong; }
  67. int GetNote (int n) { return m_SampleDescVec[n]->Note; }
  68. int GetOctave (int n) { return m_SampleDescVec[n]->Octave+6; }
  69. long GetPlayStart (int n) { return m_SampleDescVec[n]->PlayStart; }
  70. long GetLoopStart (int n) { return m_SampleDescVec[n]->LoopStart; }
  71. long GetLoopEnd (int n) { return m_SampleDescVec[n]->LoopEnd; }
  72. std::vector<Sample*> m_SampleVec;
  73. std::vector<SampleDesc*> m_SampleDescVec;
  74. private:
  75. void InitializeSampleDescription (SampleDesc* NewDesc, int num, int Note);
  76. void Cut (int n, long s, long e);
  77. void Copy (int n, long s, long e);
  78. void Paste (int n, long s, long e);
  79. void Mix (int n, long s, long e);
  80. void Crop (int n, long s, long e);
  81. void Reverse (int n, long s, long e);
  82. void Amp (int n, long s, long e);
  83. int m_Current;
  84. GUIArgs m_GUIArgs;
  85. Sample m_CopyBuffer;
  86. bool m_Recording;
  87. char m_SampleBuffer[TRANSBUF_SIZE];
  88. long m_SampleSize, m_CurrentPlayPos;
  89. float m_InitialPitch[NUM_SAMPLES];
  90. };
  91. #endif