Skip to content

Commit

Permalink
huh
Browse files Browse the repository at this point in the history
  • Loading branch information
dxinteractive committed Jun 24, 2024
1 parent e515162 commit 422714f
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
Binary file added dev/public/audio/cycfi-q-pitch-test/GLines3.wav
Binary file not shown.
59 changes: 59 additions & 0 deletions dev/src/dsp-definitions/39-autosampler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import type { DspDefinition } from "../types";

const dsp = `
import("stdfaust.lib");
threshold_on = 0.2;
threshold_off = 0.02;
release = 0.004;
table_size = 100000;
sampling_time = 10300;
sampling_time_2 = sampling_time * 2;
on_up(x) = x > x';
invert_boolean(x) = x == 0;
env_threshold(on, off, x) = x > on, x < off : ba.on_and_off : >(0);
counter(trig) = on_up(trig) : + ~ _;
input = _;
env = input : an.amp_follower_ar(0.0, release);
env_active = env : env_threshold(threshold_on, threshold_off);
env_on = env_active : ba.impulsify;
gated = input * env_active;
env_active_timer = env_active : invert_boolean : ba.countup(table_size);
env_active_forever = env_on : ba.on_and_off(_, 0) : >(0);
env_active_sweep = env_active_timer : ba.sweep(table_size);
record_head = env_active_sweep * (env_active_sweep <= sampling_time * 2);
playback_head = ((env_active_sweep - 1) % sampling_time) + 1;
playback_head2 = max(0, (((env_active_sweep - (sampling_time / 2)) - 1) % sampling_time) + 1);
vol(v) = cos(v * ma.PI * 2.0) * -0.5 + 0.5;
table(pb, x) = rwtable(table_size, 0.0, record_head(x), x, pb(x)) * vol(pb(x) / sampling_time);
fx(x) = table(playback_head, x) + table(playback_head2, x) + (x * max(0.0, 1.0 - (env_active_sweep / sampling_time) * 2.0));
repeat = fx;
`;

const dspDefinition: DspDefinition = {
id: "autosampler",
name: "Autosampler",
description: "Grabbing a chunk of audio based on an env",
dsp,
type: "offline",
inputFile: "/audio/cycfi-q-pitch-test/GLines3.wav",
channels: 1,
sampleRate: 48000,
outputLength: 48000 * 5,
output: ["gated", "playback_head", "playback_head2", "repeat"],
inputOffset: 18000 + 13000,
};

export default dspDefinition;

//
// playback_head_double = ((env_active_sweep - 1) % sampling_time_2) + 1;
// playback_head2(x) = ba.if(playback_head_double(x) <= sampling_time, playback_head_double(x), sampling_time_2 - playback_head_double(x) + 1);
2 changes: 2 additions & 0 deletions dev/src/dsp-definitions/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import recordedGuitar from "./35-recorded-guitar";
import wizardDelay from "./36-wizard-delay";
import filterBank from "./37-filter-bank";
import cloudify from "./38-cloudify";
import autosampler from "./39-autosampler";

export const all: DspDefinition[] = [
sineWave,
Expand Down Expand Up @@ -78,4 +79,5 @@ export const all: DspDefinition[] = [
wizardDelay,
filterBank,
cloudify,
autosampler,
];

0 comments on commit 422714f

Please sign in to comment.