diff --git a/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua index a6b59df911..342cbc7c07 100644 --- a/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua @@ -3,7 +3,7 @@ local S = minetest.get_translator("mesecons_noteblock") minetest.register_node("mesecons_noteblock:noteblock", { description = S("Note Block"), _doc_items_longdesc = S("A note block is a musical block which plays one of many musical notes and different intruments when it is punched or supplied with redstone power."), - _doc_items_usagehelp = S("Rightclick the note block to choose the next musical note (there are 24 half notes, or 2 octaves). The intrument played depends on the material of the block below the note block:").."\n\n".. + _doc_items_usagehelp = S("Use the note block to choose the next musical note (there are 25 semitones, or 2 octaves). The intrument played depends on the material of the block below the note block:").."\n\n".. S("• Glass: Sticks").."\n".. S("• Wood: Bass guitar").."\n".. @@ -22,7 +22,7 @@ S("The note block will only play a note when it is below air, otherwise, it stay minetest.record_protection_violation(pos, protname) return end - node.param2 = (node.param2+1)%24 + node.param2 = (node.param2+1)%25 mesecon.noteblock_play(pos, node.param2) minetest.set_node(pos, node) end, @@ -82,6 +82,8 @@ local soundnames_piano = { "mesecons_noteblock_asharp2", "mesecons_noteblock_b2", + -- TODO: Add dedicated sound file? + "mesecons_noteblock_b2", } mesecon.noteblock_play = function (pos, param2) @@ -91,24 +93,32 @@ mesecon.noteblock_play = function (pos, param2) return end - -- Default: One of 24 piano notes - local soundname = soundnames_piano[param2] - local block_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name - - if minetest.get_item_group(block_below_name, "material_glass") ~= 0 then - -- TODO: 24 sticks and clicks - soundname="mesecons_noteblock_temp_stick" - elseif minetest.get_item_group(block_below_name, "material_wood") ~= 0 then - -- TODO: 24 bass guitar sounds - soundname="mesecons_noteblock_temp_bass_guitar" - elseif minetest.get_item_group(block_below_name, "material_sand") ~= 0 then - -- TODO: 24 snare drum sounds - soundname="mesecons_noteblock_temp_snare" - elseif minetest.get_item_group(block_below_name, "material_stone") ~= 0 then - -- TODO: 24 bass drum sounds - soundname="mesecons_noteblock_temp_kick" + local param2_to_pitch = function(param2) + return 2^((param2-12)/12) end + local soundname, pitch + if minetest.get_item_group(block_below_name, "material_glass") ~= 0 then + soundname="mesecons_noteblock_stick" + pitch = param2_to_pitch(param2) + elseif minetest.get_item_group(block_below_name, "material_wood") ~= 0 then + soundname="mesecons_noteblock_bass_guitar" + pitch = param2_to_pitch(param2) + elseif minetest.get_item_group(block_below_name, "material_sand") ~= 0 then + soundname="mesecons_noteblock_snare" + pitch = param2_to_pitch(param2) + elseif minetest.get_item_group(block_below_name, "material_stone") ~= 0 then + soundname="mesecons_noteblock_kick" + pitch = param2_to_pitch(param2) + else + -- Default: One of 25 piano notes + soundname = soundnames_piano[param2] + -- Workaround: Final sound gets automatic higher pitch instead + if param2 == 24 then + pitch = 2^(1/12) + end + end + minetest.sound_play(soundname, - {pos = pos, gain = 1.0, max_hear_distance = 48,}) + {pos = pos, gain = 1.0, max_hear_distance = 48, pitch = pitch}) end diff --git a/mods/ITEMS/REDSTONE/mesecons_noteblock/locale/mesecons_noteblock.de.tr b/mods/ITEMS/REDSTONE/mesecons_noteblock/locale/mesecons_noteblock.de.tr index c107bd5dc5..272823969a 100644 --- a/mods/ITEMS/REDSTONE/mesecons_noteblock/locale/mesecons_noteblock.de.tr +++ b/mods/ITEMS/REDSTONE/mesecons_noteblock/locale/mesecons_noteblock.de.tr @@ -1,7 +1,7 @@ # textdomain: mesecons_noteblock Note Block=Notenblock A note block is a musical block which plays one of many musical notes and different intruments when it is punched or supplied with redstone power.=Ein Notenblock ist ein musikalischer Block, der eine von vielen Noten von verschiedenen Instrumenten spielt, wenn er geschlagen oder mit Redstoneenergie versorgt wird. -Use the note block to choose the next musical note (there are 24 half notes, or 2 octaves). The intrument played depends on the material of the block below the note block:=Benutzen Sie den Notenblock, um die nächste Note zu wählen (es gibt 24 halbe Noten bzw. 2 Oktaven). Das gespielte Intrument hängt vom Material des Blocks unter dem Notenblock ab: +Use the note block to choose the next musical note (there are 25 semitones, or 2 octaves). The intrument played depends on the material of the block below the note block:=Benutzen Sie den Notenblock, um die nächste Musiknote zu wählen (es gibt 25 Halbtöne, oder 2 Oktaven). Das gespielte Instrument hängt vom Material des Blocks unter dem Notenblock ab: • Glass: Sticks=• Glas: Stöcke • Wood: Bass guitar=• Holz: Bassgitarre • Stone: Bass drum=• Stein: Basstrommel diff --git a/mods/ITEMS/REDSTONE/mesecons_noteblock/locale/template.txt b/mods/ITEMS/REDSTONE/mesecons_noteblock/locale/template.txt index 95803f6667..c1d7dc02fa 100644 --- a/mods/ITEMS/REDSTONE/mesecons_noteblock/locale/template.txt +++ b/mods/ITEMS/REDSTONE/mesecons_noteblock/locale/template.txt @@ -1,7 +1,7 @@ # textdomain: mesecons_noteblock Note Block= A note block is a musical block which plays one of many musical notes and different intruments when it is punched or supplied with redstone power.= -Use the note block to choose the next musical note (there are 24 half notes, or 2 octaves). The intrument played depends on the material of the block below the note block:= +Use the note block to choose the next musical note (there are 25 semitones, or 2 octaves). The intrument played depends on the material of the block below the note block:= • Glass: Sticks= • Wood: Bass guitar= • Stone: Bass drum= diff --git a/mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_temp_bass_guitar.ogg b/mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_bass_guitar.ogg similarity index 100% rename from mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_temp_bass_guitar.ogg rename to mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_bass_guitar.ogg diff --git a/mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_temp_kick.ogg b/mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_kick.ogg similarity index 100% rename from mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_temp_kick.ogg rename to mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_kick.ogg diff --git a/mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_temp_snare.ogg b/mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_snare.ogg similarity index 100% rename from mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_temp_snare.ogg rename to mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_snare.ogg diff --git a/mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_temp_stick.ogg b/mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_stick.ogg similarity index 100% rename from mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_temp_stick.ogg rename to mods/ITEMS/REDSTONE/mesecons_noteblock/sounds/mesecons_noteblock_stick.ogg