-
Notifications
You must be signed in to change notification settings - Fork 24
Start audiofile playback manually audiovisualfftdemo #77
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
Conversation
Thanks for the clarification and 'manual' fix @stijnvanbeek, this will do for now, however: It would be nice if initialization and playback is properly synchronized on startup, without the user having to be aware of the underlying structure and manually starting playback on init. Maybe we can solve using the on |
I solved it now differently by handling the mAutoPlay property in the first update() call instead of on init(). Then the user can be assured the whole DSP patch is finished once playback starts. |
This works but we normally try to avoid / don't allow this pattern (bool on update) because it introduces an indirection that should / can be avoided using a better approach. I therefore prefer the manual solution until we 'properly' fix it. What we normally (you could) do is cache the loaded objects - they (de)register themselves with the service on Something like the above or a different solution. I therefore propose to roll-back your latest change, merge the manual fix and create a seperate issue for the inconvenience? |
Will do. In the meantime, do you have an example in the source of objects being cached on init and processed somehow post init? The thing is I don't want the AudioService to be aware of the BufferPlayerNode, the PlaybackComponent or the AutoPlay property. These are all high level constructs for specific functionality. |
See for example: Another (more advanced) example is lights in render advanced:
Many modules use their service to catch and handle global state changes (limited to the scope of their module) - it is what it is partly designed for - the |
I could give the AudioComponentInstance baseclass a virtual start() method? |
Yes that should work just fine - however, do not use (rely) on |
The AudioPlaybackComponent that plays the audiofile internally has 2 BufferPlayerNodes, one for each channel. The FFTNode is mono and only connects to the first channel BufferPlayerNode. The OutputComponent contains two OutputNodes that each connect to their own BufferPlayerNode. However this is what happens chronologically on init:
I verified this and I can see that indeed the FFTNode is already being processed a few times before the OutputComponent is initialized. This also explains why the delay is more noticeable in debug mode.
I solved the problem by setting PlaybackComponent::mAutoPlay to false and manually started playback in the init() of the app. This makes sure playback only starts after all components are initialized and all nodes are connected.