mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-12-25 06:52:26 +01:00
Add pitch variations for most noteblock sounds (#535)
This commit is contained in:
parent
6890624f3d
commit
54de66b3e1
15
mesecons_noteblock/README.txt
Normal file
15
mesecons_noteblock/README.txt
Normal file
@ -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/
|
@ -6,8 +6,8 @@ This effector makes a sound if powered and can be used for making music. Normall
|
||||
<tr><td>Chest or Locked Chest</td><td>Snare</td></tr>
|
||||
<tr><td>Any tree</td><td>Crash</td></tr>
|
||||
<tr><td>Any wooden planks</td><td>Lite Crash</td></tr>
|
||||
<tr><td>Coal Block</td><td>Explosion sound</td></tr>
|
||||
<tr><td>Lava Source</td><td>Fire sound</td></tr>
|
||||
<tr><td>Coal Block</td><td>Explosion sound (fixed pitch)</td></tr>
|
||||
<tr><td>Lava Source</td><td>Fire sound (fixed pitch)</td></tr>
|
||||
<tr><td>Steel Block</td><td>Piano (high pitch, one octave higher than normal)</td></tr>
|
||||
<tr><td>Any other block</td><td>Piano (low pitch)</td></tr>
|
||||
</table>
|
||||
|
@ -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
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user