Initial commit.
|
@ -0,0 +1,3 @@
|
|||
Games Sounds `gen_music' (C) 2017 James Stevenson
|
||||
GPL3+
|
||||
Glyph textures by kilbith from X-Decor.
|
|
@ -0,0 +1,16 @@
|
|||
gen_music_phit,walkie_blip,xdecor_enchanting,default_chest_open,catching_breath
|
||||
1
|
||||
1
|
||||
2
|
||||
0
|
||||
1
|
||||
1
|
||||
2
|
||||
0
|
||||
3
|
||||
4
|
||||
0
|
||||
5
|
||||
0
|
||||
1
|
||||
5
|
|
@ -0,0 +1,22 @@
|
|||
gen_music_phit,default_dig_metal,item_smoke
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
3
|
||||
2
|
||||
2
|
||||
3
|
||||
2
|
||||
2
|
||||
0
|
||||
0
|
||||
3
|
||||
2
|
||||
2
|
||||
3
|
||||
2
|
||||
2
|
||||
0
|
||||
0
|
|
@ -0,0 +1,17 @@
|
|||
default_dig_dig_immediate,default_dig_oddly_breakable_by_hand,default_dig_metal,default_place_node_hard,default_place_node,default_place_node_metal,default_tool_breaks,default_item_smoke
|
||||
2
|
||||
8
|
||||
0
|
||||
1
|
||||
7
|
||||
0
|
||||
6
|
||||
1
|
||||
5
|
||||
1
|
||||
0
|
||||
4
|
||||
1
|
||||
3
|
||||
1
|
||||
0
|
|
@ -0,0 +1,10 @@
|
|||
default_dig_oddly_breakable_by_hand
|
||||
1
|
||||
1
|
||||
0
|
||||
1
|
||||
0
|
||||
0
|
||||
1
|
||||
0
|
||||
1
|
|
@ -0,0 +1,11 @@
|
|||
default_dig_metal,default_dig_snappy,default_punch
|
||||
3
|
||||
3
|
||||
0
|
||||
1
|
||||
3
|
||||
2
|
||||
3
|
||||
1
|
||||
1
|
||||
0
|
|
@ -0,0 +1 @@
|
|||
walkie_blip
|
|
@ -0,0 +1,334 @@
|
|||
-- Game Sounds `gen_music'
|
||||
-- By James Stevenson (C) 2017
|
||||
-- GPL3+
|
||||
gen_music = {}
|
||||
|
||||
gen_music.songs = {}
|
||||
local mod_name = minetest.get_current_modname()
|
||||
local mod_path = minetest.get_modpath(mod_name)
|
||||
local function load_songs()
|
||||
local input = io.open(mod_path .. "/songs.txt", "r")
|
||||
if not input then
|
||||
return
|
||||
end
|
||||
|
||||
local songs = {}
|
||||
local fn = input:read("*l")
|
||||
while fn do
|
||||
songs[#songs + 1] = fn
|
||||
fn = input:read("*l")
|
||||
end
|
||||
|
||||
for i = 1, #songs do
|
||||
local song_name = songs[i]
|
||||
local song = io.open(mod_path .. "/" .. song_name, "r")
|
||||
if not song then
|
||||
print(song_name .. " not found.")
|
||||
else
|
||||
print("Loading " .. song_name)
|
||||
local ins = song:read("*l"):split()
|
||||
local seq = {}
|
||||
local seql = song:read("*l")
|
||||
while seql do
|
||||
seq[#seq + 1] = tonumber(seql)
|
||||
seql = song:read("*l")
|
||||
end
|
||||
gen_music.songs[song_name] = {
|
||||
ins = ins,
|
||||
seq = seq,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
load_songs()
|
||||
--print(dump(gen_music))
|
||||
|
||||
local sounds = {}
|
||||
for _, nodes in pairs(minetest.registered_nodes) do
|
||||
for elem, val in pairs(nodes) do
|
||||
if elem == "sounds" then
|
||||
for _, spec in pairs(val) do
|
||||
if not sounds[spec.name] and
|
||||
spec.name ~= "" then
|
||||
if not spec.gain then
|
||||
spec.gain = 0.5
|
||||
end
|
||||
sounds[#sounds + 1] = spec
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--[[
|
||||
-- mobs_redo entities.
|
||||
for _, def in pairs(minetest.registered_entities) do
|
||||
for prop, val in pairs(def) do
|
||||
if prop == "sounds" then
|
||||
for sound_type, sound in pairs(val) do
|
||||
if type(sound) == "string" then
|
||||
if not sounds[sound] and
|
||||
sounds[sound] ~= "" then
|
||||
sounds[#sounds + 1] = {name = sound, gain = 0.5}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--]]
|
||||
local extra_sounds = {
|
||||
"tnt_ignite",
|
||||
"tnt_explode",
|
||||
"tnt_gunpower_burning",
|
||||
"fire_flint_and_steel",
|
||||
"fire_extinguish_flame",
|
||||
"fire_fire",
|
||||
"default_punch",
|
||||
"default_dig_oddly_breakable_by_hand",
|
||||
"default_dug_node",
|
||||
"player_damage",
|
||||
"doors_door_open",
|
||||
"doors_door_close",
|
||||
"default_chest_open",
|
||||
"default_chest_close",
|
||||
}
|
||||
for i = 1, #extra_sounds do
|
||||
local n = extra_sounds[i]
|
||||
if not sounds[n] then
|
||||
sounds[#sounds + 1] = {name = extra_sounds[i], gain = 0.5}
|
||||
end
|
||||
end
|
||||
|
||||
-- Sound Traveller
|
||||
local ps = function(pos)
|
||||
if math.random() < 0.8 then
|
||||
return
|
||||
end
|
||||
local s = -1
|
||||
if math.random() > 0.5 then
|
||||
s = 1
|
||||
end
|
||||
minetest.add_particle({
|
||||
pos = {
|
||||
x = math.random() * s + pos.x,
|
||||
y = math.random() * s + pos.y,
|
||||
z = math.random() * s + pos.z
|
||||
},
|
||||
velocity = {
|
||||
x = math.random() * s,
|
||||
y = math.random() * s,
|
||||
z = math.random() * s
|
||||
},
|
||||
acceleration = {
|
||||
x = math.random() * s,
|
||||
y = math.random() * s,
|
||||
z = math.random() * s
|
||||
},
|
||||
expirationtime = 1,
|
||||
size = 2,
|
||||
texture = "xdecor_glyph" .. math.random(1, 18) .. ".png",
|
||||
})
|
||||
end
|
||||
-- if show_sound_traveller
|
||||
minetest.register_entity("gen_music:sound_traveller", {
|
||||
visual = "sprite",
|
||||
visual_size = {x = 0.5, y = 0.5},
|
||||
collisionbox = {0},
|
||||
physical = false,
|
||||
textures = {"empty.png"},--default_mese_crystal.png"},
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
--self.pos = self.object:get_pos()
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
--ps(self.pos)
|
||||
end,
|
||||
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
end,
|
||||
on_death = function(self, killer)
|
||||
end,
|
||||
on_rightclick = function(self, clicker)
|
||||
end,
|
||||
get_staticdata = function(self)
|
||||
end,
|
||||
})
|
||||
|
||||
gen_music.gs = function(object, song, loop)
|
||||
-- TODO Generate random sequence and ensemble based on
|
||||
-- found sounds, and extra_sounds.txt.
|
||||
if type(song) == "string" then
|
||||
song = gen_music.songs[song]
|
||||
end
|
||||
--print(dump(song))
|
||||
if not song then
|
||||
return
|
||||
end
|
||||
local gain = math.random()
|
||||
if gain > 0.67 then
|
||||
gain = 0.67
|
||||
end
|
||||
local play = minetest.sound_play
|
||||
local seq = {}
|
||||
local obj = {}
|
||||
if math.random() < 0.67 then
|
||||
minetest.after(math.random(), function()
|
||||
local p_pos = object:get_pos()
|
||||
if not p_pos then
|
||||
return
|
||||
end
|
||||
local jitter = function(j, p)
|
||||
local r = math.random()
|
||||
local s = j * -1
|
||||
if r > 0.5 then
|
||||
s = j * 1
|
||||
if math.random() > r then
|
||||
return p + (1 * s)
|
||||
else
|
||||
return p - (1 * s)
|
||||
end
|
||||
elseif math.random() < r then
|
||||
return p + (1 * s)
|
||||
else
|
||||
return p - (1 * s)
|
||||
end
|
||||
end
|
||||
p_pos.x = jitter(math.random(), p_pos.x)
|
||||
p_pos.y = jitter(math.random(), p_pos.y)
|
||||
p_pos.z = jitter(math.random(), p_pos.z)
|
||||
|
||||
local function play_variable(ensemble, positional)
|
||||
-- New object.
|
||||
local obj_idx = #obj + 1
|
||||
obj[obj_idx] = minetest.add_entity(p_pos,
|
||||
"gen_music:sound_traveller", "")
|
||||
local o_pos = obj[obj_idx]:get_pos()
|
||||
local d = vector.direction(p_pos, o_pos)
|
||||
d.x = jitter(math.random(), d.x)
|
||||
d.y = jitter(math.random(), d.y)
|
||||
d.z = jitter(math.random(), d.z)
|
||||
obj[obj_idx]:set_velocity(d)
|
||||
obj[obj_idx]:set_acceleration(d)
|
||||
|
||||
-- New sound attached to new object.
|
||||
local pitch = math.random()
|
||||
if math.random() > 0.5 or
|
||||
pitch > 0.66 then
|
||||
pitch = pitch - 0.5
|
||||
end
|
||||
local idx = #seq + 1
|
||||
local fade = math.random(1)
|
||||
local n
|
||||
if not ensemble then
|
||||
n = ""
|
||||
else
|
||||
n = ensemble[math.random(1, #song)]
|
||||
end
|
||||
seq[idx] = play(n, {
|
||||
gain = gain * 0.1,
|
||||
pitch = pitch * 1.33,
|
||||
fade = fade,
|
||||
object = obj[obj_idx],
|
||||
})
|
||||
--print("Starting " .. seq[idx])
|
||||
if fade == 1 then
|
||||
minetest.sound_fade(seq[idx], 0.1, gain)
|
||||
end
|
||||
end
|
||||
|
||||
local score = song.seq
|
||||
for i = 1, #score do
|
||||
local e = score[i]
|
||||
if e == "0" then
|
||||
minetest.after(math.random(), function()
|
||||
play_variable()
|
||||
end)
|
||||
else
|
||||
local g = song.ins[e]
|
||||
if g then
|
||||
minetest.after(math.random(), function()
|
||||
play_variable{g}
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- `Mese Music' by jas
|
||||
--[[
|
||||
if math.random() < 0.33 then
|
||||
play_variable({"phit", "phit", "phit", "phit"})
|
||||
minetest.after(math.random(), function()
|
||||
play_variable({"phit", "phit", "walkie_blip", "xdecor_enchanting", "mobs_spell"}, true)
|
||||
end)
|
||||
end
|
||||
if math.random() > 0.33 then
|
||||
minetest.after(math.random(), function()
|
||||
play_variable({"walkie_blip", "walkie_blip", "phit"}, true)
|
||||
end)
|
||||
end
|
||||
if math.random() > 0.5 then
|
||||
minetest.after(math.random(), function()
|
||||
play_variable({"xdecor_enchanting", "phit", "walkie_blip"}, false)
|
||||
end)
|
||||
end
|
||||
--]]
|
||||
|
||||
minetest.after(math.random(), function()
|
||||
for k, v in pairs(obj) do
|
||||
v:remove()
|
||||
end
|
||||
end)
|
||||
|
||||
end)
|
||||
end
|
||||
minetest.after(math.random(), function()
|
||||
for idx = 1, #seq do
|
||||
minetest.after(math.random(), function()
|
||||
--print("Stopping " .. seq[idx])
|
||||
minetest.sound_fade(seq[idx], -0.1, 0.0)
|
||||
minetest.after(math.random(), function()
|
||||
minetest.sound_stop(seq[idx])
|
||||
end)
|
||||
end)
|
||||
end
|
||||
if loop then
|
||||
if object:is_player() then
|
||||
local l = object:get_attribute("loop")
|
||||
if not l or l == "" then
|
||||
return
|
||||
end
|
||||
l = tonumber(l)
|
||||
object:set_attribute("loop", l - 1)
|
||||
if l == 0 then
|
||||
object:set_attribute("loop", nil)
|
||||
end
|
||||
minetest.after(math.random() + math.random(), function()
|
||||
gen_music.gs(object, song, loop)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("gs", {
|
||||
func = function(name, param)
|
||||
param = param:split(" ")
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if param[1] == "load" then
|
||||
--[[ -- TODO Mod security.
|
||||
if param[2] then
|
||||
local h = io.open(mod_path .. "/songs.txt", "a+")
|
||||
h:write(param[2])
|
||||
end
|
||||
--]]
|
||||
load_songs()
|
||||
end
|
||||
if param[1] == "stop" then
|
||||
player:set_attribute("loop", nil)
|
||||
return true, "This may take a moment."
|
||||
end
|
||||
local lc = param[2] or 3
|
||||
player:set_attribute("loop", tonumber(lc))
|
||||
gen_music.gs(minetest.get_player_by_name(name),
|
||||
param[1], true)
|
||||
end,
|
||||
})
|
|
@ -0,0 +1,9 @@
|
|||
walkie_blip,phit,xdecor_enchanting,mobs_spell
|
||||
|
||||
1 20
|
||||
1 10
|
||||
2 10
|
||||
1 10
|
||||
3 10
|
||||
4 30
|
||||
4 40
|
|
@ -0,0 +1,7 @@
|
|||
mysong1.txt
|
||||
dark.txt
|
||||
sombre.txt
|
||||
example1.txt
|
||||
example2.txt
|
||||
example3.txt
|
||||
example4.txt
|
After Width: | Height: | Size: 174 B |
After Width: | Height: | Size: 161 B |
After Width: | Height: | Size: 157 B |
After Width: | Height: | Size: 158 B |
After Width: | Height: | Size: 156 B |
After Width: | Height: | Size: 159 B |
After Width: | Height: | Size: 106 B |
After Width: | Height: | Size: 160 B |
After Width: | Height: | Size: 158 B |
After Width: | Height: | Size: 145 B |
After Width: | Height: | Size: 161 B |
After Width: | Height: | Size: 159 B |
After Width: | Height: | Size: 159 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 157 B |
After Width: | Height: | Size: 159 B |
After Width: | Height: | Size: 157 B |
After Width: | Height: | Size: 158 B |
After Width: | Height: | Size: 102 B |