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.

71 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. namespace sfzero
  14. {
  15. class Sample;
  16. class Sound : public water::SynthesiserSound
  17. {
  18. public:
  19. struct LoadingIdleCallback {
  20. void (*callback)(void*);
  21. void* callbackPtr;
  22. };
  23. explicit Sound(const water::File &file);
  24. virtual ~Sound();
  25. typedef water::ReferenceCountedObjectPtr<Sound> Ptr;
  26. bool appliesToNote(int midiNoteNumber) override;
  27. bool appliesToChannel(int midiChannel) override;
  28. void addRegion(Region *region); // Takes ownership of the region.
  29. Sample *addSample(water::String path, water::String defaultPath = water::String());
  30. void addError(const water::String &message);
  31. void addUnsupportedOpcode(const water::String &opcode);
  32. virtual void loadRegions();
  33. virtual void loadSamples(const LoadingIdleCallback& cb);
  34. Region *getRegionFor(int note, int velocity, Region::Trigger trigger = Region::attack);
  35. int getNumRegions();
  36. Region *regionAt(int index);
  37. const water::StringArray &getErrors() { return errors_; }
  38. const water::StringArray &getWarnings() { return warnings_; }
  39. water::String dump();
  40. void dumpToConsole();
  41. water::Array<Region *> &getRegions() { return regions_; }
  42. water::File &getFile() { return file_; }
  43. private:
  44. water::File file_;
  45. water::Array<Region *> regions_;
  46. water::HashMap<water::String, Sample *> samples_;
  47. water::StringArray errors_;
  48. water::StringArray warnings_;
  49. water::HashMap<water::String, water::String> unsupportedOpcodes_;
  50. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Sound)
  51. };
  52. }
  53. #endif // SFZSOUND_H_INCLUDED