mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 20:41:11 +01:00
Add sound pitch for other noteblock sounds
This commit is contained in:
parent
95d2465901
commit
b44f4f456d
7 changed files with 31 additions and 21 deletions
|
@ -3,7 +3,7 @@ local S = minetest.get_translator("mesecons_noteblock")
|
||||||
minetest.register_node("mesecons_noteblock:noteblock", {
|
minetest.register_node("mesecons_noteblock:noteblock", {
|
||||||
description = S("Note Block"),
|
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_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("• Glass: Sticks").."\n"..
|
||||||
S("• Wood: Bass guitar").."\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)
|
minetest.record_protection_violation(pos, protname)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
node.param2 = (node.param2+1)%24
|
node.param2 = (node.param2+1)%25
|
||||||
mesecon.noteblock_play(pos, node.param2)
|
mesecon.noteblock_play(pos, node.param2)
|
||||||
minetest.set_node(pos, node)
|
minetest.set_node(pos, node)
|
||||||
end,
|
end,
|
||||||
|
@ -82,6 +82,8 @@ local soundnames_piano = {
|
||||||
"mesecons_noteblock_asharp2",
|
"mesecons_noteblock_asharp2",
|
||||||
"mesecons_noteblock_b2",
|
"mesecons_noteblock_b2",
|
||||||
|
|
||||||
|
-- TODO: Add dedicated sound file?
|
||||||
|
"mesecons_noteblock_b2",
|
||||||
}
|
}
|
||||||
|
|
||||||
mesecon.noteblock_play = function (pos, param2)
|
mesecon.noteblock_play = function (pos, param2)
|
||||||
|
@ -91,24 +93,32 @@ mesecon.noteblock_play = function (pos, param2)
|
||||||
return
|
return
|
||||||
end
|
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
|
local block_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||||
|
local param2_to_pitch = function(param2)
|
||||||
if minetest.get_item_group(block_below_name, "material_glass") ~= 0 then
|
return 2^((param2-12)/12)
|
||||||
-- 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"
|
|
||||||
end
|
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,
|
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
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# textdomain: mesecons_noteblock
|
# textdomain: mesecons_noteblock
|
||||||
Note Block=Notenblock
|
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.
|
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
|
• Glass: Sticks=• Glas: Stöcke
|
||||||
• Wood: Bass guitar=• Holz: Bassgitarre
|
• Wood: Bass guitar=• Holz: Bassgitarre
|
||||||
• Stone: Bass drum=• Stein: Basstrommel
|
• Stone: Bass drum=• Stein: Basstrommel
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# textdomain: mesecons_noteblock
|
# textdomain: mesecons_noteblock
|
||||||
Note Block=
|
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.=
|
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=
|
• Glass: Sticks=
|
||||||
• Wood: Bass guitar=
|
• Wood: Bass guitar=
|
||||||
• Stone: Bass drum=
|
• Stone: Bass drum=
|
||||||
|
|
Loading…
Reference in a new issue