Custom Music

From Stardew Modding Wiki
Jump to navigation Jump to search

Custom Music (mod)

Replacing native music and sounds

Custom Music can target native music and sound IDs to replace them with a custom audio file. Debug Mode mod https://www.nexusmods.com/stardewvalley/mods/679 can be used to check the currently playing music ID. The Stardew Valley Event Modding Resource https://docs.google.com/spreadsheets/d/1CpDrw23peQiq-C7F2FjYOMePaYe0Rc9BwQsj3h6sjyo contains the majority of music and sound IDs the game uses, but is incomplete.

Content pack structure

Custom Music content packs follow the standard content pack structure https://stardewvalleywiki.com/Modding:Content_packs#Create_a_content_pack, consisting of a folder with a manifest.json and content.json files, and any additional files (such as audio files) that the content pack needs. See the mod description and the CM Content Pack Template download on nexus for examples https://www.nexusmods.com/stardewvalley/mods/3043/?tab=description.

Audio file formats

Custom Music accepts WAV and OGG. OGG is converted to WAV before use by Custom Music and won't reduce memory usage.

Options

Preload: true/false

Governs whether the audio file is loaded into memory during game start, before it is played in-game. When set to true, the audio file will always be stored in memory, when to false, it is only stored in memory after it has been played once. Setting this option to false reduces memory usage, as long as the track hasn't been played during the game session.

Loop: true/false

Whether the track should loop or not.

Other options exist.

Conditions

Custom Music can replace/add audio conditionally, which allows the modder to replace one music ID with multiple tracks (for example with a random chance). The Conditions field accepts event preconditions https://stardewvalleywiki.com/Modding:Event_data#Event_preconditions (all of them?). More complex conditions are possible, but documentation is lacking.

Examples

The following is a complete content.json for a Custom Music content pack. Paste it to https://smapi.io/json for better viewing.

{
  "Music": [
    // * replace the native sound ID thudStep with a WAV file called thudstep_improved.wav,
    //   when the day is NOT friday or monday. 
    // * the file is preloaded because it is small and won't consume much memory, and 
    //   because it's likely to be used by the game in almost every session.
    // * the track isn't set to loop.
    {
      "Id": "thudStep",
      "File": "thudstep_improved.wav",
      "Preload": true,
      "Loop": false,
      "Conditions": "d Fri Mon"
    },


    // * replace the native music ID springtown with an OGG file called summer_town.ogg,
    //   when the season is NOT spring, fall, or winter, with a 50% chance(?).
    // * the track is not preloaded to avoid it unnecessarily consuming memory. it will create
    //   a smaller or bigger delay when the game loads the track, and with an OGG file the delay
    //   is longer than with a WAV file (unless Custom Music is set to preconvert the files to WAV?).
    //   it could be better to use a WAV file instead, at the cost of significantly increased file size.
    // * the track is set to loop.
    {
      "Id": "springtown",
      "File": "summer_town.ogg",
      "Preload": false,
      "Loop": true,
      "Conditions": "z spring/z fall/z winter/r 0.5"
    },    


    // * ADDING A MUSIC ID TO A CUSTOM LOCATION
    //
    // * CAVEATS
    //   music IDs added to a location often don't stop playing when you exit the location,
    //   so it can be better to not loop them (or use them unnecessarily at all)
    //
    // * target a music ID added to a custom location. the ID can be manipulated as if it were a native music ID.
    //   this example uses the Custom_ForestWest location added by SVE, and the music ID is called ForestWest.
    // * the file isn't preloaded to avoid unnecessary memory consumption.
    // * the file isn't set to loop (see CAVEATS above)
    {
      "Id": "ForestWest",
      "File": "sve_forestwest.wav",
      "Preload": false,
      "Loop": false
    }
  ],
  // add the music ID to the location
  "Locations": [
    {
      // the internal name of the location (use Debug Mode mod to find it)
      "Location": "Custom_ForestWest",
      // the music ID you want the location to have
      "MusicId": "cm:ForestWest"
    }
  ]
}