# How to use the defaut setting on a some notes only

**URL:** <https://in-thread.sonic-pi.net/t/how-to-use-the-defaut-setting-on-a-some-notes-only/6402>\
**Category:** Support, Help & Resources\
**Created:** [January 14, 2022, 5:50pm UTC](https://in-thread.sonic-pi.net/t/how-to-use-the-defaut-setting-on-a-some-notes-only/6402 "2022-01-14T17:50:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![minetestist](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/minetestist/32/2194_2.png) [@minetestist](https://in-thread.sonic-pi.net/u/minetestist)\
**Post date:** [January 14, 2022, 5:50pm UTC](https://in-thread.sonic-pi.net/t/how-to-use-the-defaut-setting-on-a-some-notes-only/6402/1 "2022-01-14T17:50:29Z")

</div>

Hi there…  
I’d like to be able to tell Sonic Pi to use the default value on an FX or synth, without having to go check for it immediately…  
A little bit like (ring :c2, :r, :r, :d2, :r, c2), but for options instead of notes…  
Is this possible? Must be, but I searched the documentation and tutorials and didn’t find it…  
Thanks in advance! 🙂  
Cheers!

---

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [January 14, 2022, 10:14pm UTC](https://in-thread.sonic-pi.net/t/how-to-use-the-defaut-setting-on-a-some-notes-only/6402/2 "2022-01-14T22:14:47Z")

</div>

hi,

hum i don’t understand what you want 🙂  
Edit : i guess you want to know if there is a way to get the default value designed by Sam for some parameters ?  
i don’t know 🙂

```ruby
use_bpm 120
with_fx :slicer, mix: 0 do |m1| #applied to all enclosed live loops
  in_thread do
    loop do
      synth :piano, note: (ring :c4, :e3, :g3, :a2).tick(:n) -12, res: 0.8, sustain: 0.2,
        cutoff: (ring 110, 70, 115, 85).tick(:ggg)
      
      sleep 0.5
      control m1, mix: (ring 1, 0, 1, 0.25).tick
    end
  end
end

```

```ruby
use_bpm 120
with_fx :echo, mix: 0 do |m1| #applied to all enclosed live loops
  
  in_thread do
    loop do
      sample :bd_mehackit
      sleep 1
      control m1, mix: (ring 1, 0, 0.5, 0.75, 0).tick
    end
  end
end

```

So does it help ?

---

<div class="post-metadata">

**Author:** ![minetestist](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/minetestist/32/2194_2.png) [@minetestist](https://in-thread.sonic-pi.net/u/minetestist)\
**Post date:** [January 14, 2022, 11:36pm UTC](https://in-thread.sonic-pi.net/t/how-to-use-the-defaut-setting-on-a-some-notes-only/6402/3 "2022-01-14T23:36:22Z")

</div>

Hi!  
Well, for example I’d like to be able to tell Sonic Pi to use 100 as a value for the cutoff effect on the first note in the ring, and tell it to go back to the “factory default” value (or “Sam default” as you put it yourself 🙂 ) of the effect for the rest of the notes, even if I don’t remember what that default value is at the moment…  
Your solution works, but it still requires you to know the value…  
I mean I do know the default value for the effect in this example, but I was wondering if there was any way to tell it to Sonic Pi even if I didn’t remember it… Just go back to factory default setting.  
Probably a silly question, sorry about that! 😕  
PS: I hope my questions become more pertinent in the near future… 🙂

---

<div class="post-metadata">

**Author:** ![shemp](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@shemp](https://in-thread.sonic-pi.net/u/shemp)\
**Post date:** [January 15, 2022, 12:42am UTC](https://in-thread.sonic-pi.net/t/how-to-use-the-defaut-setting-on-a-some-notes-only/6402/4 "2022-01-15T00:42:15Z")

</div>

```ruby
use_bpm 60

use_synth :mod_fm
use_synth_defaults

play :c3
sleep 1

with_synth_defaults attack: 0.25/2, release: 0.5/2, cutoff: 72 do
  play_pattern_timed [:c4, :b3], [0.5]*2
end

play 72
sleep 1

```

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [January 15, 2022, 1:11am UTC](https://in-thread.sonic-pi.net/t/how-to-use-the-defaut-setting-on-a-some-notes-only/6402/5 "2022-01-15T01:11:40Z")

</div>

Shemp’s example probably uses the easiest techniques as far as synths are concerned 🙂

To work with fx in this way, there is no simple out-of-the-box solution - we have to reach into the guts of Sonic Pi for some internal metadata:

```ruby
defaults = ::SonicPi::Synths::SynthInfo.get_info('fx_bitcrusher').arg_defaults

```

Then, there are two ways to play with the opt values of the fx - either set them before the fx starts, or change them while the fx is running. Here’s examples of how you could use either approach:

```ruby
# Set the fx opts before the fx starts

live_loop :test do
  sample_rates = (ring 1000, nil, 1000, nil)
  sample_rates.length.times do
    tick
    opts = if sample_rates.look
      {sample_rate: sample_rates.look}
    else
      {sample_rate: defaults[:sample_rate]}
    end
    with_fx :bitcrusher, opts do
      synth :fm
      sleep 1
    end
  end
end

```

```ruby
# Set the fx opts while the fx is playing

live_loop :test2 do
  with_fx :bitcrusher do |bc|
    sample_rates = (ring 1000, nil, 1000, nil)
    sample_rates.length.times do
      tick
      if sample_rates.look
        control bc, sample_rate: sample_rates.look
      else
        control bc, sample_rate: defaults[:sample_rate]
      end
      synth :fm
      sleep 1
    end
  end
end

```

Both approaches have a few potential drawbacks:

- they both create a new fx instance every cycle around the live\_loop - this can potentially be a resource drain for intensive fx such as `:reverb` etc (as described in the Tutorial at [Sonic Pi - Tutorial](https://sonic-pi.net/tutorial.html#section-6-2)). However, the first example _also_ creates a new fx instance _several times_ during the live\_loop, once for each synth note/opt value. This may be even _more_ resource intensive for those complex fx…

- the second example creates one fx instance per live\_loop cycle, is able to make changes to an fx sound while it is playing, but if we want to change to the new opt value ‘instantly’, there is a small glitch-like sound as we transition to the new opt value (since IIRC it might not be ‘truly’ instant - though I might be wrong about that 😜 )

---

<div class="post-metadata">

**Author:** ![minetestist](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/minetestist/32/2194_2.png) [@minetestist](https://in-thread.sonic-pi.net/u/minetestist)\
**Post date:** [January 15, 2022, 3:28am UTC](https://in-thread.sonic-pi.net/t/how-to-use-the-defaut-setting-on-a-some-notes-only/6402/6 "2022-01-15T03:28:29Z")

</div>

Oh OK, I think I get it, and the script is instructive…  
But I think I actually prefer just looking up the value in the docs then…  
Might reuse these ideas for other stuff though! 🙂  
Thanks amigos!

---

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [January 15, 2022, 10:40am UTC](https://in-thread.sonic-pi.net/t/how-to-use-the-defaut-setting-on-a-some-notes-only/6402/7 "2022-01-15T10:40:11Z")

</div>

thanks @ethancrawford for this journey in the guts of sonic pi 🙂

So why not mplement a native function to get the default value for an instruction ?

`get_default( name_of_instruction, parameter)` and its use : `get_default ("sample", "cutoff')`

if my question is silly forget about it 🙂

thanks
