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.

69 lines
1.9KB

  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 SFZVOICE_H_INCLUDED
  8. #define SFZVOICE_H_INCLUDED
  9. #include "SFZEG.h"
  10. #include "water/synthesisers/Synthesiser.h"
  11. namespace sfzero
  12. {
  13. struct Region;
  14. class Voice : public water::SynthesiserVoice
  15. {
  16. public:
  17. Voice();
  18. virtual ~Voice();
  19. bool canPlaySound(water::SynthesiserSound *sound) override;
  20. void startNote(int midiNoteNumber, float velocity, water::SynthesiserSound *sound, int currentPitchWheelPosition) override;
  21. void stopNote(float velocity, bool allowTailOff) override;
  22. void stopNoteForGroup();
  23. void stopNoteQuick();
  24. void pitchWheelMoved(int newValue) override;
  25. void controllerMoved(int controllerNumber, int newValue) override;
  26. void renderNextBlock(water::AudioSampleBuffer &outputBuffer, int startSample, int numSamples) override;
  27. bool isPlayingNoteDown();
  28. bool isPlayingOneShot();
  29. int getGroup();
  30. water::int64 getOffBy();
  31. // Set the region to be used by the next startNote().
  32. void setRegion(Region *nextRegion);
  33. water::String infoString();
  34. private:
  35. Region *region_;
  36. int trigger_;
  37. int curMidiNote_, curPitchWheel_;
  38. double pitchRatio_;
  39. float noteGainLeft_, noteGainRight_;
  40. double sourceSamplePosition_;
  41. EG ampeg_;
  42. water::int64 sampleEnd_;
  43. water::int64 loopStart_, loopEnd_;
  44. // Info only.
  45. int numLoops_;
  46. int curVelocity_;
  47. void calcPitchRatio();
  48. void killNote();
  49. double fractionalMidiNoteInHz(double note, double freqOfA = 440.0);
  50. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Voice)
  51. };
  52. }
  53. #endif // SFZVOICE_H_INCLUDED