Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sound only working the first time a sketch is run #23

Open
Richard-Mullan opened this issue Feb 5, 2019 · 2 comments
Open

Sound only working the first time a sketch is run #23

Richard-Mullan opened this issue Feb 5, 2019 · 2 comments

Comments

@Richard-Mullan
Copy link

@Richard-Mullan Richard-Mullan commented Feb 5, 2019

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.

add_library('sound')
def setup():
    global ch_1, ch_2
    size(800,480)
    ch_1 = SinOsc(this)
    ch_1.play(400,1)
    ch_2 = SinOsc(this)
    ch_2.play(401,1)
    
def draw():
    global ch_1, ch_2
    background(255)
@Richard-Mullan
Copy link
Author

@Richard-Mullan Richard-Mullan commented Feb 5, 2019

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)
@kevinstadler
Copy link
Collaborator

@kevinstadler kevinstadler commented Mar 16, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.