TheUltimateKerbonaut

[1.4.4] - [1.6.1] Mono Map (map audio equalizer)

Recommended Posts

Description

MonoMap is a simple KSP mod that disabled 3D sound whilst in the map view. In other words, you get the same sound in both ears, instead of just one. Also the volume changes slightly, just a side effect.

Installation

The mod will most likely work with any version of KSP after 1.4.4 (don't quote me no that though). Install like any other mod; download file and drag contents to the GameData folder.
Download here.

(Source code can also be found on GitHub)

Credit

Thanks to forum user Morog for original idea

License

Standard MIT license. See GitHub page or download mod for details.

Edited by TheUltimateKerbonaut
Changed version

Share this post


Link to post
Share on other sites

Awesome!  I hate switching to map view and blowing out my speakers.

 

I have a suggestion for the next version.  The way it's currently implemented will cause a very small but constant CPU slowdown, since it's checking every audio source every frame.   Instead of using Update(), you could implement this with event-driven programming.  It looks like there are events for entering and exiting the map:

static EventVoid  OnMapEntered = new EventVoid("OnMapEntered")
 
static EventVoid  OnMapExited = new EventVoid("OnMapExited")

You can capture those, and just run your code when one of those is triggered.  Basically in Awake() or Start(), you'd do something like

GameEvents.onMapEntered.Add(turnOffSound);
GameEvents.onMapExited.Add(turnOnSound);

You'd then make two new functions, names turnOffSound and turnOnSound, which would just be the two branches of your "if" statement.

Share this post


Link to post
Share on other sites
On 6/6/2018 at 1:15 PM, hab136 said:

Awesome!  I hate switching to map view and blowing out my speakers.

 

I have a suggestion for the next version.  The way it's currently implemented will cause a very small but constant CPU slowdown, since it's checking every audio source every frame.   Instead of using Update(), you could implement this with event-driven programming.  It looks like there are events for entering and exiting the map:

static EventVoid  OnMapEntered = new EventVoid("OnMapEntered")
 
static EventVoid  OnMapExited = new EventVoid("OnMapExited")

You can capture those, and just run your code when one of those is triggered.  Basically in Awake() or Start(), you'd do something like


GameEvents.onMapEntered.Add(turnOffSound);
GameEvents.onMapExited.Add(turnOnSound);

You'd then make two new functions, names turnOffSound and turnOnSound, which would just be the two branches of your "if" statement.

I've never used events before (wasn't really aware of them), but now you've told me about them I'll definitely modify the code to incorporate them and save on CPU usage. Thank you :cool:!

Note: I'm currently on holiday at the moment so I will have to update the code in around 4 days time.

Edited by TheUltimateKerbonaut

Share this post


Link to post
Share on other sites

Hmmm... tried implementing your recommended event-based system, but for some reason it didn't work. In my start function, I have the following code:

void Start()
{
  GameEvents.OnMapEntered.Add(Disable3DSound);
  GameEvents.OnMapExited.Add(Enable3DSound);
  Debug.Log(NAME + " " + VERSION + " initialized");
}

and in the Enable3DSound and Disable3DSound functions respectively:

void Enable3DSound()
{
  Debug.Log(NAME + ": 3D Sound Enabled");
  // Find all audio sources
  foreach (AudioSource a in FindObjectsOfType(typeof(AudioSource)) as AudioSource[])
  {
    // Enable 3D sound
    a.spatialBlend = 1.0f;
  }
}

void Disable3DSound()
{
  Debug.Log(NAME + ": 3D Sound Disabled");
  // Find all audio sources
  foreach (AudioSource a in FindObjectsOfType(typeof(AudioSource)) as AudioSource[])
  {
  // Disable 3D sound
  a.spatialBlend = 0.0f;
  }
}

I did a few Debug.Logs() messages inside the foreach loops and based on that I can confirm for a fact that all my code is indeed being executed, and yet the code seems to have no effect on the audio whatsoever.

I'm running on a stock install, so the only explanation I can think of is that KSP enables 3D audio every frame, which unfortunately means I'll have to use my old, lazy method of just running my code in the Update() function. Am I making a really big mistake here, or am I doing everything correctly? :(

Share this post


Link to post
Share on other sites

There are no releases available on the github for this, does anyone have a copy?

EDIT: nvm, found it on spacedock....testing in 1.6.1....if I don't post here again assume I have not found any bugs.

Edited by Errol

Share this post


Link to post
Share on other sites
1 hour ago, Errol said:

There are no releases available on the github for this, does anyone have a copy?

EDIT: nvm, found it on spacedock....testing in 1.6.1....if I don't post here again assume I have not found any bugs.

I'm sure the dll will run, but does it actually make the sound mono for you? IIRC it never worked for me before.

Share this post


Link to post
Share on other sites
6 hours ago, Errol said:

There are no releases available on the github for this, does anyone have a copy?

EDIT: nvm, found it on spacedock....testing in 1.6.1....if I don't post here again assume I have not found any bugs.

Actually, I believe the one you found on SD is a completly different, tho similar, mod...

And it looks like the way @TheUltimateKerbonaut setup the github repo, the compiled .dll *is* right there in the master, along with the source code.
Could try grabbing the whole master, and just install the MonoMap folder... vOv

If you try it, let us know if it worx ... since this mod seems to be newer than the one I linked to above

Edited by Stone Blue

Share this post


Link to post
Share on other sites
On 2/21/2019 at 1:46 PM, Stone Blue said:

Actually, I believe the one you found on SD is a completly different, tho similar, mod...

And it looks like the way @TheUltimateKerbonaut setup the github repo, the compiled .dll *is* right there in the master, along with the source code.
Could try grabbing the whole master, and just install the MonoMap folder... vOv

If you try it, let us know if it worx ... since this mod seems to be newer than the one I linked to above

You are right, what I did find was the mod you linked there, and it does not work, while this one, does in fact work. At least so far, we'll see as I continue adding in mods.

Share this post


Link to post
Share on other sites

Sorry I haven't been responding, I hardly ever check my emails. Does the mod still work for 1.6.1, or shall I recompile it for the latest version?

Share this post


Link to post
Share on other sites
9 hours ago, TheUltimateKerbonaut said:

Sorry I haven't been responding, I hardly ever check my emails. Does the mod still work for 1.6.1, or shall I recompile it for the latest version?

Yes it does.

Share this post


Link to post
Share on other sites

Oh ok, that's fine then. Would it be safe to change the forum post to say [1.6.1] instead of [1.4.4], as well as with the GitHub repo?

Share this post


Link to post
Share on other sites
Posted (edited)

@TheUltimateKerbonaut wait... what does this mod do, actually? ... description in OP is a little vague.

I just tried it, and it seems to take the stock mono audio, and split it to *both* speakers (tho not true "stereo", which is fine)... it also seems to decrease the volume, "normalizing" the volume between speakers (to a moar acceptable level :P ) vOv

If *that* is what this mod does, then, yes, it is working in 1.6.1 ;)

Also, if that *is* what this mod does, may I suggest a name change?  something like "MapView Audio Equalizer", or "MapView Audio Leveler", "MapView Mono Fixer" or somthing?

MonoMap can be easily confused with the other similarly named mod which i mentioned in eartlier post. Also "MonoMap" doesnt really clue people in that its for the audio... vOv

Just my humble two-cents worth :P

Thanx for providing this mod, tho... now that I (think) I know what it does, it will be on my top "Must Have, Quality of Life" mods in all of my installs ;)

Edited by Stone Blue

Share this post


Link to post
Share on other sites

Hmmm... true, the name is a bit confusing. Changing the name would be a pain, so I'll just call it "Mono Map (map audio equalizer)" (that way I don't have to rename the DLL  or GitHub repo)  .  Thanks for the suggestion!

The mod technically just disables 3D (spatial) sound when in the map view, the difference in volume is just a side-effect, most likely from the stock music being louder in one ear than the other, or Unity's audio engine just being weird. I guess I could make it so it changes the volume whilst in map view to account for that, but I don't know if it'd be worth the trial-and-error of finding the audio difference.  But yeah, the mod works perfectly on 1.6, I'm using it now :cool:

Gonna change the name and version now.  Also added a release on GitHub, sorry if I confused people. Thanks everyone!

Share this post


Link to post
Share on other sites
4 hours ago, TheUltimateKerbonaut said:

...so I'll just call it "Mono Map (map audio equalizer)" ...

That should be good enuff... Capitalize the "MAP"? at least maybe in the thread title? vOv

Ahh... Ok (on how the mod works...) ... yeah, i wouldnt think theres any need to change it... if a little lower volume thru each speaker is nothing but a side-effect, it seems effective enuff... ;)

Share this post


Link to post
Share on other sites
20 hours ago, TheUltimateKerbonaut said:

guess I could make it so it changes the volume whilst in map view to account for that, but I don't know if it'd be worth the trial-and-error of finding the audio difference.

You could  have a volume setting for the map view

Share this post


Link to post
Share on other sites
Posted (edited)

I assumed this mod dealt with the Mono garbage collection but I’m glad I checked it out since I remember map audio being pretty annoying!

thanks!

edit: I’m on mobile, guess I missed the added bit in the title!

Edited by Jognt

Share this post


Link to post
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.