Closed schollz closed 5 years ago
Hi! I'm glad you enjoy Beep :)
What you're asking for is entirely supported if I understand it correctly. You need to use Ctrl. Specifically, to cancel a streamer you need to set the Streamer
field of Ctrl
to nil
.
You can learn about it in this part of the tutorial. I recommend reading the whole tutorial, it'll give a bunch of insight.
@faiface Thanks for the quick reply!
Oops, it was right there in the docs which I admit I didn't read yet! I think that will work perfect. I'm working on implementing a midi keyboard and want to trigger sounds on on key down and trigger sounds off on key up.
Oh, that's great! Feel free to share it when you have it done :)
A few tips. Make sure to read up on the Buffer type, either in the docs or in the tutorial (though I recommend the tutorial). Also make sure to use a small buffer size (the thing you set with speaker.Init
at the beginning of your program) to get the best latency. Low latency is pretty important to make playing on the keyboard pleasant.
@faiface Definitely will share, and thanks for the tips. I made something similar before (https://github.com/schollz/pianoai) but I want to be able to play directly through the computer instead of through the piano. Thanks to you, I should be able to!
Wow, that's rad! So you're quite a programmer, I see :) Definitely looking forward.
Hi @faiface, thank you so much for this library. It is an incredible work of code and performs really beautifully.
One thing I couldn't figure out from reading your docs (which are also well written btw!) is whether there is a pattern to stop / cancel a streamer?
In the most basic case, something like this:
Even if there is a hacky way to do this (e.g. maybe setting the volume to zero and still letting it play out?), I'd be very grateful for any advice.