kopia lustrzana https://github.com/jameshball/osci-render
Add grid delay
rodzic
4321de2f27
commit
47ed50a96c
|
@ -35,11 +35,12 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() : CommonAudioProcessor(Buse
|
||||||
auto multiplexEffect = std::make_shared<osci::Effect>(
|
auto multiplexEffect = std::make_shared<osci::Effect>(
|
||||||
std::make_shared<MultiplexEffect>(),
|
std::make_shared<MultiplexEffect>(),
|
||||||
std::vector<osci::EffectParameter*>{
|
std::vector<osci::EffectParameter*>{
|
||||||
new osci::EffectParameter("Multiplex Grid X", "Controls the horizontal grid size for the multiplex effect.", "multiplexGridX", VERSION_HINT, 1.0, 1.0, 8.0),
|
new osci::EffectParameter("Multiplex X", "Controls the horizontal grid size for the multiplex effect.", "multiplexGridX", VERSION_HINT, 1.0, 1.0, 8.0),
|
||||||
new osci::EffectParameter("Multiplex Grid Y", "Controls the vertical grid size for the multiplex effect.", "multiplexGridY", VERSION_HINT, 1.0, 1.0, 8.0),
|
new osci::EffectParameter("Multiplex Y", "Controls the vertical grid size for the multiplex effect.", "multiplexGridY", VERSION_HINT, 1.0, 1.0, 8.0),
|
||||||
new osci::EffectParameter("Multiplex Grid Z", "Controls the depth grid size for the multiplex effect.", "multiplexGridZ", VERSION_HINT, 1.0, 1.0, 8.0),
|
new osci::EffectParameter("Multiplex Z", "Controls the depth grid size for the multiplex effect.", "multiplexGridZ", VERSION_HINT, 1.0, 1.0, 8.0),
|
||||||
new osci::EffectParameter("Multiplex Smooth", "Controls the smoothness of transitions between grid sizes.", "multiplexSmooth", VERSION_HINT, 1.0, 0.0, 1.0),
|
new osci::EffectParameter("Multiplex Smooth", "Controls the smoothness of transitions between grid sizes.", "multiplexSmooth", VERSION_HINT, 0.0, 0.0, 1.0),
|
||||||
new osci::EffectParameter("Grid Phase", "Controls the current phase of the grid animation.", "gridPhase", VERSION_HINT, 0.0, -1.0, 1.0),
|
new osci::EffectParameter("Multiplex Phase", "Controls the current phase of the multiplex grid animation.", "gridPhase", VERSION_HINT, 0.0, 0.0, 1.0),
|
||||||
|
new osci::EffectParameter("Multiplex Delay", "Controls the delay of the audio samples used in the multiplex effect.", "gridDelay", VERSION_HINT, 0.0, 0.0, 1.0),
|
||||||
});
|
});
|
||||||
// Set up the Grid Phase parameter with sawtooth LFO at 100Hz
|
// Set up the Grid Phase parameter with sawtooth LFO at 100Hz
|
||||||
multiplexEffect->getParameter("gridPhase")->lfo->setUnnormalisedValueNotifyingHost((int)osci::LfoType::Sawtooth);
|
multiplexEffect->getParameter("gridPhase")->lfo->setUnnormalisedValueNotifyingHost((int)osci::LfoType::Sawtooth);
|
||||||
|
|
|
@ -5,13 +5,22 @@
|
||||||
class MultiplexEffect : public osci::EffectApplication {
|
class MultiplexEffect : public osci::EffectApplication {
|
||||||
public:
|
public:
|
||||||
osci::Point apply(int index, osci::Point input, const std::vector<std::atomic<double>>& values, double sampleRate) override {
|
osci::Point apply(int index, osci::Point input, const std::vector<std::atomic<double>>& values, double sampleRate) override {
|
||||||
jassert(values.size() >= 5);
|
jassert(values.size() >= 6);
|
||||||
|
|
||||||
double gridX = values[0].load();
|
double gridX = values[0].load();
|
||||||
double gridY = values[1].load();
|
double gridY = values[1].load();
|
||||||
double gridZ = values[2].load();
|
double gridZ = values[2].load();
|
||||||
double interpolation = values[3].load();
|
double interpolation = values[3].load();
|
||||||
double phase = values[4].load();
|
double phase = values[4].load();
|
||||||
|
double gridDelay = values[5].load();
|
||||||
|
|
||||||
|
head++;
|
||||||
|
|
||||||
|
if (head >= buffer.size()) {
|
||||||
|
head = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[head] = input;
|
||||||
|
|
||||||
osci::Point grid = osci::Point(gridX, gridY, gridZ);
|
osci::Point grid = osci::Point(gridX, gridY, gridZ);
|
||||||
osci::Point gridFloor = osci::Point(std::floor(gridX), std::floor(gridY), std::floor(gridZ));
|
osci::Point gridFloor = osci::Point(std::floor(gridX), std::floor(gridY), std::floor(gridZ));
|
||||||
|
@ -22,11 +31,18 @@ public:
|
||||||
|
|
||||||
double totalPositions = gridFloor.x * gridFloor.y * gridFloor.z;
|
double totalPositions = gridFloor.x * gridFloor.y * gridFloor.z;
|
||||||
double position = phase * totalPositions;
|
double position = phase * totalPositions;
|
||||||
|
double delayPosition = static_cast<int>(position) / totalPositions;
|
||||||
|
|
||||||
|
int delayedIndex = head - static_cast<int>(delayPosition * gridDelay * sampleRate);
|
||||||
|
if (delayedIndex < 0) {
|
||||||
|
delayedIndex += buffer.size();
|
||||||
|
}
|
||||||
|
osci::Point delayedInput = buffer[delayedIndex % buffer.size()];
|
||||||
|
|
||||||
osci::Point nextGrid = gridFloor + 1.0;
|
osci::Point nextGrid = gridFloor + 1.0;
|
||||||
|
|
||||||
osci::Point current = multiplex(input, position, gridFloor);
|
osci::Point current = multiplex(delayedInput, position, gridFloor);
|
||||||
osci::Point next = multiplex(input, position, nextGrid);
|
osci::Point next = multiplex(delayedInput, position, nextGrid);
|
||||||
|
|
||||||
// Calculate interpolation factors
|
// Calculate interpolation factors
|
||||||
osci::Point gridDiff = grid - gridFloor;
|
osci::Point gridDiff = grid - gridFloor;
|
||||||
|
@ -62,4 +78,8 @@ private:
|
||||||
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const static int MAX_DELAY = 192000 * 10;
|
||||||
|
std::vector<osci::Point> buffer = std::vector<osci::Point>(MAX_DELAY);
|
||||||
|
int head = 0;
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue