Imperfector.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #ifndef IMPERFECTORSTATE_H
  3. #define IMPERFECTORSTATE_H
  4. #include "Jukebox.h"
  5. #include <utility>
  6. /*
  7. include guards: In basic sample they uses this to check if this guard is define, if not, it`s starts define it
  8. */
  9. class CImperfector
  10. {
  11. public: explicit CImperfector();
  12. // No destructor since this class is allocated by JBox_Export_CreateNativeObject,
  13. // which means that the destructor would never be called anyway (though any memory we allocated will be automatically deallocated)
  14. // public: ~CVerySimpleSampler();
  15. /**
  16. * @brief Checks incoming diffs to see if they're note on:s/note offs (i.e. MIDI notes) and if so, add voices to the voice pool
  17. * also checks any changes of the sample parameters
  18. */
  19. private: void HandleDiffs(const TJBox_PropertyDiff iPropertyDiffs[], TJBox_UInt32 iDiffCount);
  20. private: TJBox_Int64 TagToInt(const TJBox_Tag iTag) const;
  21. private: TJBox_Bool TagToBool(const TJBox_Tag iTag) const;
  22. private: TJBox_Float64 TagToFloat(const TJBox_Tag iTag) const;
  23. public: void FlashNoteOnLamp();
  24. public: void HandleNoteOnLampTurnOff();
  25. public: void ResetIfRequested();
  26. /**
  27. * @brief Main starting point for rendering audio
  28. * @details One of the first thing you'll stumble upon as a rack extension developer is if properties should be
  29. * fetched using "diffs" or by use of Jukebox SDK functions such as JBox_LoadMOMProperty. You have both
  30. * options and they have their pros and cons. In this example most properties are fetched using
  31. * JBox_LoadMOMProperty, but note diffs are fetched through iPropertyDiffs. In order to get these diffs
  32. * you have to set them up in realtime_controller.lua/rt_input_setup/notify .
  33. **/
  34. public: void RenderBatch(const TJBox_PropertyDiff iPropertyDiffs[], TJBox_UInt32 iDiffCount);
  35. // State created in CreateNativeObject, references to different kind of properties in host
  36. private: TJBox_ObjectRef fEnvironmentRef;
  37. private: TJBox_ObjectRef fDeviceHostRef;
  38. private: TJBox_ObjectRef fTransportRef;
  39. private: TJBox_ObjectRef fNoteStates;
  40. private: TJBox_ObjectRef fMotherBoardCustomPropertiesRef;
  41. // VerySimpleSampler specific property references
  42. private: TJBox_ObjectRef fAudioOutLeftObjectRef;
  43. private: TJBox_ObjectRef fAudioOutRightObjectRef;
  44. private: TJBox_PropertyRef fNoteOnPropertyRef;
  45. private: TJBox_PropertyRef fSampleDataStringPropertyRef;
  46. // State only valid during a RenderBatch call
  47. private: TJBox_Float64 fSampleRate;
  48. // State to be used between calls (remembering last values)
  49. private: TJBox_Float64 fLastRequestResetCounter;
  50. private: TJBox_Float64 fSecondsBeforeNoteOnTurnOff;
  51. // // References to the native objects containing samples
  52. //private: NSUtil::StaticVector<TJBox_PropertyRef, kNumberOfSampleZones> fSampleNativeObjectRefs;
  53. // // The current sample parameters for each zone
  54. //private: NSUtil::StaticVector<TGUISampleParameters, kNumberOfSampleZones> fSampleZoneParameters;
  55. // // References to each sample parameter for each zone
  56. //private: NSUtil::StaticVector<TJBox_ObjectRef, kNumberOfSampleZones> fSampleZoneObjectRefs;
  57. // // Our main pool of voices that render audio data
  58. //private: CVoicePool fVoicePool;
  59. private: bool fSampleDisplayNeedsUpdate;
  60. private: std::size_t fLastSampleZoneIndex;
  61. };
  62. #endif