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

How do I stop playing audio? #1273

Open
lihongyao opened this issue Sep 7, 2024 · 0 comments
Open

How do I stop playing audio? #1273

lihongyao opened this issue Sep 7, 2024 · 0 comments

Comments

@lihongyao
Copy link

Hello, I wrapped a class based on tonejs and then provided a function to play midi like this:

public play(midi: number, durationInSeconds: number) { const frequency = (Tone.Midi(midi) as any).toFrequency() as number; this.sampler?.triggerAttackRelease(frequency, durationInSeconds); }

What should I do if I need to stop the audio I'm playing based on a situation?
I tried to use the following function to achieve my needs, but it didn't get the effect I wanted, and the audio didn't stop.

public stop() { this.sampler?.triggerAttackRelease(1, 0.1); }

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

No branches or pull requests

1 participant