Skip to content

Commit

Permalink
Merge pull request #22 from dxinteractive/issue/pedals-time
Browse files Browse the repository at this point in the history
Issue/pedals time
  • Loading branch information
dxinteractive authored Jul 11, 2024
2 parents f06c3fe + d092702 commit eeb4238
Show file tree
Hide file tree
Showing 27 changed files with 838 additions and 42 deletions.
Binary file added dev/public/audio/cycfi-q-pitch-test/1a-Low-E.wav
Binary file not shown.
Binary file added dev/public/audio/cycfi-q-pitch-test/2c-A-24th.wav
Binary file not shown.
Binary file added dev/public/audio/cycfi-q-pitch-test/GLines3.wav
Binary file not shown.
Binary file added dev/public/audio/cycfi-q-pitch-test/GStaccato.wav
Binary file not shown.
Binary file not shown.
18 changes: 8 additions & 10 deletions dev/src/dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ touchStart(liveAudioContext);

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<HashRouter>
<Routes>
<Route path="/" element={<Main />}>
<Route index element={<List />} />
<Route path=":id" element={<DspRoute />} />
</Route>
</Routes>
</HashRouter>
</React.StrictMode>
<HashRouter>
<Routes>
<Route path="/" element={<Main />}>
<Route index element={<List />} />
<Route path=":id" element={<DspRoute />} />
</Route>
</Routes>
</HashRouter>
);

function Main() {
Expand Down
44 changes: 44 additions & 0 deletions dev/src/dsp-definitions/27-pitchtracker-2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { DspDefinition } from "../types";

const dsp = `
import("stdfaust.lib");
pitchTracker(N, t, x) = loop ~ _
with {
xHighpassed = fi.highpass(1, 20.0, x);
loop(y) = an.zcr(t, fi.lowpass(N, max(20.0, y), xHighpassed)) * ma.SR * .5;
};
average_since(max_count, trig, x) = return
with {
count = ba.countup(max_count, trig);
loop(fb, x) = (fb * (trig == 0)) + x;
return = x : loop ~ _ : /(count + 1);
};
value_before_increase(hz) = ba.sAndH(hz > hz', hz');
pitchTrackerCleanup(hz) = average_since(9999, hz > hz', hz) : value_before_increase;
// input = (_ * 0.0) + os.osc(440.0);
input = _;
pitch = input : pitchTracker(2, 0.01);
pitch_clean = pitch : pitchTrackerCleanup;
osc = pitch_clean : os.osc * 0.4;
`;

const dspDefinition: DspDefinition = {
id: "pitch-tracker-2",
name: "Pitchtracker 2",
description: "Finds pitch 2",
dsp,
type: "offline",
output: ["input", "pitch", "pitch_clean", "osc"],
inputFile: "/audio/cycfi-q-pitch-test/Hammer-Pull High E.wav",
inputOffset: 26000,
outputLength: 26000,
sampleRate: 48000,
channels: 1,
};

export default dspDefinition;
34 changes: 34 additions & 0 deletions dev/src/dsp-definitions/28-average-since.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { DspDefinition } from "../types";

const dsp = `
import("stdfaust.lib");
average_since(trig, x) = return
with {
count = ba.countup(9999, trig);
loop(fb, x) = (fb * (trig == 0)) + x;
return = x : loop ~ _ : /(count + 1);
};
process = average_since;
`;

const dspDefinition: DspDefinition = {
id: "average-since",
name: "Average since",
description: "Average since",
dsp,
type: "offline",
input: [
[1, 0, 0, 0, 1, 0, 0, 0],
[4, 3, 2, 1, 2, 3, 4, 5],
],
output: ["process"],
expect: {
process: [[4, 3.5, 3, 2.5, 2, 2.5, 3, 3.5]],
},
channels: 2,
sampleRate: 44100,
};

export default dspDefinition;
106 changes: 106 additions & 0 deletions dev/src/dsp-definitions/29-autocorrelation-2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import type { DspDefinition } from "../types";

const dsp = `
import("stdfaust.lib");
// settings
longest_detectable_period = ma.SR / 80.0;
shortest_detectable_period = ma.SR / 1318.0;
sample_points = 64 * 2;
sample_stride = 4;
// utils
changed(x) = x != x';
only_changed(x) = ba.if(changed(x), x, -1);
count_stride(total, stride, trig) = ba.countup((total - 1) * stride, trig) / stride : int;
min_since(trig, x) = return
with {
loop(fb, x) = ba.if(trig, x, min(x, fb));
return = x : loop ~ _;
};
mean_since(trig, x) = return
with {
count = ba.countup(9999, trig);
loop(fb, x) = (fb * (trig == 0)) + x;
return = x : loop ~ _ : /(count + 1);
};
// process
input = _;
envelope = an.amp_follower_ar(0.0,0.1);
start_capture = envelope : >(0.1) : ba.impulsify : @(longest_detectable_period);
samples_since_start_capture = ba.countup(99999, start_capture);
samples_since_capture_end = samples_since_start_capture - (sample_points - 1) * sample_stride;
start_detect_pitch = samples_since_capture_end >= shortest_detectable_period : ba.impulsify;
trigger_sample_capture = start_capture : count_stride(sample_points, sample_stride) : only_changed;
each(i,curr_v) = result
with {
samples_ago = (sample_points - i - 1) * sample_stride;
offset_v = curr_v : @(samples_ago);
captured_v = ba.sAndH(trigger_sample_capture(offset_v) == i);
diff_v = curr_v - captured_v;
result = diff_v * diff_v;
};
autocorrelated_difference = _ <: par(i, sample_points, each(i)) :> _;
culumative_mean_difference(v) = result
with {
acd = v : autocorrelated_difference;
mean_since_start_capture = acd : mean_since(v : start_detect_pitch);
result = acd : /(mean_since_start_capture) : min(20.0);
};
cmd = culumative_mean_difference;
best_match_foo(v) = result
with {
min_since_start_capture = v : culumative_mean_difference : min_since(v : start_detect_pitch);
min_changed = min_since_start_capture : changed;
period = v : samples_since_capture_end : ba.sAndH(min_changed);
result = (ma.SR / (period + 0.001)) : max(20.0) : min(20000.0);
};
best_match = best_match_foo;
osc = best_match : os.osc * 0.4;
`;

const dspDefinition: DspDefinition = {
id: "autocorrelation-2",
name: "Auto-correlation 2",
description: "Auto-correlates pitch 2",
dsp,
type: "offline",
output: [
"input",
"trigger_sample_capture",
"samples_since_capture_end",
"autocorrelated_difference",
"cmd",
"best_match",
"osc",
],
inputFile: "/audio/cycfi-q-pitch-test/GStaccato.wav",
inputOffset: 25400,
outputLength: 192000, // 27921, // 192000,

// inputFile: "/audio/cycfi-q-pitch-test/2c-A-24th.wav",
// inputOffset: 7624,
// outputLength: 20000, // 27921, // 192000,

// inputFile: "/audio/cycfi-q-pitch-test/1a-Low-E.wav",
// inputOffset: 47500,
// outputLength: 55000, // 27921, // 192000,
sampleRate: 48000,
channels: 1,
};

export default dspDefinition;
2 changes: 1 addition & 1 deletion dev/src/dsp-definitions/30-echoloop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ wet(x) = x * wet_volume;
dsp(l, r) = (l + r * 0.5), (r : right_channel_delay);
loop(dsp, fb, l) = (l, fb : dsp), fb;
loop(dsp, fb, x) = (x, fb : dsp), fb;
lr(l, r) = r, l;
alchemist(dsp, x) = x : loop(dsp) ~ fb_loop : !,_,_ : lr;
Expand Down
43 changes: 25 additions & 18 deletions dev/src/dsp-definitions/31-echoloop-live.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import type { DspDefinition } from "../types";

// L -> send -> sum ---> L
// ^
// delay(main)
// R ------------+---- delay(offset) -> R

// foo[OWL:A], bar[OWL:B]

const dsp = `
import("stdfaust.lib");
Expand Down Expand Up @@ -47,34 +40,48 @@ bitcrusher(nbits,x) = return with {
// params
//
dry_volume_param = hslider("dry", 1.0, 0.0, 1.0, 0.01);
wet_volume_param = hslider("wet", 0.5, 0.0, 1.0, 0.01);
dry_volume_param = hslider("dry", 0.0, 0.0, 1.0, 0.01);
wet_volume_param = hslider("wet", 1.0, 0.0, 1.0, 0.01);
button_alt = checkbox("alt[OWL:B1]");
button_snapshot = button("snapshot[OWL:B2]");
time_param = hslider("time[OWL:A]", 500.0, 0.0, 1000.0, 0.1);
feedback_param = hslider("feedback[OWL:B]", 0.5, 0.0, 1.0, 0.01);
time_param = hslider("time[OWL:A]", 500.0, 0.0, 1000.0, 0.1) : si.smoo;
ping_pong_spacing_param = hslider("pingpong[TEMP]", 0.5, 0.0, 1.0, 0.01) : si.smoo;
feedback_param = hslider("feedback[OWL:B]", 0.5, 0.0, 1.0, 0.01) : si.smoo;
//
// param layers
//
delay_left_time = time_param : layerValue(500.0, button_alt, 0, 10.0) * 0.001 * ma.SR;
delay_right_time = time_param : layerValue(250.0, button_alt, 1, 10.0) * 0.001 * ma.SR;
// superseded
// delay_left_time = time_param : layerValue(500.0, button_alt, 0, 10.0);
// delay_right_time = time_param : layerValue(250.0, button_alt, 1, 10.0);
delay_left = de.delay(ma.SR, delay_left_time);
delay_right = de.delay(ma.SR, delay_right_time);
delay_a_time = time_param * (1.0 - ping_pong_spacing_param);
delay_b_time = time_param * ping_pong_spacing_param;
send_amount = 1.0; // TODO make a param
feedback_amount = feedback_param : layerValue(0.5, button_alt, 0, 0.05);
bitcrush_amount = feedback_param : layerValue(1.0, button_alt, 1, 0.05);
//
// dsp
//
feedback_path(x) = (x * feedback_amount) : delay_left : bitcrusher(bitcrush_amount * 16.0);
dsp(l, r) = (l + (r : feedback_path)), (r : delay_right);
delay(t) = de.delay(ma.SR, t * 0.001 * ma.SR);
delay_a = delay(delay_a_time);
delay_b = delay(delay_b_time);
dsp(l, r) = out
with {
in_l = l;
in_r = r;
feedback = in_r : *(feedback_amount) : delay_b : bitcrusher(bitcrush_amount * 16.0);
out_l = in_l : *(send_amount) : +(feedback) : delay_a;
out_r = in_r : delay_b;
out = out_l,out_r;
};
//
// simulated feedback loop
Expand All @@ -86,7 +93,7 @@ feedback_loop = _;
// routing
//
loop(dsp, fb, l) = (l, fb : dsp), fb;
loop(dsp, fb, x) = (x, fb : dsp), fb;
lr(l, r) = r, l;
alchemist(dsp, x) = x : loop(dsp) ~ feedback_loop : !,_,_ : lr;
Expand Down
36 changes: 36 additions & 0 deletions dev/src/dsp-definitions/32-min-since.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { DspDefinition } from "../types";

const dsp = `
import("stdfaust.lib");
min_since(trig, x) = return
with {
loop(fb, x) = ba.if(trig, x, min(x, fb));
return = x : loop ~ _;
};
process = min_since;
`;

const dspDefinition: DspDefinition = {
id: "min-since",
name: "Min since",
description: "Min since",
dsp,
type: "offline",
input: [
[1, 0, 0, 0, 1, 0, 0, 0],
[4, 3, 2, 3, 9, 3, 4, 5],
],
output: ["process"],
expect: {
process: [
[4, 3, 2, 2, 9, 3, 3, 3],
[4, 3, 2, 2, 9, 3, 3, 3],
],
},
channels: 2,
sampleRate: 44100,
};

export default dspDefinition;
Loading

0 comments on commit eeb4238

Please sign in to comment.