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

Possible to cancel a single sound via an event vs. audioContext in total? #12

Closed
marcaaron opened this issue Mar 15, 2018 · 2 comments
Closed

Comments

@marcaaron
Copy link

marcaaron commented Mar 15, 2018

Leveraging this library to create a text keyboard based instrument and I'm wondering if it's possible to cancel a queued up / currently playing sound via say a 'keyup' or some other event? I see that we can predetermine the overall length of the sound via the duration argument at the time of calling queueWaveTable and I've played around with the cancelQueue function on the player by passing it the audioContext. This worked, but canceled all of my currently playing notes. Is there some way I can target a specific sound that has been queued?

Oh and thanks for this! Having so much damn fun over here! 👍

@surikov
Copy link
Owner

surikov commented Mar 15, 2018

queueWaveTable returns envelope for note. You can invoke
envelope.cancel();
to stop note at any time.

Open example 'endless flute'
http://jsbin.com/midadem/1/edit?html,output
look to playPipe and stopPipe

Look to
https://surikov.github.io/midi-sounds-react-examples/examples/midi-sounds-example10/build/
if you use ReactJS

@surikov surikov closed this as completed Mar 15, 2018
@marcaaron
Copy link
Author

marcaaron commented Mar 15, 2018

Cool! Thanks! Since opening this I also noticed that envelopes get saved in the player.envelopes array and can be cancelled from there as well.

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

No branches or pull requests

2 participants