string_container.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* string_container.h - contains a collection of strings
  2. *
  3. * Copyright (c) 2006 Danny McRae <khjklujn/at/yahoo/com>
  4. *
  5. * This file is part of LMMS - https://lmms.io
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public
  18. * License along with this program (see COPYING); if not, write to the
  19. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20. * Boston, MA 02110-1301 USA.
  21. *
  22. */
  23. #ifndef _STRING_CONTAINER_H
  24. #define _STRING_CONTAINER_H
  25. #include <QVector>
  26. #include "vibrating_string.h"
  27. #include "MemoryManager.h"
  28. class stringContainer
  29. {
  30. MM_OPERATORS
  31. public:
  32. stringContainer(const float _pitch,
  33. const sample_rate_t _sample_rate,
  34. const int _buffer_length,
  35. const int _strings = 9 );
  36. void addString( int _harm,
  37. const float _pick,
  38. const float _pickup,
  39. const float * _impluse,
  40. const float _randomize,
  41. const float _string_loss,
  42. const float _detune,
  43. const int _oversample,
  44. const bool _state,
  45. const int _id );
  46. bool exists( int _id ) const
  47. {
  48. return m_exists[_id];
  49. }
  50. ~stringContainer()
  51. {
  52. int strings = m_strings.count();
  53. for( int i = 0; i < strings; i++ )
  54. {
  55. delete m_strings[i];
  56. }
  57. }
  58. float getStringSample( int _string )
  59. {
  60. return m_strings[_string]->nextSample();
  61. }
  62. private:
  63. QVector<vibratingString *> m_strings;
  64. const float m_pitch;
  65. const sample_rate_t m_sampleRate;
  66. const int m_bufferLength;
  67. QVector<bool> m_exists;
  68. } ;
  69. #endif