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.

59 lines
1.8KB

  1. /* Copyright 2013-2019 Matt Tytel
  2. *
  3. * vital is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * vital is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with vital. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #include "JuceHeader.h"
  18. #include "wave_frame.h"
  19. #include "wavetable_component.h"
  20. namespace vital {
  21. class Wavetable;
  22. } // namespace vital
  23. class WavetableGroup {
  24. public:
  25. WavetableGroup() { }
  26. int getComponentIndex(WavetableComponent* component);
  27. void addComponent(WavetableComponent* component) {
  28. components_.push_back(std::unique_ptr< WavetableComponent>(component));
  29. }
  30. void removeComponent(int index);
  31. void moveUp(int index);
  32. void moveDown(int index);
  33. void reset();
  34. void prerender();
  35. int numComponents() const { return static_cast<int>(components_.size()); }
  36. WavetableComponent* getComponent(int index) const { return components_[index].get(); }
  37. bool isShepardTone();
  38. void render(vital::WaveFrame* wave_frame, float position) const;
  39. void renderTo(vital::Wavetable* wavetable);
  40. void loadDefaultGroup();
  41. int getLastKeyframePosition();
  42. json stateToJson();
  43. void jsonToState(json data);
  44. protected:
  45. vital::WaveFrame compute_frame_;
  46. std::vector<std::unique_ptr<WavetableComponent>> components_;
  47. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WavetableGroup)
  48. };