How to use the defaut setting on a some notes only

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! :slight_smile:
Cheers!

hi,

hum i don’t understand what you want :slight_smile:
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 :slight_smile:

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

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 ?

1 Like

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 :slight_smile: ) 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! :confused:
PS: I hope my questions become more pertinent in the near future… :slight_smile:

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
2 Likes

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

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:

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:

# 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
# 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). 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 :stuck_out_tongue_winking_eye: )

1 Like

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! :slight_smile:
Thanks amigos!

2 Likes

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

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 :slight_smile:

thanks

1 Like