Skip to content

Commit

Permalink
huh
Browse files Browse the repository at this point in the history
  • Loading branch information
dxinteractive committed Jun 29, 2024
1 parent 37417cf commit fddcbd5
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
49 changes: 49 additions & 0 deletions dev/src/dsp-definitions/41-autosampler-2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { DspDefinition } from "../types";

const dsp = `
import("stdfaust.lib");
table_size = 999999;
start = 4000.0;
len = 581.0;
end = start + len;
raw = _;
// use trigger to start!
no_play = (ba.time > start) & (ba.time <= end);
rec_active = ba.time > start;
slide = (ba.time - start) / len * 0.1;
slide_floor = float(int(slide));
slide_remain = slide % 1.0;
rec_head = rec_active : ba.sweep(9999999.0);
play_head = ba.if(no_play, rec_head, no_play' == 0 : ba.sweep(end - start) + 1);
play_head_progress = play_head / len;
cross(a, b, f, x) = a(x) * (1.0 - f) + b(x) * f;
table(p) = rwtable(table_size, 0.0, int(rec_head), _, int(p));
microloop(r) = cross(table(play_head + len * (r + 1.0)), table(play_head + len * r), play_head_progress);
wet = cross(microloop(slide_floor),microloop(slide_floor + 1.0), slide_remain);
out = cross(_,wet,min(rec_head / 1000.0, 1.0));
`;

const dspDefinition: DspDefinition = {
id: "autosampler-2",
name: "Autosampler 2",
description: "Grabbing a single cycle of audio and osc it",
dsp,
type: "offline",
channels: 1,
sampleRate: 48000,
inputFile: "/audio/cycfi-q-pitch-test/1a-Low-E.wav",
inputOffset: 47500 + 5000 + 30000,
outputLength: 200000,
output: ["raw", "out"],
};

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

const dsp = `
import("stdfaust.lib");
filter_top_freq = 1250.0;
filter_bands = 8;
active_channel = 6;
sign(x) = ba.if(x > 0, 1, 0);
detect_crossing(x) = sign(x) != sign(x');
pitch(x) = hz,osc
with {
lowest_pitch = 0.25;
longest_cycle = ma.SR / lowest_pitch;
crossed_up(x) = (x' < 0) & (x >= 0);
safe_divide(num, denom) = num / max(denom, 1) - num * (denom == 0);
reject_sub_pitches(x) = ba.if(x > longest_cycle, 0, x);
crossed = crossed_up(x);
cycle = ba.countup(ma.SR, crossed')
: ba.sAndH(crossed)
: reject_sub_pitches;
hz = safe_divide(ma.SR, cycle);
osc = os.osc(hz) * 0.2;
};
per_band = pitch : _,!;
// TODO track amplitude
// reject any too quiet, or where hz is too variable
filter = fi.mth_octave_filterbank(active_channel, 1, filter_top_freq, filter_bands);
zero = par(i, filter_bands, per_band);
input = _;
process_1250 = _ : filter : zero : ba.selector(0, filter_bands) <: _,_;
process_625 = _ : filter : zero : ba.selector(1, filter_bands) <: _,_;
process_312 = _ : filter : zero : ba.selector(2, filter_bands) <: _,_;
process_156 = _ : filter : zero : ba.selector(3, filter_bands) <: _,_;
process_78 = _ : filter : zero : ba.selector(4, filter_bands) <: _,_;
`;

const dspDefinition: DspDefinition = {
id: "multiband-filter",
name: "Multiband filter",
description: "Multiband filter",
dsp,
type: "offline",
inputFile: "/audio/cycfi-q-pitch-test/GLines3.wav",
channels: 1,
sampleRate: 48000,
output: [
"input",
"process_1250",
"process_625",
"process_312",
"process_156",
"process_78",
],
outputLength: 48000,
inputOffset: 18000 + 13000,
};

export default dspDefinition;
4 changes: 4 additions & 0 deletions dev/src/dsp-definitions/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import filterBank from "./37-filter-bank";
import cloudify from "./38-cloudify";
import autosampler from "./39-autosampler";
import pulseDelay from "./40-pulse-delay";
import autosampler2 from "./41-autosampler-2";
import multibandFilter from "./42-multiband-filter";

export const all: DspDefinition[] = [
sineWave,
Expand Down Expand Up @@ -82,4 +84,6 @@ export const all: DspDefinition[] = [
cloudify,
autosampler,
pulseDelay,
autosampler2,
multibandFilter,
];

0 comments on commit fddcbd5

Please sign in to comment.