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
Using with Android via Oboe - threading question #49
Comments
Hi there! If you have two threads, one calling tsf_render, and another one calling tsf_note_on without any concurrency control, you are in dangerous territory. Except! While writing this response, I started writing a suggestion to modify the library so that a maximum number of possible voices could be pre-allocated to avoid the need to re-allocate during tsf_note_on. This lead me to commit a new function in bf57451 which I'd love if you could test out some more. After tsf_load you can now call If you want to try yourself to see the problem without concurrency control, you can remove the mutex and SDL_Delay from from example2.c. Then add a Keep in mind, that I think that there is a theoretical chance that ending notes would negatively influence a voice that is rendering at the same time. I tried to avoid the worst case whereas a voice that was supposed to end with note_off would continue to play because the rendering just happened to overwrite the segment change. I did this by just setting the segment twice inside Hope this helps! And thanks for using the library and reporting this! |
Awesome, thanks for that. That does appear to fix the issues I was seeing, and in fact I was indeed crashing occasionally when running without mutexes before, and it doesn't appear to be crashing any more. I've set the max_voices in my app to 256, which seems like way overkill for the sorts of MIDI it will play, but it doesn't seem to use up much memory, and it plays perfectly. I'll let you know if I get any stuck hanging notes (i.e. note_offs dropped), but so far it's been fine. |
Tried it, and looks like it works flawlessly. I also wrote a trivial stream implementation which can load the sound font from assets using AAssetManager. |
Can you share your oboe implementation, and load using AAssetManager please ? |
Here you go: https://github.com/romanbsd/tiny_midi_player |
Hi there,
I'm trying to use TinySoundFont to render sound to Android using https://github.com/google/oboe/.
I'm having trouble marrying these two bits of documentation:
Any ideas of what I can do? For what it's worth, running without mutexes seems to work fine, and adding mutexes adds only very slight audio glitches here and there, so maybe I can just not include mutexes, but that feels dangerous.
The text was updated successfully, but these errors were encountered: