From f06553cfb1bc94d9554e8f2202ac65ceddf6081e Mon Sep 17 00:00:00 2001 From: Michael Schubmehl Date: Thu, 5 Feb 2026 00:55:49 -0600 Subject: [PATCH 1/2] calculate_sustain now respects default attack, decay, and release --- app/server/ruby/lib/sonicpi/lang/sound.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/server/ruby/lib/sonicpi/lang/sound.rb b/app/server/ruby/lib/sonicpi/lang/sound.rb index 70cdc027b2..5e8c12e776 100644 --- a/app/server/ruby/lib/sonicpi/lang/sound.rb +++ b/app/server/ruby/lib/sonicpi/lang/sound.rb @@ -3705,11 +3705,11 @@ def add_out_bus_and_rand_buf!(args_h, out_bus=nil, info=nil) args_h["out_bus"] = out_bus.to_i end - def calculate_sustain!(args) + def calculate_sustain!(args, defaults) if args.has_key? :duration and not(args.has_key? :sustain) - attack = args.fetch(:attack, 0) - decay = args.fetch(:decay, 0) - release = args.fetch(:release, 0) + attack = args.fetch(:attack, defaults.fetch(:attack, 0)) + decay = args.fetch(:decay, defaults.fetch(:decay, 0)) + release = args.fetch(:release, defaults.fetch(:release, 0)) duration = args[:duration] sustain = duration - (attack + decay + release) @@ -3848,7 +3848,7 @@ def normalise_and_resolve_synth_args(args_h, info, combine_tls=false) end normalise_args!(args_h, defaults) - calculate_sustain!(args_h) + calculate_sustain!(args_h, defaults) scale_time_args_to_bpm!(args_h, info, true) if info && __thread_locals.get(:sonic_pi_spider_arg_bpm_scaling) args_h From 44976be147b9ddf9a8159fd9c1a7ada1ef0763ef Mon Sep 17 00:00:00 2001 From: Michael Schubmehl Date: Thu, 5 Feb 2026 09:39:07 -0600 Subject: [PATCH 2/2] Docs - play_pattern_timed examples use duration --- app/server/ruby/lib/sonicpi/lang/sound.rb | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/server/ruby/lib/sonicpi/lang/sound.rb b/app/server/ruby/lib/sonicpi/lang/sound.rb index 5e8c12e776..dbe01e5de4 100644 --- a/app/server/ruby/lib/sonicpi/lang/sound.rb +++ b/app/server/ruby/lib/sonicpi/lang/sound.rb @@ -1305,50 +1305,50 @@ def play_pattern_timed(notes, times, *args) # same as: -play 40, sustain: 1 +play 40, duration: 1 sleep 1 -play 42, sustain: 2 +play 42, duration: 2 sleep 2 -play 44, sustain: 3 +play 44, duration: 3 sleep 3", "play_pattern_timed [40, 42, 44, 46, 49], [1, 0.5] # same as: -play 40, sustain: 1 +play 40, duration: 1 sleep 1 -play 42, sustain: 0.5 +play 42, duration: 0.5 sleep 0.5 -play 44, sustain: 1 +play 44, duration: 1 sleep 1 -play 46, sustain: 0.5 +play 46, duration: 0.5 sleep 0.5 -play 49, sustain: 1 +play 49, duration: 1 sleep 1", "play_pattern_timed [40, 42, 44, 46], [0.5] # same as: -play 40, sustain: 0.5 +play 40, duration: 0.5 sleep 0.5 -play 42, sustain: 0.5 +play 42, duration: 0.5 sleep 0.5 -play 44, sustain: 0.5 +play 44, duration: 0.5 sleep 0.5 -play 46, sustain: 0.5 +play 46, duration: 0.5 sleep 0.5", "play_pattern_timed [40, 42, 44], [1, 2, 3, 4, 5] # same as: -play 40, sustain: 1 +play 40, duration: 1 sleep 1 -play 42, sustain: 2 +play 42, duration: 2 sleep 2 -play 44, sustain: 3 +play 44, duration: 3 sleep 3", "play_pattern_timed [40, 42, 44], [1, 2, 3], sustain: 0