-
Notifications
You must be signed in to change notification settings - Fork 7
Description
In order to use limited mobile browser resources efficiently - especially for projects with large numbers of speakers - we need to load speakers based on proximity rather than load and start playing all of them immediately (albeit out of range ones at 0 volume).
Below migrated from another unrelated ticket #81
we need to make sure memory constraints of the browser as well. these AudioBufferSourceNode will take more memory than normal streaming. too
many or large speakers, and processing/storing them at once might crash on some devices like mobiles not having much ram.
hburgund
I worry if there are hundreds of speakers that we may have resource issues as you mention, doing this, so we might want to consider doing this work in stages based on proximity to the listener? In other words, do all speakers within a certain distance, say 100m to start and then when more speakers enter this buffer zone, we do those?
Invisible Choir will likely have hundreds of speakers eventually. They will be short, but there will be a lot of them.
shreyas-jadhav
work in stages based on proximity to the listener?with this approach, i think we will be having issues on walking mode.
for anyAudioBufferSourceNode, thestart()function requires an user interaction. and we cannot already start() without a ready buffer.
current behaviour is all speakers have a ready buffer and started at first play hit, but at 0 volume.
hburgund
ah, ok...hmm...so if there are 300 speakers in the project, we would be asking the mobile browser to play 300 simultaneous pieces of audio? This seems like we are asking for trouble! What do you think? Shouldn't we have the ones not in range be paused at least to save resources? I understand if they are paused and then they are needed for playback, it would be hard to sync them(?), but I guess we could consider adding new speakers to the mix only at the loop point if that was easier?
Seems like there must be a way to make this more efficient or not require the user interaction for each and every different audio clip. Seems like mobile games work around this somehow with tons of sound effects?
shreyas-jadhav
sorry, actually disregard what i said about user interaction. i forgot that we are actually allowed tostart()later too after one initial touch,
but the requirement tostart()for all speakers at initial play button click was to ensure the synchronisation.
but i think there should be some way to achieve synchronisation too with this procedural loading.
hburgund
Ah, this is great news @shreyas-jadhav! I'd love to hear your thoughts about how to achieve sync even without starting all at the same time. Seems to me that something like:
- set a physical buffer size for a project
preloadSpeakerBufferDistance - when initial play is pressed, load all speakers that overlap the circle defined by this range and the listener's location i.e. "in range"
- on each location update, re-evaluate which speakers are within this range, "load" any new ones (I assume this would simply mean to start them playing at 0 volume?) and "unload" any that are outside of the range
- each newly added speaker could start playing at the loop point to achieve proper sync. If we adjust the
preloadSpeakerBufferDistanceproperly and don't have super long loops, in most cases, the listener would enter the new speaker zone well after it was loaded and started playing at the loop point, so this seems like it should work
This might be overly simplistic, but LMK what you think. This would be a great thing to work on now.