Skip to content

Commit 34fa49f

Browse files
committed
more
1 parent dd15c42 commit 34fa49f

File tree

3 files changed

+75
-69
lines changed

3 files changed

+75
-69
lines changed

dev/src/dsp-definitions/49-alchemist-prototype-3.ts

Lines changed: 33 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ gtr_synth = tunePlayer(tune1) : synth;
1818
bass_synth = tunePlayer(tune2) : synth;
1919
2020
//
21-
// alchemist.dsp - bass compressor, trem, detune
21+
// alchemist.dsp - bass compressor, trem, chorus
2222
//
2323
2424
// utils
@@ -61,6 +61,13 @@ layerValue(l,i,t,x) = return with {
6161
return = x : sAndHWithDefault(0.5, (l == i) & layerIsAwake(l,x,t));
6262
};
6363
64+
shortPress(time, trig) = return with {
65+
up_while_press = ba.countup(time, trig == 0);
66+
on_release = trig < trig';
67+
held_enough = up_while_press < time;
68+
return = held_enough' & on_release;
69+
};
70+
6471
// consts
6572
6673
// input
@@ -69,27 +76,34 @@ layerValue(l,i,t,x) = return with {
6976
// A C
7077
// D
7178
//
72-
// * detune
73-
// * side * trem
74-
// * width
79+
// * trem
80+
// * side * chorus
81+
// * multi
7582
7683
sidechain_param = hslider("sidechain[OWL:A]", 0., 0., 1., .001) : reject_noise(0.05, 1.0) : si.smoo;
77-
detune_param = hslider("detune[OWL:B]", 0., 0., 1., .001) : reject_noise(0.05, 1.0) : si.smoo;
78-
trem_param = hslider("trem[OWL:C]", 0., 0., 1., .001) : reject_noise(0.05, 1.0) : si.smoo;
79-
width_param = hslider("width[OWL:D]", 0., 0., 1., .001) : reject_noise(0.05, 1.0) : si.smoo;
84+
trem_param = hslider("trem[OWL:B]", 0., 0., 1., .001) : reject_noise(0.05, 1.0) : si.smoo;
85+
chorus_param = hslider("chorus[OWL:C]", 0., 0., 1., .001) : reject_noise(0.05, 1.0) : si.smoo;
86+
multi_param = hslider("multi[OWL:D]", 0., 0., 1., .001) : reject_noise(0.05, 1.0) : si.smoo;
87+
88+
8089
81-
detune_on = button("detune_on[OWL:B1]") : ba.toggle;
82-
trem_on = button("trem_on[OWL:B2]") : ba.toggle;
90+
button_a = button("button_a[OWL:B1]");
91+
button_b = button("button_b[OWL:B2]");
92+
button_a_short = button_a : shortPress(ma.SR * .2);
93+
button_b_short = button_b : shortPress(ma.SR * .2);
8394
8495
// fx
85-
wet_amount_detune = ba.if(detune_param < 2/3, ba.if(detune_param < 1/3, .1, .3), .5);
86-
wet_amount = ba.if(detune_on, wet_amount_detune, 1.);
87-
detune_amount = detune_param : *(3.) : %(1.) : *(.2);
96+
trem_on = button_a_short : ba.toggle;
97+
chorus_on = button_b_short : ba.toggle;
8898
89-
gtr_detune_l = ef.transpose(ma.SR * .003, ma.SR * .003 * .9, -detune_amount);
90-
gtr_detune_r = ef.transpose(ma.SR * .0041, ma.SR * .0041 * .9, -detune_amount * .5);
91-
gtr_detune_lr = gtr_detune_l,gtr_detune_r;
92-
gtr_detune = ba.bypass2(detune_on : ==(0), gtr_detune_lr);
99+
wet_amount_chorus = ba.if(chorus_param < 2/3, ba.if(chorus_param < 1/3, .1, .3), .5);
100+
wet_amount = ba.if(chorus_on, wet_amount_chorus, 1.);
101+
chorus_amount = chorus_param : *(3.) : %(1.) : *(.2);
102+
103+
gtr_chorus_l = ef.transpose(ma.SR * .003, ma.SR * .003 * .9, -chorus_amount);
104+
gtr_chorus_r = ef.transpose(ma.SR * .0041, ma.SR * .0041 * .9, -chorus_amount * .5);
105+
gtr_chorus_lr = gtr_chorus_l,gtr_chorus_r;
106+
gtr_chorus = ba.bypass2(chorus_on : ==(0), gtr_chorus_lr);
93107
94108
trem_depth = ba.if(trem_param < 2/3, ba.if(trem_param < 1/3, .3, .6), 1.);
95109
trem_speed = trem_param : *(3.) : %(1.) : lerp(-2., 4.) : pow(2.);
@@ -102,59 +116,9 @@ gtr_sidechain = ba.lin2LogGain(1. - sidechain_param);
102116
gtr_gain_amount = wet_amount * gtr_sidechain;
103117
gtr_gain = *(gtr_gain_amount);
104118
105-
// stereo-wide / stereo-narrow / mono-panned / mono-autopan / offset / pingpong
106-
107-
gtr_width(l,r) = return with {
108-
p(a,b,l,r) = return with {
109-
gain = (width_param >= a) & (width_param < b);
110-
return = l * gain,r * gain;
111-
};
112-
113-
p0 = 0.;
114-
p1 = .07;
115-
p2 = .13;
116-
p3 = .2;
117-
p4 = .4;
118-
p5 = .6;
119-
p6 = .8;
120-
p7 = 1.;
121-
122-
p55 = (p5 + p6) * .5;
123-
p65 = (p6 + p7) * .5;
124-
125-
pan_amount_static = unlerp(p2,p4,width_param);
126-
pan_amount_auto = os.osc(unlerp(p4,p5,width_param) : lerp(.01, .5)) * .5 + .5;
127-
pan_amount = ba.if(width_param < p4, pan_amount_static, pan_amount_auto);
128-
129-
del_max = ma.SR;
130119
131-
d(a,b,x) = return with {
132-
gain = (width_param >= a) & (width_param < b);
133-
return = x * gain;
134-
};
135-
136-
del_la = unlerp(p55,p6,width_param) : lerp(0.,del_max) : d(p55,p6);
137-
del_lb = unlerp(p6,p65,width_param) : lerp(del_max * .5, 0.) : d(p6,p65);
138-
del_lc = unlerp(p65,p7,width_param) : lerp(0.,del_max) : d(p65,p7);
139-
del_l = del_la + del_lb + del_lc;
140-
141-
del_ra = unlerp(p5,p55,width_param) : lerp(del_max, 0.) : d(p5,p55);
142-
del_rb = unlerp(p6,p65,width_param) : lerp(del_max, 0.) : d(p6,p65);
143-
del_rc = unlerp(p65,p7,width_param) : lerp(0., del_max * .5) : d(p65,p7);
144-
del_r = del_ra + del_rb + del_rc;
145-
146-
del_vol = ba.if(width_param < p6, 1., .5);
147-
148-
stereo = p(p0,p1);
149-
narrow(l,r) = l*.75+r*.25,r*.75+l*.25 : p(p1,p2);
150-
mono = _,! <: p(p2,p3);
151-
pan = constantPowerPan(pan_amount) : p(p3,p5);
152-
offset = de.delay(del_max,del_l),de.delay(del_max,del_r) : *(del_vol),*(del_vol) : p(p5,p7);
153-
154-
return = l,r <: stereo,narrow,mono,pan,offset :> _,_;
155-
};
156120
157-
gtr = gtr_gain : gtr_trem <: gtr_detune : gtr_width;
121+
gtr = gtr_gain : gtr_trem <: gtr_chorus;
158122
159123
bass_gate = ef.gate_mono(-64., .005, 0., 1.);
160124
bass_comp = co.compressor_mono(32., -34., 0., .4);
@@ -178,7 +142,7 @@ export default dspDefinition;
178142
/**
179143
* PARAMS:
180144
*
181-
* detune = - vol 10%: depth 0 ... 100%
145+
* chorus = - vol 10%: depth 0 ... 100%
182146
* - vol 30%: depth 0 ... 100%
183147
* - vol 50%: depth 0 ... 100%
184148
*
@@ -193,7 +157,7 @@ export default dspDefinition;
193157
* BUTTONS:
194158
*
195159
* A:
196-
* - tap: enable / disable detune
160+
* - tap: enable / disable chorus
197161
* - hold + B: NOT IMPLEMENTED
198162
* select sidechain mode?
199163
* - volume
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import type { DspDefinition } from "../types";
2+
3+
const dsp = `
4+
import("stdfaust.lib");
5+
6+
shortPress(time, trig) = return with {
7+
up_while_press = ba.countup(time, trig == 0);
8+
on_release = trig < trig';
9+
held_enough = up_while_press < time;
10+
return = held_enough' & on_release;
11+
};
12+
13+
input = _;
14+
process = input : shortPress(3);
15+
`;
16+
17+
const dspDefinition: DspDefinition = {
18+
id: "short-press",
19+
name: "Short press",
20+
description:
21+
"Fires an implulse on button release if button was held shorter than t time",
22+
dsp,
23+
type: "offline",
24+
sampleRate: 44100,
25+
channels: 1,
26+
input: [
27+
[
28+
0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1,
29+
1, 1, 0, 0, 0,
30+
],
31+
],
32+
output: ["input", "process"],
33+
// outputLength: 18,
34+
// expect: {
35+
// scan: [[4, 4, 0, 9, 4, 3, 0, 1, 0, 1, 4, 5, 10, 11, 10, 0, 0, 0]],
36+
// process: [[0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 1, 1, 1]],
37+
// },
38+
};
39+
40+
export default dspDefinition;

dev/src/dsp-definitions/all.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import noiseRejection from "./46-noise-rejection";
4949
import autolooper from "./47-autolooper";
5050
import alchemistPrototype2 from "./48-alchemist-prototype-2";
5151
import alchemistPrototype3 from "./49-alchemist-prototype-3";
52+
import shortPress from "./50-short-press";
5253

5354
export const all: DspDefinition[] = [
5455
sineWave,
@@ -100,4 +101,5 @@ export const all: DspDefinition[] = [
100101
autolooper,
101102
alchemistPrototype2,
102103
alchemistPrototype3,
104+
shortPress,
103105
];

0 commit comments

Comments
 (0)