From fddcbd5ba9b0f06c9885259ce15e39c8ecb1e461 Mon Sep 17 00:00:00 2001 From: dxinteractive Date: Sat, 29 Jun 2024 23:17:55 +1000 Subject: [PATCH] huh --- dev/src/dsp-definitions/41-autosampler-2.ts | 49 ++++++++++++++ .../dsp-definitions/42-multiband-filter.ts | 67 +++++++++++++++++++ dev/src/dsp-definitions/all.ts | 4 ++ 3 files changed, 120 insertions(+) create mode 100644 dev/src/dsp-definitions/41-autosampler-2.ts create mode 100644 dev/src/dsp-definitions/42-multiband-filter.ts diff --git a/dev/src/dsp-definitions/41-autosampler-2.ts b/dev/src/dsp-definitions/41-autosampler-2.ts new file mode 100644 index 0000000..1bea930 --- /dev/null +++ b/dev/src/dsp-definitions/41-autosampler-2.ts @@ -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; diff --git a/dev/src/dsp-definitions/42-multiband-filter.ts b/dev/src/dsp-definitions/42-multiband-filter.ts new file mode 100644 index 0000000..bdd16b7 --- /dev/null +++ b/dev/src/dsp-definitions/42-multiband-filter.ts @@ -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; diff --git a/dev/src/dsp-definitions/all.ts b/dev/src/dsp-definitions/all.ts index ac16ac4..b245644 100644 --- a/dev/src/dsp-definitions/all.ts +++ b/dev/src/dsp-definitions/all.ts @@ -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, @@ -82,4 +84,6 @@ export const all: DspDefinition[] = [ cloudify, autosampler, pulseDelay, + autosampler2, + multibandFilter, ];