Jump to content

Easy way to add music


Garjouan

Recommended Posts

Hey all,

I was wondering of there was an easy way to add music (locally) to my game.

I know you can use modding to do that. But in the good old times (tm) you could just add files into the game's music folder and they would play.

Anyone tried that? Would that work, too?

Link to comment
Share on other sites

Haven't tried yet, but read someone switched the temporal rift audio 'cuz it was so annoying continously. So the possibility is there to change sounds, including music.

Looked at the folder architecture and by the looks of it, it's a bit more complicated than single drag'n'drop.

Here is the path "[...]\Vintagestory\assets\survival\music" Reading musicconfig.json, just adding other music to this folder won't work, as the tracks have parameters on what time of the day they can trigger. I can't help with editing the config, no programmer, just enthusiast barely learning to read and tweak minor stuff for personal use.

However it looks like we can replace the music. Convert the music you want to .ogg, and rename exactly to a pre-existing OST there, paste to overwright the original. And that should switch your personal music with the game's OST.

Link to comment
Share on other sites

16 hours ago, Garjouan said:

I want to add music

Kazeoni was pointing into the correct direction. "Vintagestory\assets\survival\music" is the place to be. All you need to do, is to copy the desired music tracks (in the ogg format - I suggest foobar2000 for file convertion) into the music folder, and add those files to "musicconfig.json".

There you just need to copy and paste the existing definition(s), and edit them, so that the game knows that your music tracks exist and can be played.

The game supports sub-folders in the parent directory. I suggest making use of this, so that the music folder does not become too cluttered.

Here is an example. Let's say that I want to add two tracks by C418 from two of his albums to the game. As preperation we

  1. opened "Vintagestory\assets\survival\music"
  2. created one sub folder named "c418" within the folder "music"
  3. created one sub folder named "alpha" within the folder "c418"
  4. copied "01 - Key.ogg" into the "alpha" sub folder, and "01-ki.ogg" into the "c418" folder
Spoiler

Folder and file structure

music
├musicconfig.cfg
├daylight.ogg
└c418
  ├01-ki.ogg
  └alpha
   └01 - Key.ogg

 

Now we open "musicconfig.json" (I suggest using a text and code editor like Notepad++ or Sublime).

Spoiler

Existing Definition:

{
 properties: {
  mindelay: 4,
  maxdelay: 8
},
 tracks: [
  {
   "$type": "Vintagestory.API.Client.SurfaceMusicTrack, VintagestoryAPI",
   file: "daylight", 
   name: "Daylight",
   onPlayList: "survival|creative",
   minhour: 8,
   maxhour: 12,
  }
 ]
}

Explanation:

file = File name without file extension (musictrack1.ogg becomes musictrack1 for example).

name = Name of music track that is shown when the client command ".music" is executed in-game.

minhour = Time of in-game day the music track can start being played by the game.

maxhour = Time of in-game day the music track stops being played by the game.

Spoiler

We copy and paste it.

{
 properties: {
  mindelay: 4,
  maxdelay: 8
},
 tracks: [
  {
   "$type": "Vintagestory.API.Client.SurfaceMusicTrack, VintagestoryAPI",
   file: "daylight", 
   name: "Daylight",
   onPlayList: "survival|creative",
   minhour: 8,
   maxhour: 12,
  },
  {
   "$type": "Vintagestory.API.Client.SurfaceMusicTrack, VintagestoryAPI",
   file: "daylight", 
   name: "Daylight",
   onPlayList: "survival|creative",
   minhour: 8,
   maxhour: 12,
  },
  {
   "$type": "Vintagestory.API.Client.SurfaceMusicTrack, VintagestoryAPI",
   file: "daylight", 
   name: "Daylight",
   onPlayList: "survival|creative",
   minhour: 8,
   maxhour: 12,
  }
 ]
}

Note: Definitions are separated by a comma after the closing curly bracket of the definition. The last definition in the file does not feature said comma.

Spoiler

Now we edit the definitions we just copied.

{
 properties: {
  mindelay: 4,
  maxdelay: 8
},
 tracks: [
  {
   "$type": "Vintagestory.API.Client.SurfaceMusicTrack, VintagestoryAPI",
   file: "daylight", 
   name: "Daylight",
   onPlayList: "survival|creative",
   minhour: 8,
   maxhour: 12,
  },
  {
   "$type": "Vintagestory.API.Client.SurfaceMusicTrack, VintagestoryAPI",
   file: "c418/alpha/01 - Key", 
   name: "Key",
   onPlayList: "survival|creative",
   minhour: 9,
   maxhour: 11,
  },
  {
   "$type": "Vintagestory.API.Client.SurfaceMusicTrack, VintagestoryAPI",
   file: "c418/01-ki", 
   name: "This is called Ki but I prefer to pronounce it Key",
   onPlayList: "survival|creative",
   minhour: 15,
   maxhour: 16,
  }
 ]
}

We edit minhour and maxhour to our liking. Theoretically you can have the game play the music from hour 0 to hour 24. Depending on how much music you add to the game, this would lead to repetition really fast.

Note: The file name contains the folder the music files are saved in.

Now you save the file. That was basically it. With this knowledge you should be able to add as much music as you want.

I suggest making a copy of the file, so that you don't lose all your hard work after a game update.

Edited by Brady_The
Corrected "File and Folder structure" to reflect the example structure.
  • Like 3
  • Mind=blown 1
Link to comment
Share on other sites

@Garjouan After you have finished editing your file, I recommend running it through a JSON validator. This will ensure that you don't make any syntax errors, which could potentially crash VS on startup. JSON has some very particular rules about where exactly you must place commas and where they must not be placed under any circumstance.

Just open your file, do CTRL+A to select everything, CTRL+C to copy, and then on the website, CTRL+V to paste.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

So, finally took a look into that whole thing.
I noticed there are several other variables in the .json file.

Some are self explanatory, some not so much. e.g. what does minSeason/maxSeason specify, and what are the value ranges? (seems to be 0-1, but I am not sure what they signify).

Since I'd like to have my music to be played basically to all times of the days, to all seasons etc. for the start.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.