# Filter envelope

**URL:** <https://uzu.lurk.org/t/filter-envelope/2977>\
**Category:** TidalCycles\
**Tags:** questions\
**Created:** [7 March 2021 16:46 UTC](https://uzu.lurk.org/t/filter-envelope/2977 "2021-03-07T16:46:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![caspardylan](https://uzu.lurk.org/user_avatar/uzu.lurk.org/caspardylan/32/1914_2.png) [@caspardylan](https://uzu.lurk.org/u/caspardylan)\
**Post date:** [7 March 2021 16:46 UTC](https://uzu.lurk.org/t/filter-envelope/2977/1 "2021-03-07T16:46:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jalex](https://uzu.lurk.org/user_avatar/uzu.lurk.org/jalex/32/2069_2.png) [@Jalex](https://uzu.lurk.org/u/Jalex)\
**Post date:** [30 April 2023 17:29 UTC](https://uzu.lurk.org/t/filter-envelope/2977/2 "2023-04-30T17:29:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![geikha](https://uzu.lurk.org/user_avatar/uzu.lurk.org/geikha/32/2701_2.png) [@geikha](https://uzu.lurk.org/u/geikha)\
**Post date:** [30 April 2023 21:25 UTC](https://uzu.lurk.org/t/filter-envelope/2977/3 "2023-04-30T21:25:04Z")

</div>

I think the following should work:

Modify the lpf synthdef:

```haskell
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

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

```

Use them:

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

```

(I haven't tested this)

---

<div class="post-metadata">

**Author:** ![cleary](https://uzu.lurk.org/user_avatar/uzu.lurk.org/cleary/32/177_2.png) [@cleary](https://uzu.lurk.org/u/cleary)\
**Post date:** [1 May 2023 01:55 UTC](https://uzu.lurk.org/t/filter-envelope/2977/4 "2023-05-01T01:55:18Z")

</div>

You can also use control busses to achieve this within tidal:  
[https://tidalcycles.org/docs/reference/control\_busses/](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:

```haskell
    -- 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
        ]

```

---

<div class="post-metadata">

**Author:** ![Jalex](https://uzu.lurk.org/user_avatar/uzu.lurk.org/jalex/32/2069_2.png) [@Jalex](https://uzu.lurk.org/u/Jalex)\
**Post date:** [1 May 2023 05:22 UTC](https://uzu.lurk.org/t/filter-envelope/2977/5 "2023-05-01T05:22:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![geikha](https://uzu.lurk.org/user_avatar/uzu.lurk.org/geikha/32/2701_2.png) [@geikha](https://uzu.lurk.org/u/geikha)\
**Post date:** [1 May 2023 07:50 UTC](https://uzu.lurk.org/t/filter-envelope/2977/6 "2023-05-01T07:50:08Z")

</div>

the method i shared should be able to work per note

---

<div class="post-metadata">

**Author:** ![ShaiR](https://uzu.lurk.org/user_avatar/uzu.lurk.org/shair/32/2304_2.png) [@ShaiR](https://uzu.lurk.org/u/ShaiR)\
**Post date:** [2 May 2023 06:58 UTC](https://uzu.lurk.org/t/filter-envelope/2977/7 "2023-05-02T06:58:34Z")

</div>

I defined a new envlpf effect for myself as follows:

```haskell
~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:

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

```

and use it:

```haskell
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.

---

<div class="post-metadata">

**Author:** ![geikha](https://uzu.lurk.org/user_avatar/uzu.lurk.org/geikha/32/2701_2.png) [@geikha](https://uzu.lurk.org/u/geikha)\
**Post date:** [4 May 2023 03:36 UTC](https://uzu.lurk.org/t/filter-envelope/2977/8 "2023-05-04T03:36:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cleary](https://uzu.lurk.org/user_avatar/uzu.lurk.org/cleary/32/177_2.png) [@cleary](https://uzu.lurk.org/u/cleary)\
**Post date:** [28 June 2023 05:20 UTC](https://uzu.lurk.org/t/filter-envelope/2977/9 "2023-06-28T05:20:53Z")

</div>

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

> ### yaxu _—_ 24/06/2023 06:55
> 
> how about this @jader
> 
> ```haskell
> 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
> 
> ```haskell
> 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 !
> 
> ```haskell
> 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>"
> 
> ```
