Skip to content

Commit

Permalink
sdkjdsf
Browse files Browse the repository at this point in the history
  • Loading branch information
dxinteractive committed Dec 23, 2023
1 parent ef768f0 commit 1d0fcd7
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 19 deletions.
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: 30400,
outputLength: 88200,
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;
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
4 changes: 4 additions & 0 deletions dev/src/dsp-definitions/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import zeroCrossingDetection from "./23-zero-crossing-detection";
import pitchtracker from "./24-pitchtracker";
import autocorrelation from "./25-autocorrelation";
import envelopeDetector from "./26-envelope-detector";
import pitchtracker2 from "./27-pitchtracker-2";
import averageSince from "./28-average-since";
import echoloop from "./30-echoloop";
import echoloopLive from "./31-echoloop-live";

Expand Down Expand Up @@ -56,6 +58,8 @@ export const all: DspDefinition[] = [
pitchtracker,
autocorrelation,
envelopeDetector,
pitchtracker2,
averageSince,
echoloop,
echoloopLive,
];

0 comments on commit 1d0fcd7

Please sign in to comment.