[Tutorial] Custom Ambient Music Serverside

Discussion in 'Tutorials' started by Vampire, Nov 15, 2013.

  1. Vampire

    Vampire OpenDayZ Rockstar!

    Joined:
    Oct 22, 2013
    Messages:
    923
    Likes Received:
    136
    So, can we all agree that the normal ambient music in dayz sucks? All of these tracks here?

    The first time you hear that screeching grinding metal noise in game, you almost crap yourself, and then go into the settings to turn music off. Most people never turn it back on afterwards for any reason. This makes adding things like server intro music pointless if no one will be able to hear it without first turning their music back up.​
    So how can we start to make this better? I want to try to get as many servers as possible to start disabling rocket's ambient music so we can actually start playing with our music turned up.​
    To do this, you make a custom compiles (copied from your client) and simply comment out this line after adding it to your mission.pbo by putting a double slash in front of it.​
    Code:
    player_music =                compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_music.sqf";
    But why should we stop there when we can add our own custom ambient music! No more smothering the map in triggers to add your own custom ambient sounds, just have them play dynamically for everyone!​
    Instead of commenting out that line, include a custom player_music.sqf in your mission file.​
    Use the script below. I've made it really simple.​
    Code:
    private ["_sound","_length","_pause","_enableAmbient","_minWaitTime","_maxWaitTime","_musicArray","_waitTimeDifference","_randomWait"];
    /////////////////////////////////////////////
    //// Vampire's Better Ambient Music v1 //////
    /////////////////////////////////////////////
     
    // Enable Ambient music? true/false
    _enableAmbient = true;
     
    while {!r_player_dead && _enableAmbient} do {
            // Minimum amount of time before running the next track (in seconds)
            // Default for my script is 10 minutes. (600 seconds)
            // Must be less than the maximum wait time.
            _minWaitTime = 600;
     
            // Maximum amount of time before running the next track (in seconds)
            // Default for my script is 30 minutes. (1800 seconds)
            // Must be more than the maximum wait time.
            _maxWaitTime = 1800;
     
            // The array of your ambient tracks. These must match the class of a
            // cfgMusic entry either in the default DayZ cfgMusic or Description.ext
            // In your Mission.pbo. (Example: class bombs)
            // It will choose a random track from this array.
            _musicArray = ["alarm", "bombs", "gunfire","wind"];
            
            // Pick a sound
            _sound = _musicArray select floor random count _musicArray;
       
            // Get it's length from the cfgMusic/Description.ext
            _length = getNumber(configFile >> "cfgMusic" >> _sound >> "Duration");
       
            // Lets figure out the random wait time
            _waitTimeDifference = ((_maxWaitTime) - (_minWaitTime));
            _randomWait = (random (_waitTimeDifference));
            _pause = (_randomWait) + (_length);
       
            // Play the song
            if (!r_player_unconscious and !r_pitchWhine) then {
                playMusic _sound;
            };
       
            // Let the script sleep the song length and the random amount of time
            sleep _pause;
    };
    Then you need to define your new tracks in your description.ext like this.
    Code:
    class CfgMusic
    {
        tracks[]={bombs,etc};
        class bombs
        {
            name = "bombs";
            sound[] = {"Ambience\bombs.ogg", db+0, 1.0};
            duration = 13;
        };
        class etc
        {
            name = "etc";
            sound[] = {"Ambience\etc.ogg", db+0, 1.0};
            duration = 5;
        };
    };
    You need to put the class names in the player_music.sqf music array.
    The sound files also have to be .ogg files like any arma 2 sounds.
    The duration is the length of the track in seconds. This needs to be correct.
    For neatness I put all of my tracks in a folder in the mission.pbo called "Ambience", but you can put them where you like.
    The length and size of your ambient tracks are only limited by how big you want to make your mission file, but the size grows fast.

    Hopefully we can get some servers going that have some awesome custom ambient music instead of the default and actually give our music sliders some use!

    I've added 4 ambient tracks to my server, so if you want to see these in action, turn your music slider up, and play around on my Epoch server for a little while.
     
  2. kaysio

    kaysio Valued Member!

    Joined:
    Feb 15, 2013
    Messages:
    256
    Likes Received:
    97
    graeme bourne and Vampire like this.
  3. graeme bourne

    graeme bourne Member

    Joined:
    Jan 14, 2013
    Messages:
    96
    Likes Received:
    9
    I like it actually mate, though the one problem I'm having is an conversion to ogg files.. I'm guessing my search-fu is off today.. only a couple of hours sleep will do that,, serves me right

    Bags
     
  4. Hertizch

    Hertizch Well-Known Member

    Joined:
    Jun 22, 2013
    Messages:
    143
    Likes Received:
    13
  5. Vampire

    Vampire OpenDayZ Rockstar!

    Joined:
    Oct 22, 2013
    Messages:
    923
    Likes Received:
    136
  6. Vampire

    Vampire OpenDayZ Rockstar!

    Joined:
    Oct 22, 2013
    Messages:
    923
    Likes Received:
    136
  7. kaysio

    kaysio Valued Member!

    Joined:
    Feb 15, 2013
    Messages:
    256
    Likes Received:
    97
    I presume you could put the class CfgMusic into a .hpp file and call it from the description.ext
     
  8. kaysio

    kaysio Valued Member!

    Joined:
    Feb 15, 2013
    Messages:
    256
    Likes Received:
    97
    OK so where Im I going wrong with this ?

    Compiles = player_music = "custom\Ambient\player_music.sqf";

    custom > Ambient folder

    Contains my ogg tracks.

    player_music.sqf = http://pastebin.com/3rSEc6vP

    In my description.ext at the bottom Ive got it calling : #include "custom\Ambient\music.hpp"

    music.hpp = http://pastebin.com/GSZug6uE
     
  9. Vampire

    Vampire OpenDayZ Rockstar!

    Joined:
    Oct 22, 2013
    Messages:
    923
    Likes Received:
    136
    It looks good to me. Was my script working before you put it in an hpp file?
     
    kaysio likes this.
  10. kaysio

    kaysio Valued Member!

    Joined:
    Feb 15, 2013
    Messages:
    256
    Likes Received:
    97

    nope, does matter what way I put it.
    just cant get it to work.

    just gives me an excuse to rip some code apart :D
    Its more likely Ive got a clash of code somewhere.
     
  11. Vampire

    Vampire OpenDayZ Rockstar!

    Joined:
    Oct 22, 2013
    Messages:
    923
    Likes Received:
    136
    Well I havn't actually ran the script I posted, I just threw it together...

    I have a more botched together version on my server atm.
    I'll use the script I posted and see if its working.
     
    Zeehond23 likes this.
  12. Vampire

    Vampire OpenDayZ Rockstar!

    Joined:
    Oct 22, 2013
    Messages:
    923
    Likes Received:
    136
    Modified the original script I posted and I can confirm it's working.
     
  13. Vampire

    Vampire OpenDayZ Rockstar!

    Joined:
    Oct 22, 2013
    Messages:
    923
    Likes Received:
    136
    Only issue now is that JIPs aren't on the same music loop as other players.

    If someone who knows what they are doing can modify it to send PublicVariables, that would be great.
     
  14. kaysio

    kaysio Valued Member!

    Joined:
    Feb 15, 2013
    Messages:
    256
    Likes Received:
    97
    can confirm the .hpp way works aswell.
    instead of messing with your description.ext.

    you can add at he bottom : #include "custom\Ambience\music.hpp"

    Then you can call the tracks from the music.hpp

     
  15. kaysio

    kaysio Valued Member!

    Joined:
    Feb 15, 2013
    Messages:
    256
    Likes Received:
    97
    Just thinking out load here,

    is is possible to stream music from various sources ???

    for example have a radio list on the mouse scroll, then select.
    [not at home so cant test the theory out.]
     
  16. Vampire

    Vampire OpenDayZ Rockstar!

    Joined:
    Oct 22, 2013
    Messages:
    923
    Likes Received:
    136
    I havn't tested if you can play a music file that is an Ogg Vorbis stream.
    It should in theory work, but haven't tested like I said.
     
  17. Vampire

    Vampire OpenDayZ Rockstar!

    Joined:
    Oct 22, 2013
    Messages:
    923
    Likes Received:
    136
    The only issue I have for Epoch is that the safe login GUI is LOUD beeping noises.

    Unfortunately the safegui is pointed to from the config.cpp and so is the sounds, so there's not a fix for it unless they call the GUI from a different location in a future version.

    If someone wants to post on dayzepoch recommending they remove them that would be great.
     
  18. shiz

    shiz New Member

    Joined:
    Feb 13, 2014
    Messages:
    5
    Likes Received:
    0
    cool!
     
  19. VadiEx

    VadiEx New Member

    Joined:
    Apr 26, 2014
    Messages:
    1
    Likes Received:
    0
    Hi, i do all, what you write, but Im not hear dayz and my ambients, in Namalsk, ambients have 4-6 mb, i use namalsk and my track, but no hear in game, what's wrong?
    i try make it on Dayz Epoch
     

Share This Page