# Generative guitar/cello/autoharp textures

**URL:** <https://in-thread.sonic-pi.net/t/generative-guitar-cello-autoharp-textures/8774>\
**Category:** Creations & Ideas\
**Created:** [April 13, 2024, 11:42am UTC](https://in-thread.sonic-pi.net/t/generative-guitar-cello-autoharp-textures/8774 "2024-04-13T11:42:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brendanmac](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/brendanmac/32/2809_2.png) [@brendanmac](https://in-thread.sonic-pi.net/u/brendanmac)\
**Post date:** [April 13, 2024, 11:42am UTC](https://in-thread.sonic-pi.net/t/generative-guitar-cello-autoharp-textures/8774/1 "2024-04-13T11:42:36Z")

</div>

Hi  
I have spent most of the week getting to know the :pluck synth, particularly its envelope function. I discovered (as you all have, no doubt) that beyond the standard ‘steeple and church’ ADSR shape we can create unnatural envelope shapes like a capital M, where the decay level is lower than the sustain level. This causes a gentle pulsing reverb-like effect in the ADSR envelope. Again, not news to anyone here.

I also wanted an autonomous algorithm to generate random ‘windchime’ events with minimal user input, so the two controls for this function are attack time (0 - 1) and repeats (1 ~ \<100), the latter is simply the max value for a random sleep range.

The attack time input (0 - 1) is mapped in several ways. Attack and decay values are the same; the decay level is the inverse of attack, such that a percussive strike (attack = 0) has maximum amplitude at the start. Longer attack times (~ 1) cause the decay level to decrease. And the sustain level is the inverse of the decay level, so the shape has this seesaw/hinge mapping.

I’ve mapped and scaled (\* 0.4) the damping coefficient to attack time, just because. You can hardwire it back to 0.5 or thereabouts. I literally let this run in the background for ages, lovely sounds. If you exceed the input value bounds you will break it (attack \> 1 can cause negative dec/sus levels, because there’s no .clamp method currently).

```ruby
/ generative autoharp plucky-bowy thing /

/ USER INPUT HERE /
atkmax = 0.5 # must be 0 ~ 1
rpts = 7 # 1 ~ <100

/ SETUP ONLY /
use_synth :pluck
rpts = 1.0/rpts * 10.0 # just remapping

live_loop :guitelloarp do
  atkdec = rrand(0.0, atkmax+0.01) # semi-randomised atkdec
  decsus = 1.0 - atkdec # atkdec 0 ~ 1.0, decsus is its inverse
  decsus = decsus**2 # ensure decsus >0
  
  play chord(:a1, :minor7, num_octaves: 4).choose, amp: 2,
    attack: atkdec, decay: atkdec, decay_level: decsus,
    sustain: 3, sustain_level: atkdec,
    coef: decsus * 0.4 + 0.1,
    pluck_decay: 30,
    pan: rrand(-0.4, 0.4)
  
  sleep rrand(0.1, rpts)
end

```

No reverbs were harmed in the making of this patch.  
PD-Pi

---

<div class="post-metadata">

**Author:** ![coodge](https://avatars.discourse-cdn.com/v4/letter/c/74df32/32.png) [@coodge](https://in-thread.sonic-pi.net/u/coodge)\
**Post date:** [April 14, 2024, 5:27am UTC](https://in-thread.sonic-pi.net/t/generative-guitar-cello-autoharp-textures/8774/2 "2024-04-14T05:27:09Z")

</div>

Some really nice sounds. This will no doubt be a handy tool and timesaver for me. Cheers!
