Comments (3)
Hi @LeventeAsztalos, thanks for your findings.
I did some experiments using Soloud.play()
and Soloud.playClocked()
.
On C side I wrote a thread which plays your given sample 200 times. The result is this:
The upper graph is made using Soloud.playClocked()
, the bottom with Soloud.play()
with a microseconds scale.
As you can see there are a lot of delays around 40ms which is the buffer length as stated in Soloud.playClocked()
doc:
Note that if your "physics time" granularity is low, playClocked is not really useful. Audio buffers tend to be 40ms long at most.
To test this, I used this code on C side:
ActiveSound *sound = sounds[0].get();
std::thread th(
[sound, time, this]
{
for (int i = 0; i < 200; i++)
{
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
this->soloud.playClocked(time, *sound->sound.get());
// this->soloud.play(*sound->sound.get());
usleep(time*1000000);
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
std::cout << std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count() << std::endl;
}
});
th.detach();
There is no much difference doing the same on Flutter side with a code similar to yours. So the problem could be on SoLoud lib, but as you stated, the lib is not meant to be used as a music sequencer.
I have to investigate further, maybe there is some compiler args to pass or some other tips I missed.
from flutter_soloud.
Digging further I tried lowering the buffer size to 1024 or 512 instead of 2048 (which stores the previously mentioned 40ms).
This is the result:
There is not much difference between playClocked()
and play()
, anyway some better results.
Currently is not possible to change player initializing parameters, but you can try to manually modify it here
from flutter_soloud.
Thanks for the quick and detailed analysis! I tried with 512 buffer size, and the result were much better. It would be nice if we could set these params from the flutter side. On the other hand with this approach there will always be some latency. My original problem is not related to the package itself, it rather a technical method question, so I close this issue.
from flutter_soloud.
Related Issues (20)
- feat: Add custom source data for capturing HOT 3
- fix: Crash when opening a malformed mp3 file HOT 2
- feat: Make it possible to "instance" SoLoud? HOT 3
- feat: Find a better mechanism than the `audioEvent` stream for listening to changes in the engine HOT 3
- feat: Fail-fast more often HOT 2
- feat: WASM support HOT 27
- chore: Address C++ compilation warnings HOT 2
- proposal: Another set of renames HOT 4
- feat: Implement setProtectVoice() HOT 1
- docs: What does disposeSound actually do? HOT 2
- fix: Wrong error reported when trying to add a filter twice
- bug: crash on deinit() HOT 1
- fix: App asks for microphone permission even though it's not using it HOT 4
- feat: Simplified Recording Mechanism HOT 12
- feat: WaveForm for complete Audiofile HOT 1
- fix: Missing audio on playing a loaded url HOT 1
- fix: Init error on hot restart HOT 3
- fix: handles become invalid at unknown points HOT 9
- MA_NODE_FLAG_SILENT_OUTPUT duplicates API recursive triggers (bangs) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_soloud.