123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- -- This file is reloadable.
- -- Table of registered sounds. Algorithm intended for intermittent sounds only, continuous sounds need special treatment.
- -- Data includes what environment the sound needs to play, what time of day, what elevations, etc. This table is updated dynamically.
- ambiance.allsounds = {}
- ambiance.tmpsounds = {
- -- Dripping water: occurs in over-world caves at any time of day.
- -- Can also be heard in developed areas, underground.
- {
- name="drippingwater", mingain=0.2, maxgain = 1.0, miny=-25000, maxy=-30, time="", indoors=nil,
- noise_params = {
- offset = 0,
- scale = 1,
- spread = {x=256, y=256, z=256},
- seed = 2129394,
- octaves = 3,
- persist = 0.5,
- lacunarity = 1.5,
- flags = "",
- },
- noise_threshold = 0.0,
- },
- -- Cave bats: occurs in over-world caves, only at night.
- {
- name="cave_bats", gain=0.7, miny=-25000, maxy=-60, time="night", indoors=false, mintime=60, maxtime=120,
- noise_params = {
- offset = 0,
- scale = 1,
- spread = {x=256, y=256, z=256},
- seed = 577891,
- octaves = 2,
- persist = 0.5,
- lacunarity = 1.5,
- flags = "",
- },
- noise_threshold = 0.3,
- },
- -- Wind: surface sound only, any time of day (but more common at night).
- {name="wind1", gain=0.5, miny=-15, maxy=3300, time="day", indoors=false, },
- {name="wind2", gain=0.5, miny=-15, maxy=3300, time="day", indoors=false, },
- {name="desertwind", gain=0.5, miny=-15, maxy=3300, time="day", indoors=false, },
- {name="wind1", gain=1.0, miny=-15, maxy=3300, time="night", indoors=false, mintime=20, maxtime=50, },
- {name="wind2", gain=1.0, miny=-15, maxy=3300, time="night", indoors=false, mintime=20, maxtime=50, },
- {name="desertwind", gain=1.0, miny=-15, maxy=3300, time="night", indoors=false, mintime=20, maxtime=50, },
- -- Plays in caverealms.
- {
- name="cavewind", gain=1.0, miny=-31000, maxy=-256, time="", indoors=nil, mintime=25, maxtime=45,
- -- These parameters match the mapgen.
- noise_params = {
- flags = "defaults",
- lacunarity = 2,
- offset = 0,
- scale = 1,
- spread = {x=768, y=256, z=768},
- seed = 59033,
- octaves = 6,
- persistence = 0.63,
- },
- -- Mapgen threshold is 0.6.
- -- Use a slightly lower threshold so that the sound extends outside the caverns a bit.
- noise_threshold = 0.5,
- -- The world-seed is very large, causing integer overflow.
- -- So we need to get the engine to calculate it against the world seed,
- -- in order to ensure we use the same final seed the engine uses.
- include_world_seed = true,
- },
- {
- name="cavedraft", gain=1.0, miny=-31000, maxy=-256, time="", indoors=nil, mintime=100, maxtime=400,
- -- These parameters match the mapgen.
- noise_params = {
- flags = "defaults",
- lacunarity = 2,
- offset = 0,
- scale = 1,
- spread = {x=768, y=256, z=768},
- seed = 59033,
- octaves = 6,
- persistence = 0.63,
- },
- -- Mapgen threshold is 0.6.
- -- Use a slightly lower threshold so that the sound extends outside the caverns a bit.
- noise_threshold = 0.5,
- -- The world-seed is very large, causing integer overflow.
- -- So we need to get the engine to calculate it against the world seed,
- -- in order to ensure we use the same final seed the engine uses.
- include_world_seed = true,
- },
- {
- name="darkwind", gain=1.0, miny=-31000, maxy=-256, time="", indoors=nil, mintime=200, maxtime=500,
- -- These parameters match the mapgen.
- noise_params = {
- flags = "defaults",
- lacunarity = 2,
- offset = 0,
- scale = 1,
- spread = {x=768, y=256, z=768},
- seed = 59033,
- octaves = 6,
- persistence = 0.63,
- },
- -- Mapgen threshold is 0.6.
- -- Use a slightly lower threshold so that the sound extends outside the caverns a bit.
- noise_threshold = 0.5,
- -- The world-seed is very large, causing integer overflow.
- -- So we need to get the engine to calculate it against the world seed,
- -- in order to ensure we use the same final seed the engine uses.
- include_world_seed = true,
- },
- -- This plays in both overworld and channelwood (jarkati has its own entry).
- {name="desertwind", mingain=0.2, maxgain=0.4, miny=-15,maxy=3300,time="", indoors=nil, mintime=6, maxtime=8, }, -- Continuous quiet loop.
- -- Various animal sounds.
- {
- name="wolves", gain=1.0, miny=-10, maxy=1000, time="night", indoors=false,
- noise_params = {
- offset = 0,
- scale = 1,
- spread = {x=256, y=256, z=256},
- seed = 381783,
- octaves = 2,
- persist = 0.5,
- lacunarity = 1.5,
- flags = "",
- },
- noise_threshold = 0.3,
- },
- {
- name="coyote", gain=1.0, miny=-10, maxy=1000, time="night", indoors=false,
- noise_params = {
- offset = 0,
- scale = 1,
- spread = {x=256, y=256, z=256},
- seed = 6822034,
- octaves = 2,
- persist = 0.5,
- lacunarity = 1.5,
- flags = "",
- },
- noise_threshold = 0.3,
- },
- {name="craw", gain=1.0, miny=3000, maxy=3300, time="day" , indoors=false, },
- {name="hornedowl", gain=1.0, miny=3000, maxy=3300, time="night", indoors=false, },
- -- Owl in Overworld.
- {
- name="owl", gain=1.0, miny=-10, maxy=1000, time="night", indoors=false,
- noise_params = {
- offset = 0,
- scale = 1,
- spread = {x=256, y=256, z=256},
- seed = 589981,
- octaves = 2,
- persist = 0.5,
- lacunarity = 1.5,
- flags = "",
- },
- noise_threshold = 0.5,
- },
- -- Owl in Channelwood.
- {
- name="owl", gain=1.0, miny=3000, maxy=3300, time="night", indoors=false,
- noise_params = {
- offset = 0,
- scale = 1,
- spread = {x=256, y=256, z=256},
- seed = 2819294,
- octaves = 2,
- persist = 0.5,
- lacunarity = 1.5,
- flags = "",
- },
- noise_threshold = 0.2,
- },
- -- Continuous lava rumble in the nether.
- {name="lava", gain=0.8, miny=-31000, maxy=-25000, time="", indoors=nil, mintime=7, maxtime=7, },
- -- More animal sounds. These should play with less frequency.
- -- Only in Channelwood. Overworld nature bird/insect sounds use sound-beacons (due to scarcity of trees/water).
- {name="cricket", gain=1.0, miny=3000, maxy=3300, time="night", indoors=false, mintime=10, maxtime=30, },
- {name="jungle_night_1", gain=1.0, miny=3000, maxy=3300, time="night", indoors=false, mintime=10, maxtime=30, },
- {name="cardinal", gain=1.0, miny=3000, maxy=3300, time="day", indoors=false, mintime=20, maxtime=60, },
- {name="crestedlark", gain=1.0, miny=3000, maxy=3300, time="day", indoors=false, mintime=20, maxtime=60, },
- {name="deer", gain=1.0, miny=3000, maxy=3300, time="night", indoors=false, mintime=20, maxtime=120, },
- {name="frog", gain=0.7, miny=3000, maxy=3300, time="liminal", indoors=false, },
- {name="robin", gain=1.0, miny=3000, maxy=3300, time="day", indoors=false, },
- {name="bluejay", gain=1.0, miny=3000, maxy=3300, time="liminal", indoors=false, },
- {name="gull", gain=1.0, miny=3000, maxy=3300, time="day", indoors=false, },
- {name="peacock", gain=1.0, miny=3000, maxy=3300, time="liminal", indoors=false, },
- {
- name="canadianloon1", gain=1.0, miny=3000, maxy=3300, time="night", indoors=false, mintime=120, maxtime=360,
- noise_params = {
- offset = 0,
- scale = 1,
- spread = {x=256, y=256, z=256},
- seed = 6582929,
- octaves = 2,
- persist = 0.5,
- lacunarity = 1.5,
- flags = "",
- },
- noise_threshold = 0.3,
- },
- -- Rare deep cave sounds.
- {
- name="obsidianmonster_obsidianmonster", gain=1.0, miny=-31000, maxy=-128, time="", indoors=false, mintime=280, maxtime=560,
- noise_params = {
- offset = 0,
- scale = 1,
- spread = {x=256, y=256, z=256},
- seed = 589731,
- octaves = 2,
- persist = 0.5,
- lacunarity = 1.5,
- flags = "",
- },
- noise_threshold = 0.3,
- },
- {
- name="mobs_sandmonster", gain=1.0, miny=-31000, maxy=-128, time="", indoors=false, mintime=280, maxtime=560,
- noise_params = {
- offset = 0,
- scale = 1,
- spread = {x=256, y=256, z=256},
- seed = 57187382,
- octaves = 2,
- persist = 0.5,
- lacunarity = 1.5,
- flags = "",
- },
- noise_threshold = 0.3,
- },
- {
- name="mobs_spider", gain=1.0, miny=-31000, maxy=-128, time="", indoors=false, mintime=280, maxtime=560,
- noise_params = {
- offset = 0,
- scale = 1,
- spread = {x=256, y=256, z=256},
- seed = 5672824,
- octaves = 2,
- persist = 0.5,
- lacunarity = 1.5,
- flags = "",
- },
- noise_threshold = 0.3,
- },
- -- Nether yuck.
- {
- name="nether_extract_blood", gain=1.0, miny=-31000, maxy=-20000, time="", indoors=false, mintime=280, maxtime=860,
- noise_params = {
- offset = 0,
- scale = 1,
- spread = {x=256, y=256, z=256},
- seed = 282934,
- octaves = 2,
- persist = 0.5,
- lacunarity = 1.5,
- flags = "",
- },
- noise_threshold = 0.3,
- },
- -- Continuous wind on Jarkati surface.
- {name="wind1", gain=1.5, miny=3735, maxy=3900, time="", indoors=false, mintime=20, maxtime=40, },
- {name="wind2", gain=1.5, miny=3735, maxy=3900, time="", indoors=false, mintime=20, maxtime=40, },
- {name="desertwind", gain=1.5, miny=3735, maxy=3900, time="", indoors=false, mintime=20, maxtime=40, },
- {name="desertwind", mingain=0.2, maxgain=0.4, miny=3735, maxy=3900, time="", indoors=nil,mintime=6, maxtime=8, }, -- Continuous quiet loop.
- -- Continuous wind in the Outback.
- {name="wind1", gain=1.0, miny=4160, maxy=4200, time="", indoors=nil, mintime=20, maxtime=40, },
- {name="wind2", gain=1.0, miny=4160, maxy=4200, time="", indoors=nil, mintime=20, maxtime=40, },
- {name="desertwind", gain=1.0, miny=4160, maxy=4200, time="", indoors=nil, mintime=20, maxtime=40, },
- {name="desertwind", mingain=0.2, maxgain=0.4, miny=4160, maxy=4200, time="", indoors=nil,mintime=6, maxtime=8, }, -- Continuous quiet loop.
- -- Nighttime insects.
- {name="night_cicadas", mingain=0.2, maxgain=1.0, miny=4160, maxy=4200, time="night", indoors=nil,mintime=7, maxtime=11, }, -- Continuous quiet loop.
- {name="wolves", mingain=0.2, maxgain=1.3, miny=4160, maxy=4200, time="night", indoors=nil, mintime=20, maxtime=60, },
- {name="coyote", mingain=0.2, maxgain=1.3, miny=4160, maxy=4200, time="night", indoors=nil, mintime=10, maxtime=30, },
- }
- -- Initialize extra table parameters.
- minetest.after(0, function()
- for k, v in ipairs(ambiance.tmpsounds) do
- -- Mintime & maxtime are the min and max seconds a sound can play again after it has played.
- -- The timer is reset to a new random value between min and max every time the sound plays.
- v.mintime = v.mintime or 30
- v.maxtime = v.maxtime or 120
- if v.mintime < 0 then v.mintime = 0 end
- if v.maxtime < v.mintime then v.maxtime = v.mintime end
- -- If minimum or maximum gain are not specified, calculate min and max gain.
- v.mingain = v.mingain or (v.gain - 0.5)
- v.maxgain = v.maxgain or (v.gain + 0.1)
- if v.mingain < 0 then v.mingain = 0 end
- if v.maxgain < v.mingain then v.maxgain = v.mingain end
- -- Initialize timer to a random value between min and max time.
- -- This ensures all sounds start with random times on first run.
- v.timer = math.random(v.mintime, v.maxtime)
- -- Create perlin noise object if wanted.
- if v.noise_params then
- if v.include_world_seed then
- v.perlin = minetest.get_perlin(v.noise_params)
- assert(v.perlin)
- else
- v.perlin = PerlinNoise(v.noise_params)
- assert(v.perlin)
- end
- assert(v.perlin)
- end
- v.noise_threshold = v.noise_threshold or 0
- end
- ambiance.allsounds = ambiance.tmpsounds
- ambiance.tmpsounds = nil
- end)
- -- Lava & scuba sounds (or any special sound) must be handled differently.
|