48class GranularProcessor {
50 GranularProcessor() { getBuffer(); }
51 GranularProcessor(
const GranularProcessor& other);
53 [[nodiscard]] int32_t getSamplesToShutdown()
const {
return wrapsToShutdown * kModFXGrainBufferSize; }
59 void processGrainFX(StereoBuffer<q31_t> buffer, int32_t grainRate, int32_t grainMix, int32_t grainDensity,
60 int32_t pitchRandomness, int32_t* postFXVolume,
bool anySoundComingIn,
float tempoBPM,
63 void clearGrainFXBuffer();
64 void grainBufferStolen() { grainBuffer =
nullptr; }
67 void setupGrainFX(int32_t grainRate, int32_t grainMix, int32_t grainDensity, int32_t pitchRandomness,
68 int32_t* postFXVolume,
float timePerInternalTick);
69 StereoSample<q31_t> processOneGrainSample(StereoSample<q31_t> currentSample);
71 void setWrapsToShutdown();
72 void setupGrainsIfNeeded(int32_t writeIndex);
74 uint32_t bufferWriteIndex = 0;
75 int32_t _grainSize = 13230;
76 int32_t _grainRate = 1260;
77 int32_t _grainShift = 13230;
78 int32_t _grainFeedbackVol = 161061273;
79 int32_t _grainVol = 0;
80 int32_t _grainDryVol = std::numeric_limits<int32_t>::max();
81 int32_t _pitchRandomness = 0;
83 bool grainLastTickCountIsZero =
true;
84 bool grainInitialized =
false;
86 std::array<Grain, 8> grains = {0};
88 int32_t wrapsToShutdown = 0;
90 int32_t _densityKnobPos = 0;
91 int32_t _rateKnobPos = 0;
92 int32_t _mixKnobPos = 0;
95 bool tempoSync =
true;
96 bool bufferFull =
false;
99class GrainBuffer :
public Stealable {
101 GrainBuffer() =
delete;
102 GrainBuffer(GrainBuffer& other) =
delete;
103 GrainBuffer(
const GrainBuffer& other) =
delete;
105 bool mayBeStolen(
void* thingNotToStealFrom)
override {
106 if (thingNotToStealFrom !=
this) {
111 void steal(
char const* errorCode)
override { owner->grainBufferStolen(); };
114 [[nodiscard]] StealableQueue getAppropriateQueue()
const override {
115 return StealableQueue::CURRENT_SONG_SAMPLE_DATA_REPITCHED_CACHE;
117 StereoSample<q31_t>& operator[](int32_t i) {
return sampleBuffer[i]; }
118 StereoSample<q31_t> operator[](int32_t i)
const {
return sampleBuffer[i]; }
123 std::array<StereoSample<q31_t>, kModFXGrainBufferSize *
sizeof(StereoSample<q31_t>)> sampleBuffer;
void processGrainFX(StereoBuffer< q31_t > buffer, int32_t grainRate, int32_t grainMix, int32_t grainDensity, int32_t pitchRandomness, int32_t *postFXVolume, bool anySoundComingIn, float tempoBPM, q31_t reverbAmount)
preset is currently converted from a param to a 0-4 preset inside the grain, which is probably not gr...
Definition GranularProcessor.cpp:50