Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release QuickDelay v1.0 #364

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 155 additions & 0 deletions Reverb/tilr_QuickDelay.jsfx
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
desc: QuickDelay
author: tilr
version: 1.0
provides:
tilr_QuickDelay/qd.delay.jsfx-inc
tilr_QuickDelay/qd.rbj_filter.jsfx-inc
about:
# QuickDelay

Simple delay with ping-pong mode, tempo sync and feedback filters.

#### Features

* Normal and ping-pong modes
* Ping-pong stereo width control
* Tempo sync
* Low pass and high pass feedback filters with Q controls
* Delay modulation

desc:QuickDelay

slider1:delayms=250<1,1000>Delay Time (ms)
slider2:sync=0<0,16,1{Off,1/16,1/8,1/4,1/2,1/1,1/16t,1/8t,1/4t,1/2t,1/1t,1/16.,1/8.,1/4.,1/2.,1/1.}>Tempo sync
slider3:_feedback=0<0,100>Feedback
slider4:mode=0<0,1,1{Normal,Ping-Pong}>Mode
slider5:spread=0<-100,100,1>Ping-Pong Spread

slider8:lp_freq=20000<20,20000,1:log>Low Pass
slider9:lp_q=0.707<0.707,2,0.01:log>Low Pass Q

slider10:hp_freq=20<20,20000,1:log>High Pass
slider11:hp_q=0.707<0.707,2.0,0.01:log>High Pass Q

slider13:mod_amp=0<0,100>Modulation amp
slider14:mod_freq=1<1,8>Modulation freq (Hz)

slider16:_dry=100<0,100>Dry signal
slider17:_wet=100<0,100>Wet signal

import qd.delay.jsfx-inc
import qd.rbj_filter.jsfx-inc

@init
// 10 second stereo delay line
d0.delay(srate * 10);
d1.delay(srate * 10);

function sine_wave(cycle) (
sin(cycle * 2 * $pi);
);

function rc_set(rc)
instance(a) (
a = 1 / (rc * srate + 1);
);
function rc_lp(sample)
instance(lp, a) (
lp += a * (sample - lp);
);
function smooth()
instance (lp, smooth) (
lp = smooth;
smooth = this.rc_lp(this);
);

samps.rc_set(0.33);

@slider
feedback = _feedback / 100;
lfactor = spread > 0 ? 1 - spread / 100 : 1;
rfactor = spread < 0 ? 1 + spread / 100 : 1;

lp_l.rbj_lp(lp_freq, lp_q);
lp_r.rbj_lp(lp_freq, lp_q);
hp_l.rbj_hp(hp_freq, hp_q);
hp_r.rbj_hp(hp_freq, hp_q);

dry = _dry / 100;
wet = _wet / 100;

@block
while (midirecv(offset, msg1, note, vel)) (
event = msg1 & 0xF0;
event == 0xB0 && note == 123 ? ( // All notes off
memset(d0.buf, 0, d0.size);
memset(d1.buf, 0, d1.size);
);
);

sync > 0 ? (
sync == 1 ? delayms = 60000 / 4 / tempo: // 1/16
sync == 2 ? delayms = 60000 / 2 / tempo: // 1/8
sync == 3 ? delayms = 60000 / tempo: // 1/4
sync == 4 ? delayms = 60000 * 2 / tempo: // 1/2
sync == 5 ? delayms = 60000 * 4 / tempo: // 1/1
sync == 6 ? delayms = 60000 / 6 / tempo: // 1/16t
sync == 7 ? delayms = 60000 / 3 / tempo: // 1/8t
sync == 8 ? delayms = 60000 / 3 * 2 / tempo: // 1/4t
sync == 9 ? delayms = 60000 / 3 * 4 / tempo: // 1/2t
sync == 10 ? delayms = 60000 / 3 * 8 / tempo: // 1/1t
sync == 11 ? delayms = 60000 / 4 * 1.5 / tempo: // 1/16.
sync == 12 ? delayms = 60000 / 2 * 1.5 / tempo: // 1/8.
sync == 13 ? delayms = 60000 * 1.5 / tempo: // 1/4.
sync == 14 ? delayms = 60000 * 2 * 1.5 / tempo: // 1/2.
sync == 15 ? delayms = 60000 * 4 * 1.5 / tempo: // 1/1.
1;
);

delayms > 10000 ? delayms = 10000;
samps = delayms * 0.001 * srate; // delay time in samples

@sample

play_state & 1 && !(lplay_state & 1) ? (
samps.smooth = samps;
);
lplay_state = play_state;

samps.smooth();

// modulation sinewave
mod_amp ? (
cycle += mod_freq / srate;
cycle > 1 ? cycle -= 1;
wave = sine_wave(cycle);
) : (
wave = 0;
);

// read with cubic interpolation
val0 = d0.delay_read3(samps.smooth + wave * mod_amp);
val1 = d1.delay_read3(samps.smooth + wave * mod_amp);

// apply filters on delay signal
lp_freq < 20000 ? (
val0 = lp_l.rbj_df1(val0);
val1 = lp_r.rbj_df1(val1);
);
hp_freq > 20 ? (
val0 = hp_l.rbj_df1(val0);
val1 = hp_r.rbj_df1(val1);
);

// write values in delay lines
mode == 0 ? (
d0.delay_write(spl0 + val0 * feedback);
d1.delay_write(spl1 + val1 * feedback);
) : mode == 1 ? (
d0.delay_write(spl0 * lfactor + val1 * feedback);
d1.delay_write(spl1 * rfactor + val0 * feedback);
);

// sum and output
spl0 = spl0*dry + val0*wet;
spl1 = spl1*dry + val1*wet;
Loading
Loading