secondlife / jira-archive

2 stars 0 forks source link

[BUG-234965] Proposal to define and play a fragment of a sound clip #11787

Open sl-service-account opened 5 months ago

sl-service-account commented 5 months ago

How would you like the feature to work?

The sound functions such as llPlaySound, llTriggerSound, llLoopSound, etc, should be able to play a specified fragment of a sound clip.

It is quite a number of the sound functions already and more may come in future. All of them receive the name or key of the sound clip to play as parameter. We use this fact and can avoid creating a new function for every of them. Instead we have only one additional function:

key llSoundFragment(key sound, integer frames, float start, float end)

This function receives a sound clip, given either by sound in inventory or by a key and returns a key, which will be a 'reference' to the provided sound clip and the time fraction to play. 

The returned 'fragment key' can be then used within the sound functions which expect the sound name or key as parameter. 

The parameters frames, start, end define the position of the clip fragment:

Original Jira Fields | Field | Value | | ------------- | ------------- | | Issue | BUG-234965 | | Summary | Proposal to define and play a fragment of a sound clip | | Type | New Feature Request | | Priority | Unset | | Status | Accepted | | Resolution | Unresolved | | Reporter | Jenna Felton (jenna.felton) | | Created at | 2024-01-09T13:57:55Z | | Updated at | 2024-01-24T19:29:26Z | ``` { 'Build Id': 'unset', 'Business Unit': ['Platform'], 'Date of First Response': '2024-01-09T22:17:50.081-0600', 'How would you like the feature to work?': 'The sound functions such as llPlaySound, llTriggerSound, llLoopSound, etc, should be able to play a specified fragment of a sound clip.', 'ReOpened Count': 0.0, 'Severity': 'Unset', 'Target Viewer Version': 'viewer-development', 'Why is this feature important to you? How would it benefit the community?': 'This feature allows to create a number of new applications. Especially after long sound clips can be uploaded:', } ```
sl-service-account commented 5 months ago

JIRAUSER341305 commented at 2024-01-10T04:17:50Z, updated at 2024-01-10T04:25:19Z

Admittedly, I've done very very little sound stuff, but my understanding is that SL uses a fixed sample rate, so frames, start/end times, etc., is just basic math with known numbers.  So why not just have the start and end in samples:

key llSoundFragment(key sound, integer start, integer end)

If the sample rate may ever change, then we just need a way to get it — could be handled just fine by BUG-232877 accepting keys as well as inventory names, and returning both length and sample rate.

There's also no need to save the extracted sample in script memory, or on the sim at all — just need to store the originating UUID, and start/end sample indexes (grand total of 24 bytes per fragment), then send them to the viewer when called for.  This has the added benefit that slicing a sound into multiple parts, the viewer only needs to download the original sound sample once.

The script could be limited to some number of sound fragments, similar to listens, you would need to release them when they're no longer needed (128 should be enough for anyone!).  I'd think this sample registry should probably be object-bound, but that doesn't necessarily preclude the keys being available region-wide as you suggest (the sim just needs to maintain an index of all the active fragment keys — though a function like llLoadSoundFragment that does a more object-to-object binding could still work).  And in place of a lifetime, just drop the fragment.  Allowing a script to generate several instances of the same fragment would suffice for lifetime management.

sl-service-account commented 5 months ago

Spidey Linden commented at 2024-01-24T19:29:26Z

Issue accepted. We have no estimate when it may be implemented. Please see future release notes for this fix.