Table of Contents

Struct SoundAttributes

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll

Properties that control how a sound is played. There are two forms of this that might be used in JSON files: Form 1 is simply stored as an AssetLocation that points to the sound file path. There are no extra proprties. This is what most JSON objects use. Form 2 is more complex, and uses the properties below to fully configure the sound. Only certain JSON objects use this, such as entity sounds. You can mix and match in a single sound array.

[DocumentAsJson]
public struct SoundAttributes

Examples

Form 1:

"sounds": {
"place": "block/plant",
"break": "block/plant",
"hit": "block/plant"
},
Form 2. Note that entity sounds can include * at the end for multiple sound files:
"sounds": {
"hurt": "creature/chicken/chick*",
"death": "creature/chicken/chick*",
"idle": {
"path": "creature/chicken/chick*",
"range": 14,
"pitch": {
"avg": 1,
"var": 0.25
}
}
},

Fields

path (Required)

The location of the sound file.

[DocumentAsJson("Required", "", false)]
[JsonProperty("path")]
public AssetLocation? Location

Field Value

AssetLocation

Pitch (Optional) (Default: 1)

Controls a random pitch for when the sound is played.

[DocumentAsJson("Optional", "1", false)]
public NatFloat Pitch

Field Value

NatFloat

Range (Optional) (Default: 32)

The range at which the gain will be attenuated to 1% of the supplied volume. (i.e. the maximum range that the player will hear the sound)

[DocumentAsJson("Optional", "32", false)]
public float Range

Field Value

float

Type (Optional) (Default: Sound)

The type of sound, used for volume control in the settings.

[DocumentAsJson("Optional", "Sound", false)]
[JsonProperty("soundType")]
public EnumSoundType Type

Field Value

EnumSoundType

Volume (Optional) (Default: 1)

Controls a random volume for when the sound is played.

[DocumentAsJson("Optional", "1", false)]
public NatFloat Volume

Field Value

NatFloat