(MV Conversion) MUSH Audio Engine - Spatial Audio/Voice Acting/New Channels/etc

Original Plugin:


Now For MV!​

Introduction

With permission and at the request of several others in the original thread, I am publicly releasing my quick-and-dirty MV conversion of @MushroomCake28's excellent MZ audio plugin, MUSH Audio Engine. It's not perfect, but should be better than nothing for those who want this plugin on MV!


Features:
From original thread:

  • New BGM/BGS system that allows multiple BGMs/BGSs to be played at the same time.
  • Added 2 optional extra channels to control volume separately: one channel for UI sound effects called UIS, and one channel for voice acting called VSC.
  • Added a master volume option.
  • Spatial Audio for BGM, BGS, and SE (volume and pan dynamically varies depending on player position to audio source(s)).
  • Pitch and Volume variance for SE/UIS on each play.
  • Ability to load the parent map's autoplay BGM if the current map doesn't have one.

Instructions:
See original thread. The only substantive difference in usage is the plugin commands. MZ uses a UI interface for plugin commands, but for MV, you enter the plugin commands as written text. Take note as some of the commands are rather long.

Every argument is required, in the exact order shown, or things will almost certainly break. Every argument is also case-sensitive. You can put 0 for fadeIn/fadeOut if not used.

For explanations of the individual arguments and what to put there, refer to the original thread. Follow the spelling and case setting described/shown in the photos. The ONLY meaningful difference is that for the PanType, you want to use either "LinearScaling" or "OriginExpand" (without the quotes, cap sensitive, and note the lack of a space). The space was removed for ease of processing the plugin commands.


MV Plugin Commands:

Spoiler: MV Plugin Commands
  • PlayBGM Filename Channel Pitch AutoRemover Volume Pan FadeIn Interrupt
  • PlayBGS Filename Channel Pitch AutoRemover Volume Pan FadeIn Interrupt
  • StopBGM Channel FadeOut
  • StopBGS Channel FadeOut
  • StopAllBGM FadeOut
  • StopAllBGS FadeOut
  • AddSpacialBGM Filename Channel Pitch Dynamic MaxVolume Radius Strength PanType PanStartDistance PanLengthDistance CrossFade
  • AddSpacialBGS Filename Channel Pitch Dynamic MaxVolume Radius Strength PanType PanStartDistance PanLengthDistance
  • PlaySpatialSE Filename Pitch PitchVariance VolumeVariance MaxVolume EventId Radius Strength PanType PanStartDistance PanLengthDistance
  • PlayVSC Filename Channel Pitch Volume Pan Interrupt

MushPluginComs.png


Plugin Command Examples:

Spoiler: Plugin Command Examples
PlayVSC AreYouReady 2 80 70 0 Ignore
- Plays the file "AreYouReady.ogg" from the /vsc folder on Vsc channel 2 with pitch 80, volume 70, pan 0, and "Ignore" interrupt setting

PlayBGM Town1 1 100 true 45 0 3 Pause
- Plays the file "Town1.ogg" from the /bgm folder using BGM channel 1 with pitch 100, AutoRemover "true", volume 45, pan 0, fadeIn of 3 secs, and "Pause" interrupt setting

AddSpacialBGS Sea 1001 100 false 70 8 100 OriginExpand 3 6
- Adds a spacial BGS playing file "Sea.ogg" from the /bgs folder using BGS channel 1001 with pitch 100, dynamic "false", max volume 70, radius 8, strength 100, pan type OriginExpand, pan start distance 3, pan length distance 6




Known Issues:
- Playing MEs does not mute/pause BGS or Mush BGM. Playing MEs is supposed to automatically stop any BGM or BGS (default or Mush) and resume them when the ME is finished. Unfortunately this behavior works only for RM's default BGM, but not for default BGS or for Mush BGM/BGS. I had to disable portions of the functions involved because it was causing a crash error I could not fix or trace. Therefore, any Mush BGM/BGS channels or default BGS will simply continue uninterrupted if an ME is played. I may or may not get around to fixing this, as I'm not only thoroughly vexed by it, I also don't personally care much about MEs or whether they mute BGM/BGS. Someone smarter than me is welcome to investigate! Otherwise, my advice: Manually mute/pause/resume any BGS or Mush BGMs as needed before or after using MEs.

Please report any other issues with this plugin conversion here. I cannot guarantee I will be able to address them, but I will at least take a look!



Terms of Use:

Same as MushroomCake28's original, which states:
  1. This plugin is free for commercial and non-commercial use.
  2. You may edit the plugin, but please contact me before sharing any edits of the plugin.
  3. You can repost this plugin as long as you link back to this thread.
  4. Please credit MushroomCake28 in your project if you use this plugin.
Additionally, you may optionally credit "FeatherBrain Studios" if you want.


DOWNLOAD PLUGIN:
See Attached Files
Great job on this and thanks! Looking forward to trying it out tonight.
An awesome plugin for sure but... Is it possible to change the audio's pitch and volume afterward? Cause when I'm trying to do it using the same plugin command but it simply says that the channel is already occupied. Using stop isn't an option either since it then starts the whole thing from the beginning.
It seems that wasn't a functionality included in the original MZ plugin:

Is there a way to modify a volume of already running track?

Good question. There's no dedicated way, and I'm not sure calling the play Mush BGM to play the same track with the same channel will work (it might work, but it'll probably throw an error).

The original scope of this conversion was simply to convert what presently exists in the MZ plugin. I'm not sure I want to make a whole new fork with its own feature set. I'll look into it when I get a chance to see if it's an easy fix, but I may end up waiting to see if this gets patched into the original plugin before I try to make my own fix.
Is there a way to change audio's values without restarting the whole thing? Maybe I'm doing something wrong?
StopBGS often takes a long time to process and creates stuttering.

UPD I need it for one of my game mechanics that ideally won't interrupt the main game score, which is why I can't use the default "audio engine" 🙁
Like I said, this ported plugin for MV can only do what the original plugin for MZ can do, and MushroomCake28 (the author of the MZ original) indicated that the current version of the original MZ plugin does not include a way to adjust the volume or parameters on audio that is already playing.

I will look into this problem when I get a chance to see if I can find a script call or patch a fix easily without drastic changes to the plugin logic. However, if adding this functionality would require rewriting any fundamental logic of the plugin, I will probably wait for an update to the original plugin, as I don't want to expand the scope of this project right now beyond a one-for-one translation of the original to MV.
I have a problem, neither the spatial BGS nor the spatial BGM works for me
This plugin's BGM command is not compatible with RMMV's default Fadeout BGM command. It returns TypeError: Cannot read property 'name' of null. Return to Title Screen command is also unavilable since it (assumably) uses RMMV's default command.

Below is for screensots for events. The first image is after using Return to Title Screen command in the test project.
i'm not sure if this is a known issue in the MZ version, but in my project this plugin seems to entirely break transfer player commands on maps that use spatial audio. i can only assume this is related to the previously mentioned incompatibility with the default fadeout command, but in practice it's making the plugin basically unusable for me. which is a shame because it's just about the only one of this type that I can find for mv!
screenshots included below. this is after simply attempting to move the player to a new map. tested on a version with everything except the spatial audio creating events and it worked fine.
i'm not sure if this is a known issue in the MZ version, but in my project this plugin seems to entirely break transfer player commands on maps that use spatial audio. i can only assume this is related to the previously mentioned incompatibility with the default fadeout command, but in practice it's making the plugin basically unusable for me. which is a shame because it's just about the only one of this type that I can find for mv!
screenshots included below. this is after simply attempting to move the player to a new map. tested on a version with everything except the spatial audio creating events and it worked fine.
From a quick look at the code and that error, it seems like it has a problem with removing BGM when no BGM exists. Try replacing line 956 (if (buffer.spatialData.reduceMain) {) with:
if (buffer.spatialData.reduceMain && AudioManager._currentBgm) {

Alternatively, maybe try only using StopAllBGM after the transfer, not before it.
From a quick look at the code and that error, it seems like it has a problem with removing BGM when no BGM exists. Try replacing line 956 (if (buffer.spatialData.reduceMain) {) with:
if (buffer.spatialData.reduceMain && AudioManager._currentBgm) {

Alternatively, maybe try only using StopAllBGM after the transfer, not before it.
tried that last thing, and no dice - same error. for your suggestion to replace line 956, i've gone and done that and now it's giving me a host of different problems. seems closer to the root issue though? I'm a complete rube when it comes to any actual programming, so your help here is really appreciated - this is my first project in RPGmaker and up 'till now i've only been doing plugin commands via eventing lol. attached is the new console message and the relevant lines within the MUSH file.
now it's giving me a host of different problems
What problems? You've only included a screenshot of the same error as before, which I'm assuming no longer happens with that change.

Though either way it sounds like the fix probably won't be that simple then - I'll take a better look at it tomorrow.
What problems? You've only included a screenshot of the same error as before, which I'm assuming no longer happens with that change.

Though either way it sounds like the fix probably won't be that simple then - I'll take a better look at it tomorrow.
sorry, wrong phrasing. it's the same error, i meant to say it was pointing to different lines of code than it was before i think.
I couldn't replicate this unfortunately - I do get the same error normally, but not with the fix I've provided earlier. Are you sure you've applied it to the same file your game uses?
And if so, could you provide a small demo project where this error happens?
I couldn't replicate this unfortunately - I do get the same error normally, but not with the fix I've provided earlier. Are you sure you've applied it to the same file your game uses?
And if so, could you provide a small demo project where this error happens?
I must have been tired or something and done it wrong without realizing, because I came back to it with fresh eyes and re-tried the fix and it's working great now! cheers, hopefully this helps anyone else who has the same issue.
I got this error during opening game, even if didn't put any PluginCommands yet. Anyone can help? 🙁

Edit: my bad, I saved file with "1" at the end.
Seems really cool, but I couldn't get anything working

Original thread: https://forums.rpgmakerweb.com/threads/mv-conversion-mush-audio-engine-spatial-audio-voice-acting-new-channels-etc.133483/