Page 1 of 1

Map DCSS key-presses to trigger audio clips in another app?

PostPosted: Sunday, 3rd May 2020, 01:59
by dolemite99
About six months ago I started tinkering with some digital audio workstation (DAW) software products that came bundled with a keyboard I bought. Ableton Live Lite and some entry-level version of ProTools, I think. Lots of MIDI features and the ability to 'trigger' an audio clip within the DAW software when a mapped key command comes in.

The 'trigger audio clips' function in Ableton got me wondering if anyone here found a way to trigger audio clips (from any kind of player/app/folder) while playing current/stable versions of DCSS? Play an Uskayaw character, use god ability (a) and trigger a huge low boom. Or some rapid double-bass drum hits, if you're a metal fan.

Re: Map DCSS key-presses to trigger audio clips in another a

PostPosted: Sunday, 3rd May 2020, 19:15
by Implojin
The post that used to be here suggested some bad approaches to this problem, skip ahead to vt's posts

If you want to play sounds entirely within Crawl, and you're willing to play locally, you can compile the game with SOUND=y , and conditionally fire sounds through Lua by calling crawl.playsound(filename). The downside of this is that you have to write some crawl lua, possibly quite a lot of crawl lua depending on the behavior you want: https://doc.dcss.io/modules/crawl.html#playsound

Otherwise, assuming you're on windows, you could try using autohotkey as an input wrapper and having ahk conditionally trigger sounds depending on the input: I haven't personally tried using autohotkey to play sounds, but https://www.autohotkey.com/docs/commands/SoundPlay.htm suggests that it has this capability.

Re: Map DCSS key-presses to trigger audio clips in another a

PostPosted: Sunday, 3rd May 2020, 19:44
by dolemite99
Thanks Implojin for the thorough suggestion list! I should have mentioned in my original post that I don’t have any programming experience in any language, so the lua work you mention is likely well beyond my aptitude to handle. :-).

I’ll take a peek @ AutoHotKey and see what I can learn. I guess conceptually, I am envisioning a technique where some minimized application is still able to “listen” to key commands I’m pressing for Webtiles in Chrome browser, or in the local client DCSS. Seems like whatever app this ends up being would ideally be the only minimized application to be listening for input commands. I think my lack of OS expertise is showing here too. :-). Thanks again.

Re: Map DCSS key-presses to trigger audio clips in another a

PostPosted: Sunday, 3rd May 2020, 19:51
by Implojin
dolemite99 wrote:I’ll take a peek @ AutoHotKey and see what I can learn. I guess conceptually, I am envisioning a technique where some minimized application is still able to “listen” to key commands I’m pressing for Webtiles in Chrome browser, or in the local client DCSS. Seems like whatever app this ends up being would ideally be the only minimized application to be listening for input commands. I think my lack of OS expertise is showing here too. :-). Thanks again.

:)
Autohotkey is probably the simplest option for doing this, by *far*, if you're on Windows. It's designed for that use case, I think.

AHK does require some basic scripting, but you can find tons of examples of basic AHK scripts with google.


Autohotkey is simple, but it's not the simplest way to do this, see below

Re: Map DCSS key-presses to trigger audio clips in another a

PostPosted: Monday, 4th May 2020, 03:18
by vt
Another idea is to look at how CWZ (the Korean server) does its sound module. From what I hear it parses the message log and makes a sound based on that. Based on how far it is from what you want you may be able to simply use it while changing its sound files out. At least it may provide a way forward.

If you proceed by playing sounds in response to player input you'll either have to settle for pretty limited accuracy to what's happening in-game, or keep careful track of game context in order to interpret the keypresses. (Say you press a. Did you open the ability screen, or select an item or a spell? Depends on whether you were at the inventory screen, or at the main screen and had just pressed z while knowing spells, or at the main screen without having just pressed z or anything like that. Say you press a then h from the main screen. Did you use an ability, move, or do nothing? It depends on whether you have any abilities, and if so, if any of them are on 'h'. Etc etc.) I can't help but suspect that this approach is more pain that it's worth, unless you really are happy with just having a boom play every time you press a, whatever the context.

Re: Map DCSS key-presses to trigger audio clips in another a

PostPosted: Monday, 4th May 2020, 04:00
by vt
Oh I meant to say: iirc Lua is pretty much designed to be a simple, small, easy-to-pick-up scripting language. Of course you might not want to put that much work into the project. But it's not that scary to pick up the basics of.

Re: Map DCSS key-presses to trigger audio clips in another a

PostPosted: Monday, 4th May 2020, 07:33
by Implojin
To play a sound on Uskayaw's stomp, edit the path below to the sound you want to use, and put this in your rcfile:

sound += shockwave through the revelers:path\to\sound.wav

See options_guide.txt for sound regex details:
https://github.com/crawl/crawl/blob/mas ... e.txt#L447

This works for me locally after compiling with TILES=y SOUND=y , your mileage may vary with non-tiles builds. For it to work online you'd need the server owner to compile with sound and host sound files, too, I think?

There is a limitation here: Adding sound += regexes to your rcfile can mostly only play sounds when actual message log text happens. (There are a small amount of special cases defined in sound.h that can trigger without matching message log text.)

If you want to play sounds for things that don't generate message log text and aren't in the list above, then you'd have to manually call crawl.playsound() (or manually generate a message and add a corresponding sound regex, I guess) -- but this isn't necessary for Uskayaw's stomp, because it already generates a unique message when the ability is used.