Closed Richard-Mullan closed 1 year ago
Another example of code which works perfectly well. Only reason this is noteworthy is that if the mouse is clicked, then released, then clicked again, the program works as intended, with the sound stopping and starting as it should. It's only when the sketch is closed and then run again without closing and re-opening the whole processing environment that there is an issue.
add_library('sound')
def setup():
global ch_1, ch_2
size(800,480)
ch_1 = SinOsc(this)
ch_1.play(0,1)
ch_2 = SinOsc(this)
ch_2.play(0,1)
def draw():
global ch_1, ch_2
background(255)
if mousePressed:
ch_1.set(400, 1, 0, 0)
ch_2.set(401, 1, 0, 0)
else:
ch_1.set(0, 1, 0, 0)
ch_2.set(0, 1, 0, 0)
This issue sounds very similar to #10, which makes me think there's a problem with how Java libraries are handled in Python mode more generally, and in particular how that affects external resources such as sound cards or libraries performing work in separate threads. I therefore suggest you open an issue over at https://github.com/jdf/Processing.py-Bugs/issues
Hi, I have a weird problem with sound in processing.py, I'm not sure if it's a bug or if I'm doing something wrong, but I've had a look around and can't find anyone else mentioning it. When I first open a sketch, it works perfectly as intended, I hear a nice beating tone. However if I exit and then run the program again, no sound is ever heard. It only works again if I close and reopen processing, regardless of any changes made or not made to the code, ie: making it interactive or anything works perfectly fine so long as it's the first time the sketch has been run.
TL;DR: sound is only audible the first time running a sketch every time processing is opened Any help greatly appreciated, thanks.