Audio plugin host https://kx.studio/carla
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.

73 lines
2.1KB

  1. /*************************************************************************************
  2. * Original code copyright (C) 2012 Steve Folta
  3. * Converted to Juce module (C) 2016 Leo Olivers
  4. * Forked from https://github.com/stevefolta/SFZero
  5. * For license info please see the LICENSE file distributed with this source code
  6. *************************************************************************************/
  7. #ifndef SFZSOUND_H_INCLUDED
  8. #define SFZSOUND_H_INCLUDED
  9. #include "SFZRegion.h"
  10. #include "water/containers/HashMap.h"
  11. #include "water/synthesisers/Synthesiser.h"
  12. #include "water/text/StringArray.h"
  13. #include "CarlaThread.hpp"
  14. namespace sfzero
  15. {
  16. class Sample;
  17. class Sound : public water::SynthesiserSound
  18. {
  19. public:
  20. struct LoadingIdleCallback {
  21. void (*callback)(void*);
  22. void* callbackPtr;
  23. };
  24. explicit Sound(const water::File &file);
  25. virtual ~Sound();
  26. typedef water::ReferenceCountedObjectPtr<Sound> Ptr;
  27. bool appliesToNote(int midiNoteNumber) override;
  28. bool appliesToChannel(int midiChannel) override;
  29. void addRegion(Region *region); // Takes ownership of the region.
  30. Sample *addSample(water::String path, water::String defaultPath = water::String());
  31. void addError(const water::String &message);
  32. void addUnsupportedOpcode(const water::String &opcode);
  33. virtual void loadRegions();
  34. virtual void loadSamples(const LoadingIdleCallback& cb);
  35. Region *getRegionFor(int note, int velocity, Region::Trigger trigger = Region::attack);
  36. int getNumRegions();
  37. Region *regionAt(int index);
  38. const water::StringArray &getErrors() { return errors_; }
  39. const water::StringArray &getWarnings() { return warnings_; }
  40. water::String dump();
  41. void dumpToConsole();
  42. water::Array<Region *> &getRegions() { return regions_; }
  43. water::File &getFile() { return file_; }
  44. private:
  45. water::File file_;
  46. water::Array<Region *> regions_;
  47. water::HashMap<water::String, Sample *> samples_;
  48. water::StringArray errors_;
  49. water::StringArray warnings_;
  50. water::HashMap<water::String, water::String> unsupportedOpcodes_;
  51. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Sound)
  52. };
  53. }
  54. #endif // SFZSOUND_H_INCLUDED