Sound sample play once

Hey all,
I want to trigger a sample one shot with an OSC message. My issue is if I say in the mousePressed() event sound.play() it will trigger the sample once and play until the end. If I say sound.play() when bool is true then it will play a billion times because the bool is true in multiple frames in the draw() function. [Here is the example code][1]

thanks for any help on this
[1]: https://github.com/nightshining/nsPerformance/blob/master/audioVisualPerformance/src/ofApp.cpp

Why is that wrong? When should it stop?

I apologize, I think my question was a bit confusing. I want to trigger a sample like when you assign a sound.play() to the keyPressed() function, where it plays once and until the end of sample, only instead using an OSC message I’m thinking bool on/off. Although when I send a bool true/false to trigger a sample it plays for every frame draw() is called. Ideally, I want to be able to call a function outside the draw() update() functions. Thanks again.

The bool, on/off will work but you’ll have to set the bool to false again after it has been triggered