1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. Photobucket has changed its policy concerning hotlinking images and now requires an account with a $399.00 annual fee to allow hotlink. More information is available at: this link.
    Dismiss Notice
  3. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  4. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  5. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  6. Dismiss Notice
  7. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

Tutorial: Adding Music to Your MOD Civilization

Discussion in 'Civ6 - Modding Tutorials & Reference' started by FurionHuang, Aug 29, 2017.

  1. FurionHuang

    FurionHuang Chieftain

    Joined:
    Apr 27, 2017
    Messages:
    136
    Gender:
    Male
    So as I promised @sukritact , I'm gonna post a tutorial showing how to make MOD music work.
    First you will need Wwise v2015.1.9, most of us should use 64-bit version.

    Create a new project in Wwise, name the project whatever you wish.

    Spoiler Overview :

    A quick over view of what you need under "Audio" tab:
    upload_2017-8-29_18-49-41.png
    To make the music volume be able to respond to options in game, we need a bus structure as: Master Audio Bus-Master Music Bus-Music Bus.
    For in game music, we need to create switch containers under Interactive Music Hierarchy.
    The main switch container I use is named "DS_Music" which indicates that's my Dark Souls Mod music. Under the switch container I have 2 Playlist Containers: DS_Ancient_Era_Music and DS_Industrial_Era_Music. Pretty straight forward they are for different era theme musics. Under each playlist container we should have at least one Music Segment, and import the piece of music under that segment. You could have more segments if you want to mix more music, beyond my knowledge but I believe it's totally possible.


    Under "Layouts" of menu bar, select Interactive Music.
    Spoiler Imported Music :

    Now click on your imported music:
    upload_2017-8-29_18-55-14.png
    Enable "Stream" so that it can stream in game.
    Go down to music segment editor and drag the Exit Cue all the way down to NEARLY the end.
    upload_2017-8-29_19-16-2.png
    This is for switching song in the game when it's finished playing.


    Nothing special under music segment properties.

    Spoiler Playlist Container :

    Click back on playlist container, you will see this:
    upload_2017-8-29_19-0-2.png
    Drag your music segments into your music playlist editor.


    Spoiler Switch Container :

    Back up to switch container:
    upload_2017-8-29_19-1-46.png
    In properties, select Music Bus for Output Bus.


    Then we need to go to Game syncs.
    Spoiler Overview :

    upload_2017-8-29_19-3-24.png
    Again, an overview of what we need here. Don't worry about the Game_Views under States for now. They should be useful somehow but not for our purpose this time.
    So under Switches we need to create a Switch Group called "Game_Location" (and I believe now we need to specific because these are what the game is trying to pull) and under the switch group we create switches of "Ancient_Era", "Medieval_Era", etc.


    Click on your "Game_Location" switch group:
    Spoiler Switch Group :

    upload_2017-8-29_19-7-37.png
    You need to check "Use Game Parameter" and select "Game_Location" down there. Since in the example we have 4 eras, equally distribute them onto X axis by double clicking to create nodes and dragging node to locations.


    Then we are done in Game Syncs and go back to Audio and click on switch container again.
    Spoiler Switch Container :

    upload_2017-8-29_19-11-5.png
    Keep the switch container selected, go back to game syncs and drag the "Game_Location" switch group into Switch Container Association Editor.
    Then click on each switch and Add Path:
    upload_2017-8-29_19-13-18.png
    You will then see your switch show up in the panel down and click select the playlist that plays your era theme music. Do it for all the rest of your era switches.
    Go back up to Music Switch Container Properties and select Transitions tab:
    upload_2017-8-29_19-18-28.png
    Select the transition, switch Exit Source at to "Immediate", and you can go ahead and set some fade-out.
    Switch Sync To to "Entry Cue" and again go ahead and set some fade-in.

    Now you can try play your Switch Container and drag the RTPCs slider to see if the music switch to your respective era theme.

    Next you need to create some events. I will post in reply.
     
  2. FurionHuang

    FurionHuang Chieftain

    Joined:
    Apr 27, 2017
    Messages:
    136
    Gender:
    Male
    Now is events:
    Spoiler Events :

    upload_2017-8-29_19-23-55.png
    You need these events with STRICT format. Prefixes and YOUR CIVILIZATION NAME, NOT your leader name.
    For Play_Leader_Music, Play_Music, Start_Music events, we use play action:
    upload_2017-8-29_19-25-46.png
    Similarly Pause uses pause action, resume uses resume action and stop uses stop action.


    Finally we go to Soundbanks and create a Soundbank named as you wish.
    Under Layouts switch to SoundBank and select your sound bank.
    Spoiler Sound Bank :

    Go back to Events tab and drag all your events into sound bank editor.
    upload_2017-8-29_19-29-10.png
    Also go to Game Syncs tab under sound bank editor and check if your switches are there. If not, drag them in.
    upload_2017-8-29_19-30-8.png


    Finally, go up to Soundbank Manager, check your sound bank, Windows, English and generate:
    upload_2017-8-29_19-31-30.png
    You will find the generated bnk, wem, txt, xml files in your Wwise GeneratedSoundBanks folder.

    Copy them to your Mod project audio folder (discard anything with "Init", paste all the rest), and add an ini file with following text:
    Code:
    ;
    ; Civilization 6 Banks.ini for YOUR MOD
    ;
    ; Sections are defined like so:
    ; Global = banks always resident
    ; Menu = banks loaded only during main menu
    ; InGame = banks loaded during gameplay, either 2D or 3D mode
    ; 2D = banks loaded only during 2D mode gameplay
    ; 3D = banks loaded only during 3D mode gameplay
    ; FMV = banks loaded only during the intro (and outro?) FMV
    ;
    
    [Global]
    
    [Menu]
    
    [InGame]
    Your_Music_Bank.bnk
    
    [2D]
    
    
    [3D]
    
    [FMV]
    
    
    Include all the files but wem files into your InGame-UpdateAudio using modbuddy, or modinfo file you all know how to do this.
    Build, start game, and upon founding the first city, you will hear your music!

    Hope this is helpful. Happy modding!
     
  3. sukritact

    sukritact Artist and Modder

    Joined:
    Sep 21, 2010
    Messages:
    2,785
    Location:
    Bangkok
    Does this actually work? I'm fairly certain you need to add a custom cue, not just use the exit cue.
     
  4. FurionHuang

    FurionHuang Chieftain

    Joined:
    Apr 27, 2017
    Messages:
    136
    Gender:
    Male
    It worked switching between musics when entering AI diplo screen or advancing into new era. Though the game was just looping same music again and again on the map. IDK if it was because of the cue wasn't set right or it's the playModMusic function that actually excludes official music?
     
  5. sukritact

    sukritact Artist and Modder

    Joined:
    Sep 21, 2010
    Messages:
    2,785
    Location:
    Bangkok
    Oh, I see what's going on. You DO need to add a custom cue (which is why no official music with your mod). The reason your music keeps playing at all is because your playlist is set to continuous instead of step.
     
    Last edited: Aug 30, 2017
  6. FurionHuang

    FurionHuang Chieftain

    Joined:
    Apr 27, 2017
    Messages:
    136
    Gender:
    Male
    I see, I did set something "infinite" somewhere, let me go back and check. For the custom cue, is there any specific name needed?
    I also found if during the game I exit to main menu, the music will keep playing. Might also be the cue issue?
     
  7. FurionHuang

    FurionHuang Chieftain

    Joined:
    Apr 27, 2017
    Messages:
    136
    Gender:
    Male
    The custom cue actually made little difference, and I figured the reason for looping only one song is because I had only one song in the playlist as the switch set the certain era and for mod music the game is using play_music_{Mod_civ} event which is different than original game music events.
    And I also looked at Wwise DLC bank tutorial and there's a bummer line saying "All DLC content must be created using the same Wwise Project that was used for the main release. Additionally, the same Wwise version must be used for both releases to ensure compatibility of the SoundBank and package formats." So even if we magically figured out the work unit/container structure of the audios, we are unable to merge our music into original game music unless Firaxis shares their Wwise project which won't be possible by any chance...
    I also found the in game play mod music events are not totally functional especially the stop music events. I had to write some lua script to stop mod music on exiting to main menu, on entering victory/defeat view, on loading saved game, and (didn't figure out how yet) on restarting game. Sucks...
     
  8. lasttry

    lasttry Chieftain

    Joined:
    Apr 26, 2014
    Messages:
    180
    Gender:
    Male
    Location:
    Berlin
    Hey thanks for the Tutorial, will Need it cause I want to add music to my wonder mods :) and perhaps for new civs too, thank you :)
     
  9. FurionHuang

    FurionHuang Chieftain

    Joined:
    Apr 27, 2017
    Messages:
    136
    Gender:
    Male
    Just note that this method still has some issue because I can't figure out/or maybe it's impossible to blend mod music into original music playlist. And either I did it wrong or Firaxis didn't provide a good mod music functionality, we have to provide our own stop-the-mod-music-on various events script.
    Code:
    function OnUIExitGame()
        UI.PlaySound("Stop_Music_modCiv");
    end
    
    function OnPlayerDefeatStopMusic( player, defeat, eventID)
        print("Defeat Event Activated.");
        UI.PlaySound("Stop_Music_modCiv");
    end
    
    function OnTeamVictoryStopMusic(team, victory, eventID)
        print("Victory Event Activated.");
        UI.PlaySound("Stop_Music_modCiv");
    end
    
    function OnLoadScreenClose()
        if (localPlayer is modCiv<pseudo code here, whatever function you use to determine if the local player is playing modCiv>)
            UI.PlaySound("Play_Music_modCiv");
        end
    end
    
    function OnLoadGame()
        Events.LoadScreenClose.Add(OnLoadScreenClose);
    end
    ----------Events----------
    Events.LeaveGameComplete.Add(OnUIExitGame);
    Events.PlayerDefeat.Add(OnPlayerDefeatStopMusic);
    Events.TeamVictory.Add(OnTeamVictoryStopMusic);
    Events.LoadComplete.Add(OnLoadGame);
    Still, I can't find a restart game event for now. Restarting game won't stop playing mod music. Need to figure out how.
     
  10. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    7,117
    Location:
    France
    Events.LeaveGameComplete doesn't fire on restart ? That's an issue, I use it to clean some stuff :/
     
  11. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    7,117
    Location:
    France
    Yep, confirmed, here are the events (that I know) that are called on restart
    Code:
    GameCore_Tuner: -- Events.BeforeGameplayContentConfigure
    GameCore_Tuner: ---------------------------------------------------------------------------------- Start <
    GameCore_Tuner: num arguments = 0
    GameCore_Tuner:
    GameCore_Tuner: ------------------------------------------------------------------------------------ End >
    GameCore_Tuner:
    GameCore_Tuner: -- Events.AfterGameplayContentConfigure
    GameCore_Tuner: ---------------------------------------------------------------------------------- Start <
    GameCore_Tuner: num arguments = 1
    GameCore_Tuner: table: 0000000022900130
    GameCore_Tuner: --------------- table: 0000000022900130 ---------------
    GameCore_Tuner:     Success    true
    GameCore_Tuner:     ConfigurationChanged    true
    GameCore_Tuner:     ResortedToBaseConfiguration    false
    GameCore_Tuner:     DownloadingAdditionalContent    false
    GameCore_Tuner:     ErrorCode    0
    GameCore_Tuner:
    GameCore_Tuner: ------------------------------------------------------------------------------------ End >
    GameCore_Tuner:
    GameCore_Tuner: -- Events.BeforeGameplayContentChange
    GameCore_Tuner: ---------------------------------------------------------------------------------- Start <
    GameCore_Tuner: num arguments = 0
    GameCore_Tuner:
    GameCore_Tuner: ------------------------------------------------------------------------------------ End >
    GameCore_Tuner: 

    edit:
    Moderator Action: and moved to the tutorial sections
     
  12. FurionHuang

    FurionHuang Chieftain

    Joined:
    Apr 27, 2017
    Messages:
    136
    Gender:
    Male
    No it doesn't.
     
  13. lasttry

    lasttry Chieftain

    Joined:
    Apr 26, 2014
    Messages:
    180
    Gender:
    Male
    Location:
    Berlin
    EDIT : know how to end the Music now, only one Problem is left...how can i tell the game that the vanilla game Music have to stop when my track Plays, and start again when my track stops ?
    by now my track AND the vanilla game Music both playing...
     
    Last edited: Sep 10, 2017
  14. esosorcdc

    esosorcdc Chieftain

    Joined:
    Aug 3, 2017
    Messages:
    90
    Gender:
    Male
    Yea, I want to add music to in my new civ mod to, so this is helpful. But what about other audio, like when the leader talks? Do I use this same program?
     
  15. sukritact

    sukritact Artist and Modder

    Joined:
    Sep 21, 2010
    Messages:
    2,785
    Location:
    Bangkok
    You use wwise for ALL sounds.
     
  16. FurionHuang

    FurionHuang Chieftain

    Joined:
    Apr 27, 2017
    Messages:
    136
    Gender:
    Male
    Yes to sukritact you use Wwise for all sounds. For leader talk or ambient sound or unit response/action sound effects, you need to create sound tracks under actor-mixer hierarchy with similar technique of creating events and switch/playlist containers. Though I'm not sure what kind of switch they need. Sukritact will be the better person to answer that.
     
  17. esosorcdc

    esosorcdc Chieftain

    Joined:
    Aug 3, 2017
    Messages:
    90
    Gender:
    Male
    Thanks, I will start messing around with this program and post my questions on this thread.
     
  18. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    7,117
    Location:
    France
    Surely not the simplest solution, but seems to work:

    .modinfo
    Code:
            <AddUserInterfaces>
                <Properties>
                    <Context>InGame</Context>
                </Properties>
                    <File>InGame/GCO_ModInGame.xml</File>
            </AddUserInterfaces>
    GCO_ModInGame.xml
    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <Context Name="GCO_ModInGame">
        <Include File="PopupDialog"/>
        <MakeInstance Name="PopupDialog" />
    </Context>
    GCO_ModInGame.lua
    Code:
    
    -----------------------------------------------------------------------------------------
    -- Override the restart button
    -----------------------------------------------------------------------------------------
    include( "PopupDialog" )
    
    local m_kPopupDialog
    
    function OnReallyRestart()
        -- Start a fresh game using the existing game configuration.
        LuaEvents.RestartGame() -- add the function(s) you want to call before restarting a game to this lua event : LuaEvents.RestartGame.Add(myFunction)
        Network.RestartGame()
    end
    
    function OnRestartGame()
        ContextPtr:LookUpControl("/InGame/TopOptionsMenu/"):SetHide(true)
        if (not m_kPopupDialog:IsOpen()) then
            m_kPopupDialog:AddText(      Locale.Lookup("LOC_GAME_MENU_RESTART_WARNING"))
            m_kPopupDialog:AddButton( Locale.Lookup("LOC_COMMON_DIALOG_NO_BUTTON_CAPTION"), OnNo )
            m_kPopupDialog:AddButton( Locale.Lookup("LOC_COMMON_DIALOG_YES_BUTTON_CAPTION"), OnReallyRestart, nil, nil, "PopupButtonInstanceRed" )
            m_kPopupDialog:Open()
        end
    end
    
    function OnNo()
        ContextPtr:LookUpControl("/InGame/TopOptionsMenu/"):SetHide(false)
    end
    
    function Initialize()
        m_kPopupDialog = PopupDialog:new( "ModInGame" )
    end
    
    function OnEnterGame()   -- override the default callback once all the files are loaded...
        ContextPtr:LookUpControl("/InGame/TopOptionsMenu/RestartButton"):RegisterCallback( Mouse.eLClick, OnRestartGame )   
    end
    Events.LoadScreenClose.Add(OnEnterGame)
    
    Initialize()
     
  19. Aldollin

    Aldollin Chieftain

    Joined:
    Mar 7, 2017
    Messages:
    85
    Gender:
    Male
    so i think i did everything the way it is described here, including adding the scripts from Gedemon and FurionHuang that fix stuff, but there are still situations in which the music breaks or multiple tracks play at the same time
    2 different situations:

    -music works liek it should, i go to my leader screen (leader icon in the top right corner) music start from the beginning (i assume the regular one gets paused and the Leader_Music starts), same happens if i go to diplomacy screens of other civs
    but when i return to the map the music does not resume (at least not always, sometimes it still works)

    -when restarting the game the music from the first game keeps playing, so after settling the first city in the restarted game the track is playing 2 times

    any idea what i could have done wrong or how to fix this?
    one thing in this tutorial i dont get is the "costum cue" thing, how do i add a costum cue, what do i have to do etc.... (only using exit cue so far)
     
  20. FurionHuang

    FurionHuang Chieftain

    Joined:
    Apr 27, 2017
    Messages:
    136
    Gender:
    Male
    To the first question, I remember entering leader scene and exiting with the music pause/resume fine. You might want to make sure in your Wwise project the resume event sets correctly.
    To the second question, I guess that means Gedemon's script doesn't totally solve the restarting issue yet. I'm stuck here not knowing a good solution to that:crazyeye:.
     

Share This Page