@treynterrio you can use this code if you have 2 inputs and 2 outputs or use the previous one if you have one input and one output.
The first code you can use in scriptnode in case you need to process, for example, mid and side separately.
import("stdfaust.lib");
MAX_DELAY = 192000;
// Phase-shifted phasor for reverse reading
// dtime: delay time in samples
// phase: phase offset for reading position
phasor_phase(dtime, phase) = ((os.lf_rawsaw(dtime) + phase) % dtime) : int;
phasor(dtime, phase) = phasor_phase(dtime*2, phase) <: <=(dtime), (*(-1) + dtime*2), _ : select2;
// Single channel reverse delay processing
reverse_delay = _ <: direct, delayed_and_reversed :> _
with {
// Get current sample rate for scaling controls
current_sr = ma.SR;
// User controls with sample rate scaling
delay_base = hslider("Delay Time[style:knob]", 0.5, 0.02, 1, 0.01);
delay_time = min(MAX_DELAY-1, delay_base * current_sr);
dry_wet = hslider("Dry/Wet[style:knob]", 0.5, 0, 1, 0.01);
// Direct path with gain
direct = *(1-dry_wet);
// Delay into reverse buffer implementation
delayed = de.delay(MAX_DELAY, delay_time);
// Reverse buffer using rwtable
reversed = rwtable(MAX_DELAY, 0.0,
phasor(delay_time, 0) : int, // Write index
_, // Input signal
phasor(delay_time, delay_time/2) : int // Read index
);
// Process delayed signal through reverse buffer with gain
delayed_and_reversed = delayed : reversed : *(dry_wet);
};
// Main stereo processing - apply reverse_delay to each channel independently
process = reverse_delay, reverse_delay;