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.

134 lines
4.0KB

  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. static const int TRANSBUF_SIZE = 0x10000;
  24. struct SampleDesc
  25. {
  26. std::string Pathname;
  27. float Volume;
  28. float Velocity;
  29. float Pitch;
  30. float PitchMod;
  31. bool Loop;
  32. bool PingPong;
  33. int Note;
  34. int Octave;
  35. bool TriggerUp;
  36. float SamplePos;
  37. int SampleRate;
  38. bool Stereo;
  39. long PlayStart;
  40. long LoopStart;
  41. long LoopEnd;
  42. };
  43. class PoshSamplerPlugin : public SpiralPlugin
  44. {
  45. public:
  46. PoshSamplerPlugin();
  47. virtual ~PoshSamplerPlugin();
  48. virtual PluginInfo &Initialise(const HostInfo *Host);
  49. virtual SpiralGUIType *CreateGUI();
  50. virtual void Execute();
  51. virtual void ExecuteCommands();
  52. virtual void StreamOut(std::ostream &s);
  53. virtual void StreamIn(std::istream &s);
  54. virtual bool SaveExternalFiles(const std::string &Dir);
  55. virtual void LoadExternalFiles(const std::string &Dir, int withID=-1);
  56. enum GUICommands{NONE,LOAD,SAVE,SETVOL,SETPITCH,SETLOOP,SETPING,SETNOTE,SETOCT,
  57. SETPLAYPOINTS,SETREC,CUT,COPY,PASTE,CROP,MIX,REV,AMP,SETCURRENT,
  58. GETSAMPLE};
  59. struct GUIArgs
  60. {
  61. int Num;
  62. float Value;
  63. bool Boole;
  64. int Int;
  65. long Start;
  66. long End;
  67. long LoopStart;
  68. char Name[256];
  69. };
  70. void LoadSample(int n, const std::string &Name);
  71. void SaveSample(int n, const std::string &Name);
  72. Sample* GetSample(int n) { return m_SampleVec[n]; }
  73. float GetVolume(int n) { return m_SampleDescVec[n]->Volume; }
  74. float GetPitch(int n) { return m_SampleDescVec[n]->PitchMod; }
  75. bool GetLoop(int n) { return m_SampleDescVec[n]->Loop; }
  76. bool GetPingPong(int n) { return m_SampleDescVec[n]->PingPong; }
  77. int GetNote(int n) { return m_SampleDescVec[n]->Note; }
  78. int GetOctave(int n) { return m_SampleDescVec[n]->Octave+6; }
  79. long GetPlayStart(int n) { return m_SampleDescVec[n]->PlayStart; }
  80. long GetLoopStart(int n) { return m_SampleDescVec[n]->LoopStart; }
  81. long GetLoopEnd(int n) { return m_SampleDescVec[n]->LoopEnd; }
  82. std::vector<Sample*> m_SampleVec;
  83. std::vector<SampleDesc*> m_SampleDescVec;
  84. private:
  85. void SetVolume(int n, float s) { m_SampleDescVec[n]->Volume=s; }
  86. void SetPitch(int n, float s) { m_SampleDescVec[n]->PitchMod=s; }
  87. void SetLoop(int n, bool s) { m_SampleDescVec[n]->Loop=s; }
  88. void SetPingPong(int n, bool s){ m_SampleDescVec[n]->PingPong=s; }
  89. void SetNote(int n, int s) { m_SampleDescVec[n]->Note=s; }
  90. void SetOctave(int n, int s) { m_SampleDescVec[n]->Octave=s-6; }
  91. void SetPlayStart(int n, long s) { m_SampleDescVec[n]->PlayStart=s; }
  92. void SetLoopStart(int n, long s) { m_SampleDescVec[n]->LoopStart=s; }
  93. void SetLoopEnd(int n, long s) { m_SampleDescVec[n]->LoopEnd=s; }
  94. void SetRecord(bool s) { m_Recording=s; }
  95. void Cut(int n, long s, long e);
  96. void Copy(int n, long s, long e);
  97. void Paste(int n, long s, long e);
  98. void Mix(int n, long s, long e);
  99. void Crop(int n, long s, long e);
  100. void Reverse(int n, long s, long e);
  101. void Amp(int n, long s, long e);
  102. int m_Current;
  103. GUIArgs m_GUIArgs;
  104. Sample m_CopyBuffer;
  105. bool m_Recording;
  106. char m_SampleBuffer[TRANSBUF_SIZE];
  107. long m_SampleSize;
  108. long m_CurrentPlayPos;
  109. };
  110. #endif