Sound

From wiki
Jump to: navigation, search

In Staxel, *.sound files are collections of sounds that the game will use depending on it's condition. These files include everything from UI sounds, to the sounds while stepping on blocks to the ambience and music.

There can be three type of music files used with Staxel.

  • *.wav - Used for all sound effects. This includes tools, UI etc.
  • *.wav.csr - Used to compress *.wav files on disc. The game will decompress them on load.
  • *.ogg - Used purely for ambience and music.

As a note, these files will not play by themselves, some other component, such as a tile, needs to play these sounds.


Adding New Sounds To Staxel

Staxel also allows you to add new sounds to staxel. The process for doing so is actually quite simple and as long as you know how to get the sounds, the rest shall follow easily.

Before beginning make sure to follow #Setting up for Mod Creation. There are however two things that you will probably need before getting started however.

First, you need to have an object already made so that you can test the sound. Follow #Creating a In-game object to create one. Anything will do.

Second, you need to have some sound files already made. As a note, the game only allows *.wav files to be played as sounds. If your sounds are not in this format then you can use Audacity and export them to *.wav files.

Once this is done, move the object and the sound files to a new mod folder. Then create a file with an ending of .sound, and place the following into it.

{
  "code" : "mods.modname.modsoundname",
  "sounds" : [
    {
      "file" : "mods/modname/modsoundname1",
      "volume" : 0.4
    },
    {
      "file" : "mods/modname/modsoundname2",
      "volume" : 0.4
    }
  ]
}

You can replace the temporary names with whatever will work for your mod. Do not add .wav to the end of the file. The game automatically adds this. Now in this example it shows 2 sound files added. You can add any number of sounds from 1 to some large number, and the game will just randomly select a sound from the list. If you only have one sound, then remove the content between the { } and remove the preceding comma.

Congrats you have created your sound. Now to get an object to play it, add the following line to the object's *.tile file.

"stepSoundGroup" : "mods.modname.modsoundname"

Once this line is added in, head to gamedata/bin/ and start up Staxel.ContentBuilder.exe. When this has started up, click Validate Resources and wait until the progress bar has done. Now you can load up and hear your sound whenever you walk over your object.


Compressing Sounds

Staxel also has the option to compress these files to save space but not lose quality. These files will be played back the same as any normal *.wav file, but will take up much less space than even a zipped file.

Before doing this, you will want to make sure you have a backup of the sound file, as it will be overwritten.

You can compress your file by simply heading to gamedata/bin/ and start up Staxel.ContentBuilder.exe. When this has started up, click Compress .wav assests, wait a moment and then click Validate Resources and wait until the progress bar has done. Now all the sound assests you added are compressed and will still run in staxel.


Useful components

Sounds do not have many useful components. Sounds don't have many components as they are not specifically used by the game but they do have a single component which is used specifically for sounds.

Ambience Component

This component is used to specify sounds for playing as ambience. In game this is specifically used to play the bird sounds you hear throughout the day.

For more information on how to use the ambience component, head to Ambience Component#When and How to use.


Config Options

"code"

Valid options (String): A unique string which sound what this object is.

Default Value: No default value is specified. Always need to provide your own.


This option is required to uniquely identify any object or resource. This path must be unique to all other codes, but does not have any other requirements.

For example: Having the code "mods.testsound.soundgroup1" creates an object that has the handle "mods.testsound.soundgroup1"


"sounds"

Sounds is a list of smaller JSON/Blob files which contain information on files. It is written as:

{
  "sounds" : [
    {
      //Stuff here
    },
    {
      //Stuff here
    }
  ]
}

Each set contains the values below.


"emitterCode"

Valid options (String): The kind of sound emitter to use.

Default Value: If not specified, will default to "staxel.audioEmitter.Default".

This is the type of emitter you want to use for this Sound. Different Audio Emitters have different properties. The current emitters in the game are;

  • "staxel.audioEmitter.Default": The normal sound emitter.
  • "staxel.audioEmitter.Fireworks": The emitter used for fireworks. Has longer range than the default emitter.
  • "staxel.audioEmitter.ClockTowerChime": Same as the fireworks emitter, but for the Clock.


"file"

Valid options (String): A string which contains the path to an audio file. Do not include ".wav", ".ogg" or ".wav.csr".

Default Value: No default value is specified. Always need to provide your own.


This option points to the audio file. It is however missing the extension on purpose as the game will add the extension while playing the sound.

For example: Having the file name "mods/testsound/sound1" look for an object that is either "mods/testsound/sound1.wav", "mods/testsound/sound1.ogg" or "mods/testsound/sound1.wav.csr" depending on context.


"randomPitch"

Valid options (Vector 2 - Float): {"x":-1.0, "y":1.0}

Default Value: If not specified, then pitch will not vary.

This option tells the game exactly to play the sound at a random pitch between two points, x (min) and y (max).


"randomVolume"

Valid options (Vector 2 - Float): {"x":0.0, "y":1.0}

Default Value: If this is specified, "volume" cannot be used. Only one of the two can, and must, be specified.

This option tells the game exactly to play the sound at a random volume between two points, x (min) and y (max).


"volume"

Valid options (Float): A value between 0.0 and 1.0.

Default Value: If "randomVolume" is specified, this cannot be used. Only one of the two can, and must, be specified.


This option tells the game exactly how loud to play the sound.