HammeriteAudioSoundSpec
Audio. Inherits Resource
What to play and how: the description a sound is created from.
Handed to HammeriteAudioManager.create_positional_sound() or HammeriteAudioManager.create_environmental_sound(), which read it once and keep their own copy of what it said. So one spec can create any number of sounds, and changing it afterwards changes none of them - what a sound is doing now is changed through the manager, by its handle.
var spec := HammeriteAudioSoundSpec.new()
spec.sound_file = "doors/creak.ogg"
spec.position = door.global_position
var handle := manager.create_positional_sound(spec)
manager.play_sound(handle)A resource, so a game can author one beside the thing that makes the noise rather than building it in code. Most sounds want an HammeriteAudioEmitter3D or HammeriteAudio.play_one_shot() instead; this is the layer under both.
Properties
| Type | Name | Default |
|---|---|---|
String | sound_file | "" |
Vector3 | position | Vector3(0, 0, 0) |
float | volume_db | 0.0 |
bool | loop | false |
bool | propagate | true |
float | max_distance | 0.0 |
float | attenuation_scale | 1.0 |
bool | free_when_finished | false |
Vector3 | direction | Vector3(0, 0, 0) |
Property descriptions
sound_file
var sound_file: String = ""
The recording, by its name in HammeriteAudioRuntime.sounds - doors/creak.ogg under one of its search paths - or by a resource path. A name that resolves to nothing creates no sound.
position
var position: Vector3 = Vector3(0, 0, 0)
Where the sound is made, in world space. Report a noise from where it is MADE: a sound at floor level is not in air, and in a map with no graph nothing hears it at all.
volume_db
var volume_db: float = 0.0
Mix level in dB, before anything the distance and the route cost it.
loop
var loop: bool = false
Loop until stopped, rather than playing once.
propagate
var propagate: bool = true
Route the sound through the acoustic graph - reverb, occlusion, round corners. Off plays it at its source with distance falloff alone, for a sound that should always arrive as if it were next to the listener.
max_distance
var max_distance: float = 0.0
Past this much path length the sound is not heard at all. 0 is no limit. Positional sounds only.
attenuation_scale
var attenuation_scale: float = 1.0
Scales what the distance costs: below 1 carries further, above 1 falls off sooner. Positional sounds only.
free_when_finished
var free_when_finished: bool = false
Release the sound once it has played through, handle and all. For a one-shot with no owner to delete it, which would otherwise hold a pooled player for the rest of the level. Positional sounds only.
direction
var direction: Vector3 = Vector3(0, 0, 0)
Which side weather comes from; Vector3.ZERO is all round at once. Environmental sounds only, and settable afterwards with HammeriteAudioManager.set_sound_direction().