@@ -994,16 +994,21 @@ Only Ogg Vorbis files are supported.
994
994
For positional playing of sounds, only single-channel (mono) files are
995
995
supported. Otherwise OpenAL will play them non-positionally.
996
996
997
- Mods should generally prefix their sounds with ` modname_ ` , e.g. given
997
+ Mods should generally prefix their sound files with ` modname_ ` , e.g. given
998
998
the mod name "` foomod ` ", a sound could be called:
999
999
1000
1000
foomod_foosound.ogg
1001
1001
1002
- Sounds are referred to by their name with a dot, a single digit and the
1003
- file extension stripped out. When a sound is played, the actual sound file
1004
- is chosen randomly from the matching sounds.
1002
+ Sound group
1003
+ -----------
1004
+
1005
+ A sound group is the set of all sound files, whose filenames are of the following
1006
+ format:
1007
+ ` <sound-group name>[.<single digit>].ogg `
1008
+ When a sound-group is played, one the files in the group is chosen at random.
1009
+ Sound files can only be referred to by their sound-group name.
1005
1010
1006
- When playing the sound ` foomod_foosound ` , the sound is chosen randomly
1011
+ Example: When playing the sound ` foomod_foosound ` , the sound is chosen randomly
1007
1012
from the available ones of the following files:
1008
1013
1009
1014
* ` foomod_foosound.ogg `
@@ -1012,20 +1017,111 @@ from the available ones of the following files:
1012
1017
* (...)
1013
1018
* ` foomod_foosound.9.ogg `
1014
1019
1015
- Examples of sound parameter tables:
1020
+ ` SimpleSoundSpec `
1021
+ -----------------
1022
+
1023
+ Specifies a sound name, gain (=volume), pitch and fade.
1024
+ This is either a string or a table.
1025
+
1026
+ In string form, you just specify the sound name or
1027
+ the empty string for no sound.
1028
+
1029
+ Table form has the following fields:
1030
+
1031
+ * ` name ` :
1032
+ Sound-group name.
1033
+ If == ` "" ` , no sound is played.
1034
+ * ` gain ` :
1035
+ Volume (` 1.0 ` = 100%), must be non-negative.
1036
+ At the end, OpenAL clamps sound gain to a maximum of ` 1.0 ` . By setting gain for
1037
+ a positional sound higher than ` 1.0 ` , one can increase the radius inside which
1038
+ maximal gain is reached.
1039
+ Furthermore, gain of positional sounds doesn't increase inside a 1 node radius.
1040
+ The gain given here describes the gain at a distance of 3 nodes.
1041
+ * ` pitch ` :
1042
+ Applies a pitch-shift to the sound.
1043
+ Each factor of ` 2.0 ` results in a pitch-shift of +12 semitones.
1044
+ Must be positive.
1045
+ * ` fade ` :
1046
+ If > ` 0.0 ` , the sound is faded in, with this value in gain per second, until
1047
+ ` gain ` is reached.
1048
+
1049
+ ` gain ` , ` pitch ` and ` fade ` are optional and default to ` 1.0 ` , ` 1.0 ` and ` 0.0 ` .
1050
+
1051
+ Examples:
1052
+
1053
+ * ` "" ` : No sound
1054
+ * ` {} ` : No sound
1055
+ * ` "default_place_node" ` : Play e.g. ` default_place_node.ogg `
1056
+ * ` {name = "default_place_node"} ` : Same as above
1057
+ * ` {name = "default_place_node", gain = 0.5} ` : 50% volume
1058
+ * ` {name = "default_place_node", gain = 0.9, pitch = 1.1} ` : 90% volume, 110% pitch
1059
+
1060
+ Sound parameter table
1061
+ ---------------------
1062
+
1063
+ Table used to specify how a sound is played:
1064
+
1065
+ ``` lua
1066
+ {
1067
+ gain = 1.0 ,
1068
+ -- Scales the gain specified in `SimpleSoundSpec`.
1069
+
1070
+ pitch = 1.0 ,
1071
+ -- Overwrites the pitch specified in `SimpleSoundSpec`.
1072
+
1073
+ fade = 0.0 ,
1074
+ -- Overwrites the fade specified in `SimpleSoundSpec`.
1075
+
1076
+ start_time = 0.0 ,
1077
+ -- Start with a time-offset into the sound.
1078
+ -- The behavior is as if the sound was already playing for this many seconds.
1079
+ -- Negative values are relative to the sound's length, so the sound reaches
1080
+ -- its end in `-start_time` seconds.
1081
+ -- It is unspecified what happens if `loop` is false and `start_time` is
1082
+ -- smaller than minus the sound's length.
1083
+
1084
+ loop = false ,
1085
+ -- If true, sound is played in a loop.
1086
+
1087
+ pos = {x = 1 , y = 2 , z = 3 },
1088
+ -- Play sound at a position.
1089
+ -- Can't be used together with `object`.
1090
+
1091
+ object = < an ObjectRef > ,
1092
+ -- Attach the sound to an object.
1093
+ -- Can't be used together with `pos`.
1094
+
1095
+ to_player = name ,
1096
+ -- Only play for this player.
1097
+ -- Can't be used together with `exclude_player`.
1098
+
1099
+ exclude_player = name ,
1100
+ -- Don't play sound for this player.
1101
+ -- Can't be used together with `to_player`.
1102
+
1103
+ max_hear_distance = 32 ,
1104
+ -- Only play for players that are at most this far away when the sound
1105
+ -- starts playing.
1106
+ -- Needs `pos` or `object` to be set.
1107
+ -- `32` is the default.
1108
+ }
1109
+ ```
1110
+
1111
+ Examples:
1016
1112
1017
1113
``` lua
1018
1114
-- Play locationless on all clients
1019
1115
{
1020
1116
gain = 1.0 , -- default
1021
- fade = 0.0 , -- default, change to a value > 0 to fade the sound in
1117
+ fade = 0.0 , -- default
1022
1118
pitch = 1.0 , -- default
1023
1119
}
1024
1120
-- Play locationless to one player
1025
1121
{
1026
1122
to_player = name ,
1027
1123
gain = 1.0 , -- default
1028
- fade = 0.0 , -- default, change to a value > 0 to fade the sound in
1124
+ fade = 0.0 , -- default
1029
1125
pitch = 1.0 , -- default
1030
1126
}
1031
1127
-- Play locationless to one player, looped
@@ -1034,17 +1130,18 @@ Examples of sound parameter tables:
1034
1130
gain = 1.0 , -- default
1035
1131
loop = true ,
1036
1132
}
1037
- -- Play at a location
1133
+ -- Play at a location, start the sound at offset 5 seconds
1038
1134
{
1039
1135
pos = {x = 1 , y = 2 , z = 3 },
1040
1136
gain = 1.0 , -- default
1041
- max_hear_distance = 32 , -- default, uses a Euclidean metric
1137
+ max_hear_distance = 32 , -- default
1138
+ start_time = 5.0 ,
1042
1139
}
1043
1140
-- Play connected to an object, looped
1044
1141
{
1045
1142
object = < an ObjectRef > ,
1046
1143
gain = 1.0 , -- default
1047
- max_hear_distance = 32 , -- default, uses a Euclidean metric
1144
+ max_hear_distance = 32 , -- default
1048
1145
loop = true ,
1049
1146
}
1050
1147
-- Play at a location, heard by anyone *but* the given player
@@ -1055,45 +1152,10 @@ Examples of sound parameter tables:
1055
1152
}
1056
1153
```
1057
1154
1058
- Looped sounds must either be connected to an object or played locationless to
1059
- one player using ` to_player = name ` .
1060
-
1061
- A positional sound will only be heard by players that are within
1062
- ` max_hear_distance ` of the sound position, at the start of the sound.
1063
-
1064
- ` exclude_player = name ` can be applied to locationless, positional and object-
1065
- bound sounds to exclude a single player from hearing them.
1066
-
1067
- ` SimpleSoundSpec `
1068
- -----------------
1069
-
1070
- Specifies a sound name, gain (=volume) and pitch.
1071
- This is either a string or a table.
1072
-
1073
- In string form, you just specify the sound name or
1074
- the empty string for no sound.
1075
-
1076
- Table form has the following fields:
1077
-
1078
- * ` name ` : Sound name
1079
- * ` gain ` : Volume (` 1.0 ` = 100%)
1080
- * ` pitch ` : Pitch (` 1.0 ` = 100%)
1081
-
1082
- ` gain ` and ` pitch ` are optional and default to ` 1.0 ` .
1083
-
1084
- Examples:
1085
-
1086
- * ` "" ` : No sound
1087
- * ` {} ` : No sound
1088
- * ` "default_place_node" ` : Play e.g. ` default_place_node.ogg `
1089
- * ` {name = "default_place_node"} ` : Same as above
1090
- * ` {name = "default_place_node", gain = 0.5} ` : 50% volume
1091
- * ` {name = "default_place_node", gain = 0.9, pitch = 1.1} ` : 90% volume, 110% pitch
1092
-
1093
- Special sound files
1094
- -------------------
1155
+ Special sound-groups
1156
+ --------------------
1095
1157
1096
- These sound files are played back by the engine if provided.
1158
+ These sound-groups are played back by the engine if provided.
1097
1159
1098
1160
* ` player_damage ` : Played when the local player takes damage (gain = 0.5)
1099
1161
* ` player_falling_damage ` : Played when the local player takes
@@ -8804,7 +8866,10 @@ Used by `minetest.register_node`.
8804
8866
8805
8867
footstep = <SimpleSoundSpec> ,
8806
8868
-- If walkable, played when object walks on it. If node is
8807
- -- climbable or a liquid, played when object moves through it
8869
+ -- climbable or a liquid, played when object moves through it.
8870
+ -- Sound is played at the base of the object's collision-box.
8871
+ -- Gain is multiplied by `0.6`.
8872
+ -- For local player, it's played position-less, with normal gain.
8808
8873
8809
8874
dig = <SimpleSoundSpec> or " __group" ,
8810
8875
-- While digging node.
0 commit comments