Page 1 of 1

How to bind songs to keys

Posted: Sat Feb 07, 2009 3:43 am
by Renegade
Although one of the best features of HLDJ is using the console interface, some times this can get tedious, especially if the moment is ripe for a particular song, so here's the definitive tutorial on how to bind a key to a song for quick access.

1) creating binds:
Some people simply bind keys to song numbers. Sure, it's simple & easy in the short-term, but if the numbers should ever change (i.e. if you add/remove songs) it can be problematic. The recommended method is to use the absolute binding technique as explained in HLDJ's in-game help message #3 (enter 'hldj3' in console). This method is briefly outlined below:

Code: Select all

bind <key> "bind <command relay key> >$\<relative*path*to*file>; hldjsf"
where:
<key> is the desired bind key
<command relay key> is the one set in HLDJ's advanced setup (default is '=')
> tells HLDJ to load the file/folder exactly - no search is performed. (optional, but more effecient)
$ tells HLDJ that the path provided is relative to your audio folder. (optional, but saves you typing)
* must be used instead of spaces in the path due to limitations in HL's bind syntax
; is a separator between commands
hldjsf tells HLDJ that the path points to a file (use hldjsd for a directory)

Here are some examples:

Code: Select all

bind x "bind = >$\voices\simpsons\homer.wav; hldjsf"
bind y "bind = >$\voices\simpsons\homer; hldjsf"        // note the ".wav" is optional
bind a "bind = >$\music\some*album\track1.wav; hldjsf"  // note the space is replaced by *
bind b "bind = >$\music\some*album\; hldjsd"
// binds a directory. note the '\' at the end and 'hldjsd'
Much more details on the advanced binds can be found in the in-game help.

2) using them in a script
Once you've got the hang of the above technique, create your binds and place them in a config file, possibly your hldj_custom.cfg or the game's autoexec/userconfig, so that they are loaded on start-up.
So is that all there is to it? Yes - if you don't mind using your keys for audio binds, but many players use nearly all their keys for the game, which is where dynamic binding comes into play...

3) dynamically binding your keys
To make the best use of your keys, you can rebind the same keys to different actions dynamically, like so:
Create a config file, i.e. "my_hldj_binds.cfg", and place all of your audio binds into this file.
In another config file, i.e. "my_default_binds.cfg", place all of your original game binds (alternatively you can also just use your game's config.cfg).
You'll want to place the first file in your custom folder so that it is copied to the game directory on start-up. Also, if the keys you use have different meanings in different games, you'll want create and place a default bind config in each game's config folder (or as mentioned above, just use the game's config.cfg).

Next, bind a key to "exec my_hldj_binds.cfg" and one to "exec my_default_binds.cfg".
Now you can use these keys to switch between your audio binds and game binds easily!

You can leave it at that, or if you've got the hang of scripting you can really start to get creative. For example, you can use a single key to toggle between your binds, or use the +/- aliases to load the configs on key-down/key-up presses:

Code: Select all

alias +mybinds "exec my_hldj_binds.cfg"    // executes songs binds when you press & hold
alias -mybinds "exec my_default_binds.cfg" // executes default binds on release
Just bind a key to "mybinds" (again, you can place this code into your custom config) and hold it down to activate your audio binds, and release to deactivate them.


so 128 keys aren't enough?...
If you still need more binds keys (!?), you can create multiple config files (as above) to map more keys to songs.
The ultimate solution (overkill) is to have key mappings for your key mappings. For example, you could create a config, i.e. "my_keymappings.cfg" that binds a set of keys to exec your various other configs:

Code: Select all

bind 1 "exec my_hldj_binds1.cfg"
bind 2 "exec my_hldj_binds2.cfg"
//...
bind N "exec my_hldj_bindsN.cfg"
After binding a key to exec this file, it will rebind the above keys to exec another config that will re-map your keys to audio binds (again, you can alter it so that it's done on key-down/up presses).
This technique ultimately allows you to bind an infinite amount of keys, but of course this is the extreme case and who would actually want to remember so many binds?? :lol: [/size]

Re: How to bind songs to keys

Posted: Fri Jan 22, 2010 7:33 pm
by Leafblower29
WOw thx i came t othe forum just for this thread :D

Re: How to bind songs to keys

Posted: Mon Mar 15, 2010 10:01 am
by ivrytwr3
OK, i need a bit of help here. HLDJ works in game for me for indivual binds, but i would like to set up different keys to different binds, but it ain't working. This is what i am trying, whaere have i gone wrong?!

bind UPARROW "bind MOUSE4 >C:\Users\The xxxxx Family\Desktop\games\hldj\hldj_1.5.02b\HLDJ\@Stanlio&Ollio.wav; hldjsf"

(mouse4 works with sample audio and my audio files ingame).

Re: How to bind songs to keys

Posted: Mon Mar 15, 2010 10:59 pm
by Renegade
You forgot to replace spaces (" ") in the file path with "*". It should look like:

Code: Select all

bind UPARROW "bind MOUSE4 >C:\Users\The*xxxxx*Family\Desktop\games\hldj\hldj_1.5.02b\HLDJ\@Stanlio&Ollio.wav; hldjsf"
It's a common mistake, but you'll notice it right away if the game complains about your syntax (the game engine cannot handle spaces in command arguments)

Another tip is that you should try to specify the path relative to your audio directory. For exmaple, if your Audio Directory were "C:\Users\The*xxxxx*Family\Desktop\games\hldj\hldj_1.5.02b\HLDJ", then the better bind would be:

Code: Select all

bind UPARROW "bind MOUSE4 >$\@Stanlio&Ollio.wav; hldjsf"

Re: How to bind songs to keys

Posted: Thu Jun 17, 2010 4:18 am
by Itachi
Renegade wrote:For exmaple, if your Audio Directory were "C:\Users\The*xxxxx*Family\Desktop\games\hldj\hldj_1.5.02b\HLDJ", then the better bind would be:

Code: Select all

bind UPARROW "bind MOUSE4 >$\@Stanlio&Ollio.wav; hldjsf"
Do you mean the audio directory is "C:\Users\The*xxxxx*Family\Desktop\games\hldj\hldj_1.5.02b\HLDJ\Audio"? I am having trouble getting my binds to work and I think the problem may be simply location. That Audio folder is there by default right? In the ">$\" binds, I have tried using them both with and without "\Audio" to no avail.

Re: How to bind songs to keys

Posted: Thu Jun 17, 2010 4:52 pm
by Renegade
'$' points to whatever Audio Directory has been set for the game. For example, if your audio directory is "C:\HLDJ\Audio" and you want to load "My Audio.wav", you would use ">$\My*Audio.wav" (not ">$\Audio\My*Audio.wav"). For backwards compatibility, it should work with and without the backslash after '$', but it's always better to include it.

Re: How to bind songs to keys

Posted: Sun Sep 19, 2010 8:06 pm
by Mannosuke
I can't seem to get mine to work. F1 is my broadcast key, and I'm trying to set up F3 to be bound to a certain song. I entered:

bind F3 "bind = >G:\TF2*Micspam\ahaha.wav; hldjsf"

And upon pressing F3, I receive this message in console:

bind <key> [command] : attach a command to a key
Host_WriteConfiguration: Wrote cfg/hldj_cmd_c.cfg

F1 continues to be bound to the previous song I selected normally with no change. Each time I press F3 it doesn't do anything but write a new config file. Could you help me out?

Re: How to bind songs to keys

Posted: Sun Sep 19, 2010 8:12 pm
by Renegade
It has been noticed that the ":" character causes problems for certain games. The next release will fix this by allowing the use of "|" in place of ":"; until then, use a path that avoids this char, i.e. use "$" to load from the audio dir, or "\" to load from the root dir.

Re: How to bind songs to keys

Posted: Sun Sep 19, 2010 10:15 pm
by Mannosuke
Yep, that fixed it. Thanks a lot.

Re: How to bind songs to keys

Posted: Wed Sep 29, 2010 3:00 pm
by Paralyze
I'm having trouble using the dramatic method of binding keys to open
a cfg file. I'm using one of my cfg files in the hldj custom folder and
the other is the autoexec from the game. Do the cfg files have to be
in the same folder or in differen't places? I'm really confused, need
some help here.

I use these commands as written is there any problems here?
because i've tried to put the binds in the cfg files but in game
they wont execute.

bind + "exec hldj_custom.cfg"
bind - "exec autoexec.cfg"

Re: How to bind songs to keys

Posted: Wed Sep 29, 2010 5:16 pm
by Renegade
You probably want to exec config.cfg not autoexec.cfg.
Secondly, you'll want to place your audio binds in a separate file other than hldj_custom.cfg, Follow the guidelines in #3.

Re: How to bind songs to keys

Posted: Wed Sep 29, 2010 7:05 pm
by Paralyze
Thanks, had to use another cfg file other than custom.