|
Post by alexstrook on Nov 1, 2021 15:35:56 GMT
Hello! I'm currently trying to do something with Master Audio, which I think should be straightforward, but I would love some pointers I have 3 audio clips: -Song_intro -Song_loop_varA -Song_loop_varB The goal is to play Song_intro when I start a certain level, then fade into Song_loop_varA once the intro is done. I need to be able to dynamically switch between A and B depending on gameplay parameters (for example, the player Y position).
Here is my current setup I don't know if it makes sense, please excuse the detailed explanation, but I want to make sure im using master audio correctly: In my Persistent gameplay scene : - Master Audio Prefab
- Playlist Controller "PLC_Music", No initial Playlist
In my Game level scenes (I have multiple of those, they all need their own Intro + loop variations. I want to load/unload them dynamically.) - DynamicSoundGroupCreator with 2 Playlists : "PL_Song_INTRO", "PL_Song_LOOP"
- the "PL_Song_INTRO" dynamic playlist has just one clip ("Song_Intro"), transition is "New Clip from beginning", Create mode "Ressource"
- the "PL_Song_LOOP" dynamic playlist has two clips ("Song_loop_varA", "Song_loop_varB"), transition is "Synchronize Clips", Create mode "Ressource"
Right now in code, whenever I enter a new Game Level. I do (pseudo code) :
private void OnLevelEntered() { PLC_Music.StartPlaylist(MasterAudio.GrabPlaylist(PL_Song_INTRO, true)); PLC_Music.SongEnded += OnIntroEnded; }
private void OnIntroEnded(string songName) { PLC_Music.SongEnded -= OnIntroEnded; PLC_Music.StartPlaylist(MasterAudio.GrabPlaylist(PL_Song_LOOP, true)); PLC_Music.CurrentSong.isLoop = true; }
This works, but once my Playlist Controller is playing the " PL_Song_LOOP", I can't manage to switch on demand to the other variation seamlessly, I'd love some guidance on how to do this! private void PlayMusicVariation(string variation) { // how ? } Note: Should all of those track be in ressources, or streaming?
Thank you! Enjoying Master Audio a lot so far!
|
|
|
Post by DarkTonic Dev on Nov 1, 2021 16:09:13 GMT
I think it sounds like you're trying to switch between 2 different playlists, and expecting that to be seamless. It actually only works on songs in the SAME playlist. So fix that and you should be fine.
-Briam
|
|
|
Post by alexstrook on Nov 1, 2021 17:25:12 GMT
But would it make sense to have audio clips of different length in a playlist set to "synchronize Clips"? The intro and the loop are not the same length and the Master Audio Playlist inspector clearly shows "All clips must be of exactly the same length in this mode"
To be precise with what im doing up there is
-Once the intro is done I switch to the playlist will all the looping variation (this works fine right now, I manage to successfuly change playlist once the intro clip is done) -I don't know exactly what function should I call, to seamlessly transition to another clip in a "synchronized" playlist?
Thanks!
|
|
|
Post by DarkTonic Dev on Nov 1, 2021 17:27:30 GMT
Everything loops with Synchronize Clips. So if you don't want the intro to loop, it's not a good choice anyway.
|
|
|
Post by alexstrook on Nov 1, 2021 17:29:51 GMT
Edited my message up there with a bit more detail.
As said in the first message, I don't need the intro to loop! Once the intro is done, It will never play again unless I renter the level.
The question is: What function do I need to call to change the clip currently playing in a playlist, and have it play at the exact same time the previous clip was playing? (In a synchronized playlist) Thanks for the fast replies
|
|
|
Post by alexstrook on Nov 1, 2021 17:43:47 GMT
Ok, I got it working with:
MyPlaylistController.TriggerPlaylistClip(ClipName);
Turns out my crossfade time was 0 and it was not working? Not sure why!
So in the end my setup is:
Dynamic Playlist: PL_Intro (with 1 clip)
Dynamic Playlist: PL_Loop (with multiples clips of same length, Playlist is of type Synchronized, Crossfade time not 0)
At the start of a level, I assign and play the PL_Intro to my PlaylistController. On the intro is done, I changed the current playlist of my Playlist Controller to the PL_Loop playlist (when "PlaylistController.SongEnded" is called)
from now on, I can switch between any clip of the PL_Loop seamlessly using
PL_Loop.TriggerPlaylistClip(Clipname);
|
|
|
Post by DarkTonic Dev on Nov 1, 2021 18:16:53 GMT
Cool. I believe there's no crossfade when you switch playlists though.
|
|
|
Post by alexstrook on Nov 1, 2021 18:50:31 GMT
Yeah, but its ok! The intro section doesnt need to fade to the loop playlist(the music is cut perfectly to the right moment). The only moment the system needs to crossfade is between variation of a loop (and it always happens within a playlist)
|
|
|
Post by DarkTonic Dev on Nov 1, 2021 21:09:59 GMT
Ok cool.
|
|