diff --git a/mesecons_noteblock/README.txt b/mesecons_noteblock/README.txt
new file mode 100644
index 0000000..e0ad34c
--- /dev/null
+++ b/mesecons_noteblock/README.txt
@@ -0,0 +1,15 @@
+Credits of sound files:
+
+Note: Most sounds have not been used verbatim, but tweaked a little to be more suitable for the noteblock mod.
+
+* mesecons_noteblock_litecrash.ogg
+ * License: CC BY 3.0
+ * by freesound.org user ani_music
+ * Source: https://freesound.org/people/ani_music/sounds/219612/
+
+Everything else:
+Created by Mesecons authors, licensed CC BY 3.0.
+
+--------------------
+License links:
+* CC BY 3.0: http://creativecommons.org/licenses/by/3.0/
diff --git a/mesecons_noteblock/doc/noteblock/description.html b/mesecons_noteblock/doc/noteblock/description.html
index e11724d..a98c0f9 100644
--- a/mesecons_noteblock/doc/noteblock/description.html
+++ b/mesecons_noteblock/doc/noteblock/description.html
@@ -6,8 +6,8 @@ This effector makes a sound if powered and can be used for making music. Normall
Chest or Locked Chest | Snare |
Any tree | Crash |
Any wooden planks | Lite Crash |
-Coal Block | Explosion sound |
-Lava Source | Fire sound |
+Coal Block | Explosion sound (fixed pitch) |
+Lava Source | Fire sound (fixed pitch) |
Steel Block | Piano (high pitch, one octave higher than normal) |
Any other block | Piano (low pitch) |
diff --git a/mesecons_noteblock/init.lua b/mesecons_noteblock/init.lua
index 4080478..847c40b 100644
--- a/mesecons_noteblock/init.lua
+++ b/mesecons_noteblock/init.lua
@@ -20,6 +20,7 @@ minetest.register_node("mesecons_noteblock:noteblock", {
mesecon.noteblock_play(pos, node.param2)
end
}},
+ place_param2 = 11, -- initialize at C note
on_blast = mesecon.on_blastnode,
})
@@ -45,7 +46,7 @@ local soundnames = {
"mesecons_noteblock_a",
"mesecons_noteblock_asharp",
"mesecons_noteblock_b",
- "mesecons_noteblock_c"
+ "mesecons_noteblock_c" -- << noteblock is initialized here
}
local node_sounds = {}
@@ -74,6 +75,9 @@ mesecon.noteblock_play = function(pos, param2)
pos.y = pos.y-1
local nodeunder = minetest.get_node(pos).name
local soundname = node_sounds[nodeunder]
+ local use_pitch = true
+ local pitch
+ -- Special sounds
if not soundname then
for k,v in pairs(node_sounds_group) do
local g = minetest.get_item_group(nodeunder, k)
@@ -83,6 +87,7 @@ mesecon.noteblock_play = function(pos, param2)
end
end
end
+ -- Piano
if not soundname then
soundname = soundnames[param2]
if not soundname then
@@ -92,6 +97,17 @@ mesecon.noteblock_play = function(pos, param2)
if nodeunder == steelblock_nodename then
soundname = soundname.. 2
end
+ use_pitch = false
+ end
+ -- Disable pitch for fire and explode because they'd sound too odd
+ if soundname == "fire_fire" or soundname == "tnt_explode" then
+ use_pitch = false
+ end
+ if use_pitch then
+ -- Calculate pitch
+ -- Adding 1 to param2 because param2=11 is *lowest* pitch sound
+ local val = (param2+1)%12
+ pitch = 2^((val-6)/12)
end
pos.y = pos.y+1
if soundname == "fire_fire" then
@@ -99,6 +115,6 @@ mesecon.noteblock_play = function(pos, param2)
local handle = minetest.sound_play(soundname, {pos = pos, loop = true})
minetest.after(3.0, minetest.sound_fade, handle, -1.5, 0.0)
else
- minetest.sound_play(soundname, {pos = pos}, true)
+ minetest.sound_play(soundname, {pos = pos, pitch = pitch}, true)
end
end
diff --git a/mesecons_noteblock/sounds/mesecons_noteblock_litecrash.ogg b/mesecons_noteblock/sounds/mesecons_noteblock_litecrash.ogg
index 79ab256..36d83f3 100644
Binary files a/mesecons_noteblock/sounds/mesecons_noteblock_litecrash.ogg and b/mesecons_noteblock/sounds/mesecons_noteblock_litecrash.ogg differ