Skip to content

Commit

Permalink
blops
Browse files Browse the repository at this point in the history
  • Loading branch information
dxinteractive committed Aug 15, 2024
1 parent 5252e2f commit 9a057de
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions dev/src/dsp-definitions/44-c4-blops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,33 @@ import("stdfaust.lib");
// consts
peak = 0.65;
threshold = peak * 0.02;
highest_hz = 1320.0;
shortest_cycle = ma.SR / highest_hz;
// utils
zero_crosses(x) = (x' > 0) != (x > 0);
crossed_up(x) = (x' < 0) & (x >= 0);
safe_divide(num, denom) = num / max(denom, 1) - num * (denom == 0);
// process
input = _;
is_note_on = _ : an.amp_follower_ar(0.00001, 0.01) > threshold;
devfn(x) = crosses,cycle
devfn(x) = crosses,cycle,key,sine
with {
note_on = is_note_on(x);
crosses = x : *(note_on) : crossed_up;
crosses_on = crosses + (1 - note_on);
cycle = ba.countup(10000, crosses_on') : ba.sAndH(crosses_on);
key = ba.if(cycle < shortest_cycle, 0.0, (ma.SR / cycle) : ba.hz2midikey : +(0.5) : floor);
sine = key : ba.midikey2hz : os.osc;
};
dev_crosses_on = _ : devfn : _,!;
dev_cycle = _ : devfn : !,_;
process = _ <: _,_;
dev_crosses_on = _ : devfn : _,!,!,!;
dev_cycle = _ : devfn : !,_,!,!;
dev_key = _ : devfn : !,!,_,!;
dev_sine = _ : devfn : !,!,!,_;
`;

const dspDefinition: DspDefinition = {
Expand All @@ -38,7 +44,7 @@ const dspDefinition: DspDefinition = {
type: "offline",
channels: 1,
sampleRate: 48000,
output: ["input", "dev_crosses_on", "dev_cycle"],
output: ["input", "dev_crosses_on", "dev_cycle", "dev_key", "dev_sine"],
outputLength: 48000 * 2.46,
inputOffset: 1000,
};
Expand Down

0 comments on commit 9a057de

Please sign in to comment.