Closed sonosole closed 3 months ago
Hey! You could use a Ref
, like so:
# S
@bind vol Slider(0:0.5:4, default=1.0)
# a Ref is like a vector with just one element
vol_ref = Ref(1.0)
vol_ref[] = vol
@bind play_song CounterButton()
# C
begin
# use this variable here to make the button trigger this cell
play_song
@async let
# by referencing vol_ref instead of vol, the slider does not trigger this cell
vol_current = vol_ref[]
for chunk in wavdatas
write(spk, chunk .* vol_current)
end
end
end
Hope this helps, let me know otherwise! It sounds like you're writing a fun notebook with music :)
Every time I drag the slider
S
, the slider triggers another codeC
which needs the slider-value, what if i want to runS
andC
asynchronously, soC
would not be triggered over and over again. This need could happen when i play a song, the song's volume is controlled by the slider-value. likeis it possible in Pluto? I'm not using it much. Thanks !