Filter envelope

hey all,

i'm sure there's a simple way of modulating the filter cutoff value by using attack and release from within the lpf effect.. but i just can't seem to figure out quite how to do it.
any help would be really appreciated.

any idea !? I don't understanding how is it works with midi cc parameters. thnx!

I think the following should work:

Modify the lpf synthdef:

SynthDef("dirt_lpf" ++ numChannels, { |out, cutoff = 440, resonance = 0, lpfattack = 0, lpfhold = 0, lpfrelease = inf, lpfcurve = -3|
		var env = EnvGen.ar(Env.linen(lpfattack, lpfhold, lpfrelease, 1, lpfcurve));
		var signal = In.ar(out, numChannels);
		signal = RLPF.ar(signal, (cutoff * env).abs.clip(20, SampleRate.ir / 2), resonance.linexp(0, 1, 1, 0.001));
		ReplaceOut.ar(out, signal)
	}, [\ir, \kr, \kr, \kr, \kr, \kr, \kr]).add;

Define new controls in Tidal

let lpfatt = pF "lpfattack"
let lpfhold = pF "lpfhold"
let lpfrel = pF "lpfrelease"

Use them:

d1 $ s "piano" # lpf 400 # lpfatt 0.2 # lpfrel 0.2

(I haven't tested this)

1 Like

You can also use control busses to achieve this within tidal:
https://tidalcycles.org/docs/reference/control_busses/

@Jalex you will need to use separate events sending CC values to your midi receiving controls ccn - example, d1 sends midi notes, d2 sends to multiple receiving knobs on my softsynth, at a density of 128 events per cycle:

    -- midi notes
    d1
        $ struct "t*12"
        $ stack [
             s "midi0"
             # note (scale "minor" "c"
                 )
        ]

    -- midi control
    d2 
        $ segment 128 $ stack [
            ccv 64 # ccn 2 # s "midi0" -- filter open up
            , ccv 0 # ccn 1 # s "midi0" -- bass drive
            , ccv 0 # ccn 74 # s "midi0" -- band res
            , ccv 0 # ccn 75 # s "midi0" -- band cutoff
            , ccv (range 0 127 $ fast 4 saw) # ccn 76 # s "midi0" -- band cutoff
        ]
1 Like

Thank you. but I wanted to be able to control the envelopes within a single note. Or I misunderstood the idea. I will be grateful for any comments.

the method i shared should be able to work per note

1 Like

I defined a new envlpf effect for myself as follows:

~dirt.addModule('dirt_env_lpf', { |dirtEvent|
	dirtEvent.sendSynth('dirt_env_lpf' ++ ~dirt.numChannels,
		[
			env_lpf_freq: ~env_lpf_freq,
			env_lpf_dur: ~env_lpf_dur,
			env_lpf_attack: ~env_lpf_attack,
			env_lpf_resonance: ~env_lpf_resonance,
			out: ~out
		]
	)
}, { ~env_lpf_freq.notNil  }); // play synth only if at least one of the two was given

SynthDef("dirt_env_lpf" ++ ~dirt.numChannels, { |out, env_lpf_freq = 440, env_lpf_resonance = 0, env_lpf_dur = 1, env_lpf_attack = 0, env_lpf_curve = -4|
	var signal = In.ar(out, ~dirt.numChannels);
	var env_lpf = Env.perc(env_lpf_attack, env_lpf_dur - env_lpf_attack, env_lpf_freq - 20, env_lpf_curve).ar + 20;
	signal = RLPF.ar(signal, env_lpf, env_lpf_resonance.linexp(0, 1, 1, 0.001));
	ReplaceOut.ar(out, signal)
}, [\ir, \kr, \kr, \kr, \kr, \kr]).add;

and in Tidal I defined the function:

    envlpf freq dur att = pF "env_lpf_freq" freq # pF "env_lpf_dur" dur # pF "env_lpf_attack" att

and use it:

d1
$ n "0..7"
# s "juno"
# envlpf 2000 0.1 0.01

I find this effect useful for many cases, like creating pluck sounds or shaping percussive samples.

8 Likes

ah that's a great idea, using the perc envelope can def make it a "pluck" setting

from the discord, a similar question with a tidal answer:

yaxu 24/06/2023 06:55

how about this @jader

let sqz effectcycle pat = squeezeJoin $ ((# effectcycle) . pure) <$> pat

d1 $ sqz (djfbus 4 (segment 128 $ range 0.5 0.2 saw)) $
  note "0 7 -7 5 8 12 0" # s "braids"
  1. [06:55]

I don't have braids but this sounds right

d1 $ sqz (djfbus 4 (segment 128 $ range 0.5 0.1 tri)) $
  n "3 5 [8 7]" # s "sax" # legato 1
  1. [06:59]

fun !

d1 $ sqz (djfbus 4 (segment 128 $ range 0.5 0.1 $ slowcat [sine, saw, tri])) $
  n "3 5 [8 7] [5 2]" # s "sax" # legato 1
  |+ n "<0 12 3>"