commit de029527a6d177a93e33945e82aeecc236dd76e0 Author: tenplus1 Date: Sun Nov 9 19:32:21 2014 +0000 First Commit by TenPlus1 diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +default diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..6013177 --- /dev/null +++ b/init.lua @@ -0,0 +1,304 @@ + +--= Ambience lite by TenPlus1 (11 Sep 2014) + +local max_frequency_all = 1000 -- larger number means less frequent sounds (100-2000) +local SOUNDVOLUME = 1 +local volume = 0.3 +local ambiences +local played_on_start = false + +-- sound sets +local night = { + handler = {}, frequency = 20, + {name="hornedowl", length=2}, + {name="wolves", length=4}, + {name="cricket", length=6}, + {name="deer", length=7}, + {name="frog", length=1}, + {name="raccoon", length=1} +} + +local day = { + handler = {}, frequency = 80, + {name="cardinal", length=3}, + {name="craw", length=3}, + {name="bluejay", length=6}, + {name="canadianloon1", length=10}, + {name="canadianloon2", length=14}, + {name="robin", length=4}, + {name="bird1", length=11}, + {name="bird2", length=6}, + {name="crestedlark", length=6}, + {name="peacock", length=2} +} + +local cave = { + handler = {}, frequency = 80, + {name="drippingwater1", length=1.5}, + {name="drippingwater2", length=1.5} +} + +local beach = { + handler = {}, frequency = 20, + {name="seagull", length=4.5}, + {name="beach", length=13}, + {name="gull", length=1} +} + +local desert = { + handler = {}, frequency = 20, + {name="coyote", length=2.5}, + {name="desertwind", length=8} +} + +local flowing_water = { + handler = {}, frequency = 1000, + {name="waterfall", length=6} +} + +local splash = { + handler = {}, frequency = 1000, + {name="swim_splashing", length=3}, +} + +local lava = { + handler = {}, frequency = 1000, + {name="lava", length=7} +} + +-- find how many nodes in range +local nodes_in_range = function(pos, search_distance, node_name) + nodes = minetest.env:find_nodes_in_area({x=pos.x-search_distance,y=pos.y-search_distance, z=pos.z-search_distance}, + {x=pos.x+search_distance,y=pos.y+search_distance, z=pos.z+search_distance}, + node_name) + return #nodes +end + +local nodes_in_coords = function(minp, maxp, node_name) + nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name) + return #nodes +end + +-- find at least (threshold) nodes in area +local atleast_nodes_in_grid = function(pos, distance, height, node, threshold) + + nodes = minetest.env:find_nodes_in_area({x=pos.x-distance,y=height, z=pos.z+20}, + {x=pos.x+distance,y=height, z=pos.z+20}, node) + totalnodes = #nodes + if totalnodes >= threshold then return true end + + nodes = minetest.env:find_nodes_in_area({x=pos.x-distance,y=height, z=pos.z-20}, + {x=pos.x+distance,y=height, z=pos.z-20}, node) + totalnodes = totalnodes + #nodes + if totalnodes >= threshold then return true end + + nodes = minetest.env:find_nodes_in_area({x=pos.x+20,y=height, z=pos.z+distance}, + {x=pos.x+20,y=height, z=pos.z-distance}, node) + totalnodes = totalnodes + #nodes + if totalnodes >= threshold then return true end + + nodes = minetest.env:find_nodes_in_area({x=pos.x-20,y=height, z=pos.z-distance}, + {x=pos.x-20,y=height, z=pos.z+distance}, node) + totalnodes = totalnodes + #nodes + if totalnodes >= threshold then return true end + + return false +end + +-- check where player is and which sounds are played +local get_ambience = function(player) + + local pos = player:getpos() + + pos.y = pos.y + 0.2 + + if minetest.get_node(pos).name == "default:water_source" then + return {splash=splash} + end + + pos.y=pos.y - 0.2 + + if nodes_in_range(pos, 7, {"default:lava_flowing", "default:lava_source"}) > 5 then + return {lava=lava} + end + + if nodes_in_range(pos, 6, "default:water_flowing") > 45 then + return {flowing_water=flowing_water} + end + + if pos.y < 7 and pos.y > 0 and atleast_nodes_in_grid(pos, 60, 1, "default:water_source", 51 ) then + return {beach=beach} + end + + if nodes_in_range(pos, 6, {"default:desert_sand", "default:desert_stone", "default:sandstone"}) > 250 then + return {desert=desert} + end + + if player:getpos().y < 5 then + return {cave=cave} + end + + if minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8 then + return {day=day} + else + return {night=night} + end +end + +-- play sound, set handler then delete handler when sound finished +local play_sound = function(player, list, number) + + local player_name = player:get_player_name() + + if list.handler[player_name] == nil then + + local gain = volume * SOUNDVOLUME + local handler = minetest.sound_play(list[number].name, {to_player=player_name, gain=gain}) + + if handler then + list.handler[player_name] = handler + + minetest.after(list[number].length, function(args) + local list = args[1] + local player_name = args[2] + + if list.handler[player_name] then + minetest.sound_stop(list.handler[player_name]) + list.handler[player_name] = nil + end + end, {list, player_name}) + end + + end +end + +-- stop all sounds that are not in still_playing +local stop_sound = function(still_playing, player) + + local player_name = player:get_player_name() + + if not still_playing.cave then + local list = cave + if list.handler[player_name] then + if list.on_stop then + minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME}) + end + minetest.sound_stop(list.handler[player_name]) + list.handler[player_name] = nil + end + end + + if not still_playing.beach then + local list = beach + if list.handler[player_name] then + if list.on_stop then + minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME}) + end + minetest.sound_stop(list.handler[player_name]) + list.handler[player_name] = nil + end + end + + if not still_playing.desert then + local list = desert + if list.handler[player_name] then + if list.on_stop then + minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME}) + end + minetest.sound_stop(list.handler[player_name]) + list.handler[player_name] = nil + end + end + + if not still_playing.night then + local list = night + if list.handler[player_name] then + if list.on_stop then + minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME}) + end + minetest.sound_stop(list.handler[player_name]) + list.handler[player_name] = nil + end + end + + if not still_playing.day then + local list = day + if list.handler[player_name] then + if list.on_stop then + minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME}) + end + minetest.sound_stop(list.handler[player_name]) + list.handler[player_name] = nil + end + end + + if not still_playing.flowing_water then + local list = flowing_water + if list.handler[player_name] then + if list.on_stop then + minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME}) + end + minetest.sound_stop(list.handler[player_name]) + list.handler[player_name] = nil + end + end + + if not still_playing.splash then + local list = splash + if list.handler[player_name] then + if list.on_stop then + minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME}) + end + minetest.sound_stop(list.handler[player_name]) + list.handler[player_name] = nil + end + end + + if not still_playing.lava then + local list = lava + if list.handler[player_name] then + if list.on_stop then + minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME}) + end + minetest.sound_stop(list.handler[player_name]) + list.handler[player_name] = nil + end + end + +end + +-- player routine +local timer = 0 +minetest.register_globalstep(function(dtime) + timer = timer + dtime + if timer < 2 then return end + timer = 0 + + for _,player in ipairs(minetest.get_connected_players()) do + ambiences = get_ambience(player) + stop_sound(ambiences, player) + + for _,ambience in pairs(ambiences) do + + if math.random(1, 1000) <= ambience.frequency then + if ambience.on_start and played_on_start == false then + played_on_start = true + minetest.sound_play(ambience.on_start, + {to_player=player:get_player_name(),gain=SOUNDVOLUME}) + end + play_sound(player, ambience, math.random(1, #ambience)) + end + end + end +end) + +-- set volume command +minetest.register_chatcommand("svol", { + params = "", + description = "set sound volume (0.1 to 1.0)", + privs = {server=true}, + func = function(name, param) + SOUNDVOLUME = param + minetest.chat_send_player(name, "Sound volume set.") + end, +}) diff --git a/sounds/SoundLicenses.txt b/sounds/SoundLicenses.txt new file mode 100644 index 0000000..7bee6c6 --- /dev/null +++ b/sounds/SoundLicenses.txt @@ -0,0 +1,118 @@ +--------------Music Lic: +Amethystium: +--Avalon +--Ethereal +--Faraway +--Strangely Beautiful + +"I can't give you a formal license (legal paperwork) for it, but as long as it's non-commercial I can give you my personal blessing and guarantee that you won't get in trouble for using it :) If that's enough just feel free to use any of my tracks. Please credit the music properly though, and include a link to www.amethystium.com and www.am.mu (it's the same site right now, but the latter will be a label/music store site soon). +Best regards, +Øystein Ramfjord" + +Jordach: +--dark_ambiance +--eastern_feeling +These sounds are used for the Mod for Minetest; Ambiance. +The included sounds are http://creativecommons.org/licenses/by-nc-sa/3.0/ +Not Used:--mtest + +-----------Sound Lic: +--Nightime Sound, Recorded by Mike Koenig, License: Attribution 3.0 http://soundbible.com/951-Nightime.html +--Crickets At Night Sound, License: Attribution 3.0 | Recorded by Mike Koenig |http://soundbible.com/365-Crickets-At-Night.html + +--Medium Pack Of Wolves Howling, License: Public Domain | Recorded by fws.gov, http://soundbible.com/277-Medium-Pack-Of-Wolves-Howling.html + +--Horned Owl Sound, License: Attribution 3.0 | Recorded by Mike Koenig , http://soundbible.com/1851-Horned-Owl.html +--Bats In Cave Sound, License: Attr-Noncommercial 3.0 | Recorded by Mike Koenig , http://soundbible.com/1939-Bats-In-Cave.html + +--Spooky Water Drops Sound, License: Attribution 3.0 | Recorded by Mike Koenig, http://soundbible.com/380-Spooky-Water-Drops.html + + +-- Single Water Droplet Sound, License: Attribution 3.0 | Recorded by Mike Koenig, http://soundbible.com/384-Single-Water-Droplet.html + +--HollowWind, Black Boe, Creative Commons 0 License, http://www.freesound.org/people/Black%20Boe/sounds/22331/ + +--drippingwater*.ogg sounds: CC0, Dripping Water Mod, by kddekadenz, http://minetest.net/forum/viewtopic.php?id=1688 + +--best cardinal bird: License: Attribution 3.0 | Recorded by PsychoBird, http://soundbible.com/1515-Best-Cardinal-Bird.html + +--birdsongnl: the Attribution License, HerbertBoland, http://www.freesound.org/people/HerbertBoland/sounds/28312/ (end) + +--robin2: Attribution License, reinsamba, http://www.freesound.org/people/reinsamba/sounds/32479/ (end) + +--Craw.WAV, Attribution License, inchadney, http://www.freesound.org/people/inchadney/sounds/52450/ + +--bluejay.wav, Creative Commons 0 License, UncleSigmund, http://www.freesound.org/people/UncleSigmund/sounds/42382/ + +--scuba1*.ogg- digifishmusic, Attribution License, http://www.freesound.org/people/digifishmusic/sounds/45521/ + +--Underwater Pool - Attribution 3.0 | Recorded by Mike Koenig, http://soundbible.com/1660-Underwater-Pool.html + +--dolphin_screaming - Creative Commons 0 License, felix.blume, http://www.freesound.org/people/felix.blume/sounds/161691/ + +--dolphins - Attribution Noncommercial License, acclivity, http://www.freesound.org/people/acclivity/sounds/13691/ + +ComboWind uses: +--wind-in-the-trees -Attribution License, laurent, http://www.freesound.org/people/laurent/sounds/16995/ +--drygrassInWind- Creative Commons 0 License, felix.blume, http://www.freesound.org/people/felix.blume/sounds/146436/ + +--Splash: Attribution 3.0 | Recorded by BlastwaveFx.com, http://soundbible.com/546-Fish-Splashing.html + +--small_waterfall Attribution License, volivieri, http://www.freesound.org/people/volivieri/sounds/38390/ + +--Lake_Waves_2*, Attribution License, Benboncan, http://www.freesound.org/people/Benboncan/sounds/67884/ + +--water_swimming_splashing*, Attribution Noncommercial License, Robinhood76, http://www.freesound.org/people/Robinhood76/sounds/79657/ + +--earth01a, Creative Commons 0 License., Halion , http://www.freesound.org/people/Halion/sounds/17785 + +--fiji_beach, Creative Commons 0 License, c97059890, http://www.freesound.org/people/c97059890/sounds/21754/ + +--seagull, Attribution Noncommercial License., hazure, http://www.freesound.org/people/hazure/sounds/23707/, + +desert: +coyote2, Attribution License, rogerforeman, http://www.freesound.org/people/rogerforeman/sounds/68068/ +http://www.freesound.org/people/Proxima4/sounds/104319/ +Desert Monolith.wav, Creative Commons 0 License, Proxima4, http://www.freesound.org/people/Proxima4/sounds/104319/ +Rattlesnake Rattle, Public Domain, fws.gov, http://soundbible.com/237-Rattlesnake-Rattle.html + +flying: +crystal_airlines: Attribution License, suonho, http://www.freesound.org/people/suonho/sounds/56364/ + +----------------Not used yet: +desert: +Desert Simple.wav, Creative Commons 0 License, Proxima4, http://www.freesound.org/people/Proxima4/sounds/104320/ + + 313hummer (Jordan Craige) +--echos http://soundcloud.com/jordan-craige/echos-1 +Creative Commons Attribution license (reuse allowed) Attribution 3.0 Unported (CC BY 3.0) +Not Used:--FoamOfTheSea http://soundcloud.com/jordan-craige/foam-of-the-sea + +xi-intersection: +http://soundcloud.com/xi-intersection/mass-effect-uncharted-worlds Creative Commons License +--not used: +http://soundcloud.com/xi-intersection/donkey-kong-country-2-flight +http://soundcloud.com/kogyo/kogyo-skalar-m1 + +lava: +http://www.freesound.org/people/Halion/sounds/17785/ (almost as good cc) (combine with rocks falling?) +http://www.freesound.org/people/pushtobreak/sounds/17823/ (attrib non cc really good) +http://www.freesound.org/people/klankbeeld/sounds/123970/ (horror rhythm) +Rockfall in mine.wav http://www.freesound.org/people/Benboncan/sounds/60085/ + + +http://www.freesound.org/people/snotch/sounds/96175/ (mud volcano) + +--natural night sounds in Boquete.wav, Attribution License, laurent, http://www.freesound.org/people/laurent/sounds/15851/ +http://www.freesound.org/people/Dynamicell/sounds/17553/ +http://www.freesound.org/people/juskiddink/sounds/78955/ aspen tree in wind +http://www.freesound.org/people/Benboncan/sounds/69761/ wind in hedge birds animals + + +ButterflyTea: +Creative Commons : Attribution-Noncommercial-Share Alike 3.0 +http://www.jamendo.com/en/track/904012/dance-of-magical-flowers +http://www.jamendo.com/en/track/904013/magic-of-the-seventh-world +http://www.jamendo.com/en/track/904016/in-search-of-the-soul + +zero-project diff --git a/sounds/beach.ogg b/sounds/beach.ogg new file mode 100644 index 0000000..69c37b7 Binary files /dev/null and b/sounds/beach.ogg differ diff --git a/sounds/bird1.ogg b/sounds/bird1.ogg new file mode 100644 index 0000000..4efee11 Binary files /dev/null and b/sounds/bird1.ogg differ diff --git a/sounds/bird2.ogg b/sounds/bird2.ogg new file mode 100644 index 0000000..9543471 Binary files /dev/null and b/sounds/bird2.ogg differ diff --git a/sounds/bluejay.ogg b/sounds/bluejay.ogg new file mode 100644 index 0000000..3dfe8a5 Binary files /dev/null and b/sounds/bluejay.ogg differ diff --git a/sounds/canadianloon1.ogg b/sounds/canadianloon1.ogg new file mode 100644 index 0000000..e57cf89 Binary files /dev/null and b/sounds/canadianloon1.ogg differ diff --git a/sounds/canadianloon2.ogg b/sounds/canadianloon2.ogg new file mode 100644 index 0000000..511d8e1 Binary files /dev/null and b/sounds/canadianloon2.ogg differ diff --git a/sounds/cardinal.ogg b/sounds/cardinal.ogg new file mode 100644 index 0000000..ad8c836 Binary files /dev/null and b/sounds/cardinal.ogg differ diff --git a/sounds/coyote.ogg b/sounds/coyote.ogg new file mode 100644 index 0000000..dc29674 Binary files /dev/null and b/sounds/coyote.ogg differ diff --git a/sounds/craw.ogg b/sounds/craw.ogg new file mode 100644 index 0000000..3c5c941 Binary files /dev/null and b/sounds/craw.ogg differ diff --git a/sounds/crestedlark.ogg b/sounds/crestedlark.ogg new file mode 100644 index 0000000..8757747 Binary files /dev/null and b/sounds/crestedlark.ogg differ diff --git a/sounds/cricket.ogg b/sounds/cricket.ogg new file mode 100644 index 0000000..58f6b97 Binary files /dev/null and b/sounds/cricket.ogg differ diff --git a/sounds/deer.ogg b/sounds/deer.ogg new file mode 100644 index 0000000..293591f Binary files /dev/null and b/sounds/deer.ogg differ diff --git a/sounds/desertwind.ogg b/sounds/desertwind.ogg new file mode 100644 index 0000000..0fb4d3e Binary files /dev/null and b/sounds/desertwind.ogg differ diff --git a/sounds/drippingwater1.ogg b/sounds/drippingwater1.ogg new file mode 100644 index 0000000..7bc116a Binary files /dev/null and b/sounds/drippingwater1.ogg differ diff --git a/sounds/drippingwater2.ogg b/sounds/drippingwater2.ogg new file mode 100644 index 0000000..e8b040c Binary files /dev/null and b/sounds/drippingwater2.ogg differ diff --git a/sounds/frog.ogg b/sounds/frog.ogg new file mode 100644 index 0000000..3775fef Binary files /dev/null and b/sounds/frog.ogg differ diff --git a/sounds/gull.ogg b/sounds/gull.ogg new file mode 100644 index 0000000..3d90847 Binary files /dev/null and b/sounds/gull.ogg differ diff --git a/sounds/hornedowl.ogg b/sounds/hornedowl.ogg new file mode 100644 index 0000000..4656ae6 Binary files /dev/null and b/sounds/hornedowl.ogg differ diff --git a/sounds/lava.ogg b/sounds/lava.ogg new file mode 100644 index 0000000..b019444 Binary files /dev/null and b/sounds/lava.ogg differ diff --git a/sounds/peacock.ogg b/sounds/peacock.ogg new file mode 100644 index 0000000..c17142f Binary files /dev/null and b/sounds/peacock.ogg differ diff --git a/sounds/raccoon.ogg b/sounds/raccoon.ogg new file mode 100644 index 0000000..0f89a96 Binary files /dev/null and b/sounds/raccoon.ogg differ diff --git a/sounds/robin.ogg b/sounds/robin.ogg new file mode 100644 index 0000000..709207d Binary files /dev/null and b/sounds/robin.ogg differ diff --git a/sounds/seagull.ogg b/sounds/seagull.ogg new file mode 100644 index 0000000..9dab963 Binary files /dev/null and b/sounds/seagull.ogg differ diff --git a/sounds/swim_splashing.ogg b/sounds/swim_splashing.ogg new file mode 100644 index 0000000..af64acf Binary files /dev/null and b/sounds/swim_splashing.ogg differ diff --git a/sounds/waterfall.ogg b/sounds/waterfall.ogg new file mode 100644 index 0000000..7be3ee4 Binary files /dev/null and b/sounds/waterfall.ogg differ diff --git a/sounds/wolves.ogg b/sounds/wolves.ogg new file mode 100644 index 0000000..f23b1f9 Binary files /dev/null and b/sounds/wolves.ogg differ