Skip to content

Instantly share code, notes, and snippets.

View jpcima's full-sized avatar

JP Cimalando jpcima

View GitHub Profile
@jpcima
jpcima / hexdump.c
Created August 23, 2022 10:05
Hexadecimal printing function in the style of xxd
// Copyright Jean Pierre Cimalando 2022.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// SPDX-License-Identifier: BSL-1.0
#include <stdio.h>
#include <stddef.h>
(°)
(%)
(+/-)
(0..1)
(0=all buses)
(0=auto)
(0=omni)
(0=resonant, 1=dull)
(0=tempo sync)
(0=use played velocity)
@jpcima
jpcima / lsmooth.dsp
Last active August 6, 2021 11:25
Linear smoother
import("stdfaust.lib");
// a linear smoother
lfsmooth(tau, flush, tgt) =
((+:(_,tgt):select2(flush))~_)~((tgt-_)<:(abs,(/(tau*ma.SR):(select2(sc)~_):abs),_):(min,_):copysign)
with {
sc = (tgt!=tgt')|(tau!=tau');
copysign(x,s) = abs(x)*select2(s<0.0,1.0,-1.0);
//copysign = ffunction(float copysignf|copysign|copysignl(float,float),<math.h>,"");
};
/**
Calculate the analog filter and the bilinear transform
of the Bass and EQ section.
SPDX-License-Identifier: MIT
Compile
c++ -O2 -g -o bassFilter bassFilter.cpp
Run
param1 = 0.5; % knob 0 to 1
Fs = 44100.0;
R1 = 330e3;
C1 = 220e-12;
R2 = 3.3e3;
C2 = 10e-9;
Rp = 100e3 * param1;
Num = [(R1*C1*(Rp+R2)*C2) (C2*(Rp+R2)+R1*C1+R1*C2) 1.0];
#include <SDL2/SDL.h>
#include <stdio.h>
/*
--- Want
Rate : 44444
Channels : 2
Samples : 4096
Size : 0
Format : 0x008120
@jpcima
jpcima / mspShifter.dsp
Created May 18, 2021 17:30
Pitch shifter G09.pitchshift.pd
// SPDX-License-Identifier: ISC
import("stdfaust.lib");
//
// shift: transposition in semitones
// wt: window time
// dt: delay time
//
mspShifter(shift, wt, dt, sig) = mix with {
// speed change
@jpcima
jpcima / Transposer3.dsp
Created May 16, 2021 15:19
Pitch-shifter 3 délais foireux
import("stdfaust.lib");
// Transposer with 3 delay lines
// w: Window length (samples)
// s: Detune amount (semitones)
// t: Tuning adjustment factor
GenericTransposer3(w, s, t, sig) =
sum(i, 3, mix(i)*del(w*(mod(i)*ov+(i/2.)*(1.-ov)))) : *(0.5)
with {
ov = 2./3.;
@jpcima
jpcima / linSmooth.dsp
Created May 15, 2021 13:17
Linear smoother
import("stdfaust.lib");
// slewRate: a slew rate limiter
// - rate: maximum variation allowed in the time frame of a second (positive)
slewRate(rate) = next with {
next(x) = y letrec {
'y = y+step(rate/ma.SR,x-y);
}
with {
step(r, dy) = abs(dy) : min(r) : *(ba.if(dy>0,1,-1));