Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions app/server/ruby/lib/sonicpi/lang/sound.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down