Jump to content

[1.0.5] Music Hack - custom soundtrack player


tay

Recommended Posts

Music Hack

I made a short kRPC script that plays music based on in-game events and figured I'd share it here and maybe get some feedback. It's an alternative to Soundtrack Editor for people low on memory. It'll also be easier to add new music events for people who'd rather not dive into full-on add-on development. I've found this better than the "mute and play space music" strategy I was using earlier.

Features

  • As an external program, no impact on game memory usage
  • Can play anything that VLC can play, such as Youtube URLs
  • Can play dramatic music during docking or rendezvous a la Interstellar
  • Play custom music while editing, above the atmosphere, at the space center, or at the tracking station, eg play the Normandy galaxy map theme at the tracking center
  • Play main menu music
  • Configurable via music.yaml
  • Comes with stock music

Requirements

  • Python 2.7 or later
  • LibVLC for Python (pip install python-vlc) - currently only supports 32 bit python
  • kRPC (pip install krpc)
  • PyYAML (pip install PyYAML)

Downloads

Github | Source

Configuration

  • Edit music.yaml
    • Individual files or directories with music inside are allowed
    • To disable music for a label, just delete all the bullets underneath it
    • Backslashes must be doubled for Windows style paths
  • Mute KSP music

Usage

  • Run the program (python music_hack.py or ./music_hack.py) and start the game, in whatever order
  • Start kRPC server (or set to autostart) after loading a save
  • Accept connection from KSP (or set KRPC server to auto-accept)
  • Crashes of the music player only require a restart of the music player

Limitations

  • Can only distinguish the tracking center. The rest of the space center scenes all play music from the space center label.
  • Doesn't come with stock tracking or main menu music (licensing limitations)
  • Can't play KSP theme when the program launches
  • Youtube playback depends on whether LibVLC has up-to-date Youtube capabilities.
  • Space music continues after switch to space center till next scene change.
Edited by tay
Update download link
Link to comment
Share on other sites

17 minutes ago, komodo said:

Spiffy! I always like to see pythonic things created (since it's about all I know how to program, haha... 

Nice program!

Thanks! Yeah, similar story here. Didn't want to get into the whole mono business :P

6 minutes ago, Enceos said:

Basically works like SoundSense for Dwarf Fortress? Neat.

Yup, good eye :) I might've been a little bit inspired by a music program I wrote for dwarf fortress after I gave up trying to make SoundSense work. I guess the same thing happened to me again with Soundtrack Editor. I'm actually thinking about a soundsense-like way to somehow use the KSP game log to figure out when to play the main menu music while waiting to connect to the kRPC server.

Link to comment
Share on other sites

@Enceos Wow, thanks for the heads up! This is exactly what I needed. Time to take a look at my game log monitoring code...

Edit: Okay, looks like the log file is buffered so it can't be reliably used for scene changes, but I'll see if I can get main menu music to work...

Edit: Main menu music is working!

Edited by tay
Update on findings
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...