46class GranularProcessor {
48 GranularProcessor() { getBuffer(); }
49 GranularProcessor(
const GranularProcessor& other);
51 [[nodiscard]] int32_t getSamplesToShutdown()
const {
return wrapsToShutdown * kModFXGrainBufferSize; }
57 void processGrainFX(std::span<StereoSample> buffer, int32_t grainRate, int32_t grainMix, int32_t grainDensity,
58 int32_t pitchRandomness, int32_t* postFXVolume,
bool anySoundComingIn,
float tempoBPM,
61 void clearGrainFXBuffer();
62 void grainBufferStolen() { grainBuffer =
nullptr; }
65 void setupGrainFX(int32_t grainRate, int32_t grainMix, int32_t grainDensity, int32_t pitchRandomness,
66 int32_t* postFXVolume,
float timePerInternalTick);
69 void setWrapsToShutdown();
70 void setupGrainsIfNeeded(int32_t writeIndex);
72 uint32_t bufferWriteIndex = 0;
73 int32_t _grainSize = 13230;
74 int32_t _grainRate = 1260;
75 int32_t _grainShift = 13230;
76 int32_t _grainFeedbackVol = 161061273;
77 int32_t _grainVol = 0;
78 int32_t _grainDryVol = std::numeric_limits<int32_t>::max();
79 int32_t _pitchRandomness = 0;
81 bool grainLastTickCountIsZero =
true;
82 bool grainInitialized =
false;
84 std::array<Grain, 8> grains = {0};
86 int32_t wrapsToShutdown = 0;
88 int32_t _densityKnobPos = 0;
89 int32_t _rateKnobPos = 0;
90 int32_t _mixKnobPos = 0;
93 bool tempoSync =
true;
94 bool bufferFull =
false;
97class GrainBuffer :
public Stealable {
99 GrainBuffer() =
delete;
100 GrainBuffer(GrainBuffer& other) =
delete;
101 GrainBuffer(
const GrainBuffer& other) =
delete;
103 bool mayBeStolen(
void* thingNotToStealFrom)
override {
104 if (thingNotToStealFrom !=
this) {
109 void steal(
char const* errorCode)
override { owner->grainBufferStolen(); };
112 [[nodiscard]] StealableQueue getAppropriateQueue()
const override {
113 return StealableQueue::CURRENT_SONG_SAMPLE_DATA_REPITCHED_CACHE;
115 StereoSample& operator[](int32_t i) {
return sampleBuffer[i]; }
116 StereoSample operator[](int32_t i)
const {
return sampleBuffer[i]; }
void processGrainFX(std::span< StereoSample > 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:47