arafay
New Member
Posts: 24
Posts: 24
|
Post by arafay on Aug 29, 2016 6:51:56 GMT
Hi there, I'm a building a Quiz App which uses Audio as Questions, Choices. There are 100s of questions and i stich them dynamically on runtime. For example [Question][Number][4] [Actual_Question_Audio] [Choice] [ActualChoice] [Choice] [ActualChoice]
As you can see that there are few shared voices in every level like word "Question" or "Number" or digit "4".
I have 10 folders in Resources, Each folder contains 10 audio files from number 1 to 10
So i play "Question" file, listen to its Complete event, then i play "Number" file and so on...
Now thing is, i used another plugin for that and it worked well so far, however i guess im the only user of that plugin so it breaks every new Unity release and i have to ask the author to make update, and this time he is unable to fix the issue, so i hope AAA audio can serve this case.
So my requirements are using pure Scripting something like - AddResourceFile("readable name of audio", "actual_file_path_in_resources_folder") - PlayResourceFile("readable_name_of_audio", onCompleteEvent); - RemoveResourceFileByName - RemoveAllResourceFiles.
Can you please assist here? Because Using Drag n Drop or UI for this purpose wont help due to dynamic nature of the files. Thanks
|
|
|
Post by DarkTonic Dev on Aug 29, 2016 17:48:35 GMT
If you have the files in your Resources folder, then you can create the Sound groups by dragging with the UI. Code to play them in succession is easy and I can provide it if you did not see it in the documentation.
I don't see a reason why you can't use the UI to create the Sound Groups.
|
|
arafay
New Member
Posts: 24
Posts: 24
|
Post by arafay on Aug 29, 2016 19:44:07 GMT
Reason is, We will have same code but many apps (country quiz, fruits quiz etc) and dragging and dropping seem overkill for 100s of files. It'd be really great if you could expose this functionality via code.
|
|
|
Post by DarkTonic Dev on Aug 29, 2016 19:54:00 GMT
You know you can drag them in bulk right? You don't have to do it one at a time. You could drag all of the 100's at once or groups of 50 or whatever.
Anyway, you can do it from code, but you will have to set many, many parameters if you need different than the default. Use MasterAudio.CreateSoundGroup if you want to do it from code.
|
|
arafay
New Member
Posts: 24
Posts: 24
|
Post by arafay on Aug 29, 2016 20:01:38 GMT
Really appreciate! Can you please provide example code snippet too in light of my first post's requirements? And also Complete Event example as you mentioned.
|
|
|
Post by DarkTonic Dev on Aug 29, 2016 23:30:26 GMT
Here's how to play 3 sounds in a row.
StartCoroutine(PlaySounds()); // in your event method somewhere, calls the private method below.
private IEnumerator PlaySounds() { yield return StartCoroutine(MasterAudio.PlaySoundAndWaitUntilFinished("Arrow")); yield return StartCoroutine(MasterAudio.PlaySoundAndWaitUntilFinished("Blast")); yield return StartCoroutine(MasterAudio.PlaySoundAndWaitUntilFinished("Scream")); }
As far as showing you an example of CreateSoundGroup, I'm sorry but that's not a supported feature, it's there for DynamicSoundGroupCreators to use. You could actually populate a DSGC with everything you need for each scenario, and then just Instantiate the DSGC and all the SoundGroups will be added.
|
|
arafay
New Member
Posts: 24
Posts: 24
|
Post by arafay on Aug 30, 2016 6:51:16 GMT
Alright, let me try on my own then and if i get stuck i hope you will help. Thanks Again
|
|
|
Post by DarkTonic Dev on Aug 30, 2016 15:33:17 GMT
No problem.
|
|
arafay
New Member
Posts: 24
Posts: 24
|
Post by arafay on Sept 1, 2016 6:18:10 GMT
Hi there, I tried and failed miserably, are you sure you cant spare this week to make simplified version? If not, then i'll have no option but to use GUI
|
|
|
Post by DarkTonic Dev on Sept 1, 2016 6:39:55 GMT
I'm already behind on the multiplayer code, so I'm afraid not. And this is not a small task or I'd try to fit it in. The GUI can do what you want anyway especially if you just spawn or instantiate a DGSC. Read about them on the help website.
|
|
arafay
New Member
Posts: 24
Posts: 24
|
Post by arafay on Sept 1, 2016 18:26:50 GMT
Can you please tell me insteps what to do add audio files from resources and then play?
|
|
|
Post by DarkTonic Dev on Sept 1, 2016 18:49:59 GMT
1) In the DGSC, Dynamic Group Mixer section, change the field "Variation Create Mode" to "ResourceFile". 2) Lock your Inspector (click the lock icon in the upper right corner) so you can drag in as many Resource files as you want at once. Each Resource file will create one Sound Group in this mode. 3) Drag in all your Resource files at once. Many Sound Groups will be created.
Not sure what you're asking about "play" though...
|
|
arafay
New Member
Posts: 24
Posts: 24
|
Post by arafay on Sept 2, 2016 11:57:53 GMT
ok i tried with 1) and the first problem i got is "you already have a group name question". which happend because if i have 10 levels, and each level have 10 questions, then each question folder has file name as "quesiton.mp3". If you look at following file structure, first [1] is level and we have 10 level folders, now first level folder has 10 questions so 1-10 folders, now each folder has same a question and 4 choices. As you can see this structure helped us dynamically loading sound files and removing them/ question in same scene. So how can i handle this case? Secondly if i load an audio file myself, can i pass that file directly to PlaySoundAndWaitUntilFinished to play? this way i can bypass whole sound group creation problem. yield return StartCoroutine(MasterAudio.PlaySoundAndWaitUntilFinished("Arrow")); Lastly, i really appreciate your help.
|
|
|
Post by DarkTonic Dev on Sept 2, 2016 15:13:18 GMT
No you cannot name the Sound Groups identically. You must slightly alter the name.
There are many steps to loading the Resource file to make sure it's not kept in memory when not used and nit loaded more than needed. No you cannot load it yourself or Master Audio can't use it.
|
|
arafay
New Member
Posts: 24
Posts: 24
|
Post by arafay on Sept 2, 2016 17:41:02 GMT
So what do you suggest for this case where filenames are identicals?
|
|