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.

SFZVoice.h 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 curMidiNote_, curPitchWheel_;
  37. double pitchRatio_;
  38. float noteGainLeft_, noteGainRight_;
  39. double sourceSamplePosition_;
  40. EG ampeg_;
  41. water::int64 sampleEnd_;
  42. water::int64 loopStart_, loopEnd_;
  43. // Info only.
  44. int numLoops_;
  45. int curVelocity_;
  46. void calcPitchRatio();
  47. void killNote();
  48. double fractionalMidiNoteInHz(double note, double freqOfA = 440.0);
  49. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Voice)
  50. };
  51. }
  52. #endif // SFZVOICE_H_INCLUDED