Skip to content

Commit b9cb5c4

Browse files
committed
Add pitch variations for most noteblock sounds
1 parent fedbf49 commit b9cb5c4

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

mesecons_noteblock/README.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Credits of sound files:
2+
3+
Note: Most sounds have not been used verbatim, but tweaked a little to be more suitable for the noteblock mod.
4+
5+
* mesecons_noteblock_litecrash.ogg
6+
* License: CC BY 3.0
7+
* by freesound.org user ani_music
8+
* Source: https://freesound.org/people/ani_music/sounds/219612/
9+
10+
Everything else:
11+
Created by Mesecons authors, licensed CC BY 3.0.
12+
13+
--------------------
14+
License links:
15+
* CC BY 3.0: http://creativecommons.org/licenses/by/3.0/

mesecons_noteblock/doc/noteblock/description.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<tr><td>Chest or Locked Chest</td><td>Snare</td></tr>
77
<tr><td>Any tree</td><td>Crash</td></tr>
88
<tr><td>Any wooden planks</td><td>Lite Crash</td></tr>
9-
<tr><td>Coal Block</td><td>Explosion sound</td></tr>
10-
<tr><td>Lava Source</td><td>Fire sound</td></tr>
9+
<tr><td>Coal Block</td><td>Explosion sound (fixed pitch)</td></tr>
10+
<tr><td>Lava Source</td><td>Fire sound (fixed pitch)</td></tr>
1111
<tr><td>Steel Block</td><td>Piano (high pitch, one octave higher than normal)</td></tr>
1212
<tr><td>Any other block</td><td>Piano (low pitch)</td></tr>
1313
</table>

mesecons_noteblock/init.lua

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ mesecon.noteblock_play = function(pos, param2)
6161
pos.y = pos.y-1
6262
local nodeunder = minetest.get_node(pos).name
6363
local soundname = node_sounds[nodeunder]
64+
local pitch
65+
-- Special sounds
66+
if not soundname then
67+
for k,v in pairs(node_sounds_group) do
68+
local g = minetest.get_item_group(nodeunder, k)
69+
if g ~= 0 then
70+
soundname = v
71+
break
72+
end
73+
end
74+
end
75+
-- Piano
6476
if not soundname then
6577
for k,v in pairs(node_sounds_group) do
6678
local g = minetest.get_item_group(nodeunder, k)
@@ -79,13 +91,26 @@ mesecon.noteblock_play = function(pos, param2)
7991
if nodeunder == "default:steelblock" then
8092
soundname = soundname.. 2
8193
end
94+
pitch = false
95+
end
96+
-- Disable pitch for fire and explode because they'd sound too odd
97+
if soundname == "fire_fire" or soundname == "tnt_explode" then
98+
pitch = false
99+
end
100+
if pitch == false then
101+
pitch = nil
102+
else
103+
-- Calculate pitch
104+
local val = (param2+1)%12
105+
-- All semitones from C to B (analog to piano mode)
106+
pitch = 2^((val-6)/12)
82107
end
83108
pos.y = pos.y+1
84109
if soundname == "fire_fire" then
85110
-- Smoothly fade out fire sound
86111
local handle = minetest.sound_play(soundname, {pos = pos, loop = true})
87112
minetest.after(3.0, minetest.sound_fade, handle, -1.5, 0.0)
88113
else
89-
minetest.sound_play(soundname, {pos = pos}, true)
114+
minetest.sound_play(soundname, {pos = pos, pitch = pitch}, true)
90115
end
91116
end
-2.76 KB
Binary file not shown.

0 commit comments

Comments
 (0)