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.

135 lines
4.1KB

  1. /* SpiralLoops
  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. #ifndef LOOP
  19. #define LOOP
  20. #include "SpiralSound/Filter.h"
  21. #include "GUI/LoopGUI.h"
  22. #include "../../Sample.h"
  23. class Loop
  24. {
  25. public:
  26. Loop();
  27. ~Loop();
  28. void LoadWav(const char *Filename);
  29. void SaveWav(const char *Filename);
  30. bool GetOutput(Sample &data);
  31. void AllocateMem(int Length);
  32. void Clear();
  33. void Hold() {m_StoreBuffer=m_HoldBuffer;}
  34. void Double();
  35. void MatchLength(int Len);
  36. void Crop();
  37. void StreamIn(istream &s);
  38. void StreamOut(ostream &s);
  39. void SetGUI(LoopGUI *s) { m_GUI=s; }
  40. void SetId(int Id) { m_Id=Id; }
  41. void SetCutoff(int c) { m_Filter.SetCutoff(c); }
  42. void SetResonance(int r) { m_Filter.SetResonance(r); }
  43. void SetPos(int Pos) { m_Pos=Pos; }
  44. void SetLength(int Len) { m_LoopPoint=Len; }
  45. void SetSpeed(float Speed) { m_Speed=Speed; }
  46. void SetVolume(float Vol) { m_Volume=Vol; }
  47. void SetPlaying(bool Playing) { m_Playing=Playing; }
  48. void SetRecordingSource(const float *s) { m_RecordingSource=s; }
  49. void Record(bool r) { m_Recording=r; if (!r) EndRecordBuf(); }
  50. void SetMasterStatus(bool m) { m_Master=m; }
  51. void FilterBypass(bool s) { m_Filter.FilterBypass(s); }
  52. void DelMe() { m_DelMe=true; }
  53. void SetBalance(float s) { m_Balance=s; m_LeftVol=(2-s)/2; m_RightVol=(1+s-1.0f)/2;}
  54. void Trigger() { m_Pos=0; SetPlaying(true); }
  55. void SetEffects(bool s) { m_EffectsOn=s; }
  56. const float GetVolume() {return m_Volume;}
  57. const float GetCutoff() {return m_Filter.GetCutoff();}
  58. const float GetResonance() {return m_Filter.GetCutoff();}
  59. const float GetBalance() {return m_Balance;}
  60. const bool GetEffects() {return m_EffectsOn;}
  61. const bool IsPlaying() {return m_Playing;}
  62. const float *GetLoopPtr() {return m_StoreBuffer.GetBuffer();}
  63. const int GetId() {return m_Id;}
  64. const int GetLoopLength() {return m_LoopPoint;}
  65. float *GetPosPtr() {return &m_Pos;}
  66. const int GetTotalLength() {assert(m_StoreBuffer.GetLength()==m_HoldBuffer.GetLength()); return m_StoreBuffer.GetLength();}
  67. const bool IsMaster() {return m_Master;}
  68. const bool Delete() {return m_DelMe; }
  69. const float GetSpeed() {return m_Speed;}
  70. const float GetLeftVol() { return m_LeftVol; }
  71. const float GetRightVol() { return m_RightVol; }
  72. const float GetCurrentAngle() { return m_LoopPoint?(m_Pos/m_LoopPoint)*360.0f:0; }
  73. const string& GetSampleName() { return m_Sample; }
  74. void Cut(int Start, int End);
  75. void Copy(int Start, int End);
  76. void Paste(int Start);
  77. void PasteMix(int Start);
  78. void ZeroRange(int Start, int End);
  79. void ReverseRange(int Start, int End);
  80. void Halve();
  81. void SelectAll();
  82. void Move(int Start);
  83. private:
  84. void RecordBuf(float Pos, int Length);
  85. void EndRecordBuf();
  86. Filter m_Filter;
  87. int m_Id;
  88. float m_Pos;
  89. int m_IntPos;
  90. int m_PlayBufPos;
  91. bool m_Playing;
  92. bool m_Recording;
  93. bool m_Master;
  94. bool m_DelMe;
  95. long int m_LoopPoint;
  96. float m_Speed;
  97. float m_Volume;
  98. const float *m_RecordingSource;
  99. Sample m_StoreBuffer;
  100. Sample m_HoldBuffer;
  101. Sample m_RecBuffer;
  102. int m_RecPos;
  103. float m_Balance;
  104. float m_LeftVol,m_RightVol;
  105. bool m_FirstRecord;
  106. bool m_FixedRecord;
  107. int m_RecLength;
  108. bool m_EffectsOn;
  109. string m_Sample;
  110. LoopGUI *m_GUI;
  111. friend istream &operator>>(istream &s, Loop &o);
  112. friend ostream &operator<<(ostream &s, Loop &o);
  113. };
  114. istream &operator>>(istream &s, Loop &o);
  115. ostream &operator<<(ostream &s, Loop &o);
  116. #endif