Forums » StepMania Development » Making a sound play every time a key is pressed during gameplay

1
Hey all, not sure if this is the place to ask this, but I thought I'd see if some seasoned developers could help me a little.

I was working on making a slight modification to StepMania such that every time a key is pressed during gameplay (i.e. during a song) it triggers a certain sound. The mod is for an experiment on human computer interaction where we'll be testing effectiveness at performing a given task under a variety of conditions.

I was just wondering if anyone had advice on how best to accomplish this. I'm a little bit daunted by the size of this code base and I just don't know where to begin. Cheers!

Last edited: 18 November 2015 12:44am

Reply
Is the beat game mode appropriate for what you're doing? In that game mode, when the player hits a note at the right time, a sound tied to the key is played. The simfiles for that mode have to be specially crafted, and I don't think stepmania's editor can make them, and I don't know what editor people use. (I should get nixtrix in here, since he plays beat).

Or do you need something non-musical, where the sounds are unrelated to the song being played, and are just there as feedback that the key was pressed? Something like that can be done through the lua interface, though I don't know how much lag there is.

This is an example of how to do it as a decoration on gameplay:

local fake_key_sounds= {}
local function fake_key_sound_input(event)
if event.type ~= "InputEventType_FirstPress" then return end
if fake_key_sounds[event.button] then
fake_key_sounds[event.button]:play()
end
end

return Def.ActorFrame{
Def.Sound{
File= THEME:GetPathS("Common", "Cancel"), InitCommand= function(self)
fake_key_sounds.Left= self
end
},
Def.Sound{
File= THEME:GetPathS("Common", "Coin"), InitCommand= function(self)
fake_key_sounds.Right= self
end
},
Def.Sound{
File= THEME:GetPathS("Common", "invalid"), InitCommand= function(self)
fake_key_sounds.Down= self
end
},
Def.Sound{
File= THEME:GetPathS("Common", "value"), InitCommand= function(self)
fake_key_sounds.Up= self
end
},
Def.ActorFrame{
OnCommand= function(self)
SCREENMAN:GetTopScreen():AddInputCallback(fake_key_sound_input)
end
}
}


(though, actually getting it into a theme in a sane and working way can be difficult for a first timer)
< cybik> til Kyzentun fixes bugs for breakfast
--
< maxvg1> shakesoda: then why do i still play lol
<@shakesoda> because you're an ITG player. And thus, a masochist
--
<@shakesoda> Kyzentun: I think you might need to put down the meshes for a bit
Reply
Oh wow, looks like I was totally in the wrong area.

Sounds like lua scripting would fit my purpose, as the sounds will generally be neutral to the songs being played (think a 'ding' or 'buzz') and a little lag won't hurt the cause too badly.

I'll fiddle around for a bit and report back. Thanks so much for the advice!
Reply
So would you put the code in Themes\_fallback\Scripts\gameplay.lua?
Reply
It just occurred to me that I could probably just run a program in the background that'll accomplish this goal. So maybe that's what I'll try.
Reply
If you already know how to do what you want with a separate program, then it's easier to do it that way than to try to do it in stepmania.

The code I pasted was meant as an example that someone who knows the basics of theming could use for reference. It would go in BGAnimations/ScreenGameplay overlay.lua or similar. But using it right would require some care to avoid overriding the normal overlay in the theme.
< cybik> til Kyzentun fixes bugs for breakfast
--
< maxvg1> shakesoda: then why do i still play lol
<@shakesoda> because you're an ITG player. And thus, a masochist
--
<@shakesoda> Kyzentun: I think you might need to put down the meshes for a bit
Reply
Awesome, yeah, I'm just going to use SoundPlant to map sounds to keys and then run that in the background. Thanks for helping.
Reply