|
Post by pete4242 on Jan 9, 2021 9:22:30 GMT
Hi,
I am new to Master Audio AAA. I need to retrieve and import a varying number of audio files at runtime (via WWW or device file-system) and therefore need to create audio groups at runtime where the member audio clip files (ie: group variations) are defined by the end user during game settings at runtime. Is this possible using the Master Audio API? My initial read of the API docs does not appear to have methods for doing this.
I can see the DynamicSoundGroupCreator option and related API but this appears to only create groups with lists of audio clip files in groups in a pre-defined DynamicSoundGroupCreator object.
Maybe of have completely missed something reading the docs, any pointers would be most helpful.
I am starting to think I should simply create, load and manage the audio clip files using native Unity API rather than Master Audio.
|
|
|
Post by DarkTonic Dev on Jan 9, 2021 9:48:03 GMT
There are 3 approaches if you don't know the audio files ahead of time.
1) Pre-create the Sound Groups with empty audio clips then populate them by code later.
2) Use MasterAudio.createGroupVariationFromClip.
3) Use MasterAudio.CreateSoundGroup
In general there is no support for this as it's pretty difficult to populate all the myriad of fields from the custom Inspectors just from code and have any idea what you're doing.
-Brian
|
|
|
Post by pete4242 on Jan 11, 2021 0:29:01 GMT
Thanks Brian, that's a great help. The audio clips are very short effect clips in response to game events I want the end user to mod themselves. Pre-creating the Sound Groups and populating with audio clips at runtime sounds good, makes sense to configure the Sound Groups at build time as the sound events are known at build time so I can configure the inspector fields appropriately.
Doh...I completely missed the main MasterAudio class detail in the docs, it has the API methods I was looking for, I was focusing on the DynamicSoundGroup class. I appreciate your help pointing me in the right direction.
Given a specific game event, I wish to select 1 clip to play from say 20 possible clips based on game event context parameters. Would it be best to have one sound group for the event with the 20 variations (selecting the variation to play) or have 20 separate Sound Groups? I expect they would all have the same inspector values. My current basic MasterAudio understanding suggests 1 Sound Group with 20 variations (1 set of Sound Group fields to configure) but I would value your advice on which way to go.
-Pete
|
|
|
Post by DarkTonic Dev on Jan 11, 2021 1:29:24 GMT
Yes, use 1 Sound Group with 20 Variations. That's exactly what it's for.
Glad to help!
|
|
|
Post by pete4242 on Jan 11, 2021 9:12:18 GMT
Great thanks again. Two more quick questions if that's OK.
1. I can see the API MasterAudio.GetAllPlayingVariationsOfTransform, but cannot see a method to get all variations (playing or not playing). I assume I would just use standard Unity API like transform.GetChild(i) or transform.GetObjectsOftype<SoundGroupVariation>() or similar. Just making sure there isn't a MasterAudio method I have missed.
2. To create a SoundGroupVariation there is MasterAudio.CreateGroupVariationFromClip, to create one from an addressable or a file-system audio file I assume I use standard Unity API to first create a AudioClip and then pass that to MasterAudio.CreateGroupVariationFromClip. Again just making sure I'm not missing a MasterAudio API call for such things. MasterAduio supports Addressables in the Inspector but it appears that usage is internal to MasterAudio and not exposed via the public API?
|
|
|
Post by DarkTonic Dev on Jan 11, 2021 16:34:16 GMT
1) Actually there is MasterAudio.GetAllPlayingVariations you can use. 2) MasterAudio.CreateSoundGroup can take an addressable but you'll have to fill out tons of properties, without knowing what they all do. As I said, it's not really built for this sort of dynamic scenario.
-Brian
|
|
|
Post by pete4242 on Jan 12, 2021 0:03:30 GMT
1) Does MasterAudio.GetAllPlayingVariations just return variations actively playing or return all variation playing or not playing? I thought the former with the API description "Returns a list of all Variation scripts that are currently playing a sound" but maybe I got it wrong. 2) Thanks, point noted, makes sense.
Thanks again.
|
|
|
Post by DarkTonic Dev on Jan 12, 2021 0:50:09 GMT
Yes, you're right, it gets all the ones Playing. You could change probably 1 line of code in there to get all of them period. What is that for though?
|
|
|
Post by pete4242 on Jan 12, 2021 7:45:30 GMT
I'm selecting a sound variation to play based on the total number of available variations available. In short I'm segmenting a straight line collider into virtual segments where each segment plays a sound variation... colliderSegment(i) plays soundVariation(i). I'll be able to get all variations one way or another.
|
|
|
Post by DarkTonic Dev on Jan 12, 2021 16:18:42 GMT
Is that the number of Variations in a single Sound Group? Because I can get you that code.
|
|
|
Post by pete4242 on Jan 12, 2021 23:30:42 GMT
Correct, thanks that's awesome:)
|
|
|
Post by DarkTonic Dev on Jan 13, 2021 0:07:20 GMT
Here, use this code:
var variations = MasterAudio.GrabGroup("GroupName").groupVariations;
|
|
|
Post by pete4242 on Jan 13, 2021 3:27:23 GMT
Appreciate it, thanks.
|
|
|
Post by DarkTonic Dev on Jan 13, 2021 4:57:21 GMT
Any time.
|
|