python-sonic icon indicating copy to clipboard operation
python-sonic copied to clipboard

Correct synth scope in threads

Open jmoon1506 opened this issue 4 years ago • 0 comments

This snippet should play BEEP, TB303, BEEP.

use_synth(BEEP)
play(50)
sleep(1)

@in_thread
def test():
    use_synth(TB303)
    play(50)

test()
sleep(1)
play(50)

(See https://sonic-pi.net/tutorial#section-5-4)

However, due to the global _current_synth variable, the current behavior overrides the last note's synth and instead plays BEEP, TB303, TB303. I've fixed this by changing the global _current_synth to a dictionary with keys based on thread id.

jmoon1506 avatar Sep 24 '21 07:09 jmoon1506