Param drives pitch effect in FMOD Studio, but not in Unity

Hello, I have an FMOD Event I set up with a local parameter called “Power”. It’s a looping hum sound that gets both higher in pitch and also louder as the Power param moves from 0 to 1. In FMOD Studio, moving the parameter works as designed. However, when this sound is playing in Unity, adjusting the Power parameter only changes the volume of the sound. The pitch stays static.

The FMOD Event has a Pitch Shifter component on the Master Track and also on each of its 3 Logic Tracks (4 in total). The automation is applied on the Pitch Shifter Pitch setting on the Master Track, with the other pitch settings set statically. It seems like these components are being ignored completely, because the pitch that I hear in game is the same as if the Pitch Shifters in FMOD Studio were bypassed.

I had the thought that maybe having multiple Pitch Shifters was causing the problem, but removing them from the individual tracks (leaving just the one on the Master Track), rebuilding and retesting didn’t seem to make a difference.

I’ve seen this sort of thing a couple of times but haven’t been able to sort out the cause or how to fix it. I do have plenty of other sounds with parameter-driven pitch automation that work fine.

I’m using FMOD Studio 2.02.11.

Hi,

Thank you for all the information.

Would it be possible to get screenshots of the event in FMOD Studio showing all the pitch shifters and the automation attached to them? Also, could I get a code snippet outlining how you control the parameter value in Unity?

I created a simple event and was not able to reproduce the issue. Are there any logs in the Unity console that you can share?

Thanks for your response. Yeah, of course! Screenshots are attached of the Event with each track selected so you can see the params. The automation is currently removed from the pitch on the individual tracks.




Here’s the code I’m using to fade the parameter to a target value. We use DOTween. (This component also keeps a Dictionary of Events by name so it’s easy to get a reference to the event instance.)

    public static DG.Tweening.Core.TweenerCore<float, float, DG.Tweening.Plugins.Options.FloatOptions> FadeParam(string eventName, string paramName, float to, float duration, AnimationCurve curve) {
      DG.Tweening.Core.TweenerCore<float, float, DG.Tweening.Plugins.Options.FloatOptions> tween;

      EventInstance instance = events[eventName].EventInstance;

      tween = DOTween
        .To(() => {
          instance.getParameterByName(paramName, out float val);
          return val;
        }, (v) => instance.setParameterByName(paramName, v), to, duration);

      if (curve != null) {
        tween.SetEase(curve);
      } else {
        tween.SetEase(Ease.InOutSine);
      }

      return tween;
    }

Thank you for the images and the code.

Could I suggest adding a Studio::EventInstance::isValid() call after retrieving the instance?

EventInstance instance = events[eventName].EventInstance;
if (instance.isValid())
    // Manipulate params
else
   // There is an issue retrieving the instance

Do you still experience the issue when not using DOTween? Is it possible to return any of the FMOD.RESULT calls from this function?

Thanks for the response and the suggestion. This method returns a DOTween tween, so it’s not super straightforward to make the proposed changes, but we can use the following method for now to isolate our testing from any tweens or fades, just setting the parameter directly:

   public static FMOD.RESULT SetEventParam(string eventName, string paramName, float value) {
      if (!events.ContainsKey(eventName)) {
        return FMOD.RESULT.OK;
      }

      EventInstance instance = events[eventName].EventInstance;

      if (!instance.isValid()) {
        Debug.LogWarning("Tried to set parameter " + paramName + " on invalid event instance " + eventName);
        return FMOD.RESULT.OK;
      }

      return events[eventName].EventInstance.setParameterByName(paramName, value);
    }

This still has the same issue. The pitch isn’t changing. The volume and the tremolo frequency (which you may have noticed from the screenshots is also automated) do change as expected. The FMOD.Result is “OK” for each call to set the Power level, which is being set to .25f, .5f, .75f, and 1f, in that order. There are no errors or warnings logging in the console that I can see.

1 Like

Thank you for the update code, I was able to test that on my side and it does seem to be working. Would it be possible to package the project, with banks included:
image


and upload them to your profile, please note that you need to register a project with us before uploading to your profile. This will allow me to try setting the params with the code on my side.

Yeah, you bet. Our project is really massive, so I wanted to give you a limited test case. I deleted all the Events and Assets I could that weren’t related to this particular issue and then just as a test wired this limited project up in Unity to verify the issue is still happening, and it is. So hopefully that’s helpful. You should be able to find it on my profile as “FMOD Project test case.fspackage”.

By the way, if you want to look at another issue, there is also an Event in that project package at event:/UI/Music/Previous Versions/Night Frights which I was unable to delete. Each time I tried, FMOD Studio crashed. (This issue is less of a priority for us, but still thought you might want to know about it.)

Thanks!

1 Like

Thank you for the project. I have tested with some of my audio files and I am not sure if it is the expected behaviour.

Would it be possible to share just the build banks? That way, I can load them in my test scene, play the same events you have, and then record a profiler session to confirm it is not working as expected.

I have been able to reproduce the crash when deleting the event. I have passed it on to our development team to investigate further. Thank you for bringing this to our attention.

Of course, no problem. I’ve uploaded our Build folder compressed as Build.zip. Let me know if you need anything else from me. Thanks.

1 Like

Thank you for sharing the built banks. Something I noticed, you are automating the Pitch value of the Pitch Shifter from 0.5x - 1.0x. In the Docs: FMOD Engine | Core API Reference - Effect Parameters. It notes 0.5x will pitch the audio one octave down and 1.0x will not change the pitch. The issue may be you are not changing the value enough, maybe automating between 0.5x - 2.0x may have the desired behavior?

I have confirmed that your code is correctly changing the value of the pitch:

instance.getChannelGroup(out FMOD.ChannelGroup mCG);

mCG.isPlaying(out bool playing);
if (playing)
{
	mCG.getDSP(1, out FMOD.DSP pitchShifter);

	if (pitchShifter.hasHandle())
	{
		pitchShifter.getParameterFloat(0, out float pitch);

		Debug.Log($"Current pitch value {pitch}");
	}
}

Hope this helps!

Thanks for your response. Unfortunately changing the pitch range of the automation from 0.5 to 2.0 does not seem to have any effect in Unity. It does, as expected, change the pitch range from an octave below to an octave above the base pitch when playing the Event and adjusting the parameter directly in FMOD Studio. In Unity, however, the pitch stays static as the parameter is adjusted (while the other two automation settings – volume and tremolo – update as expected).

I also just want to point out that my goal is to have the pitch start at an octave below the baseline and then move up to the baseline pitch. It’s correctly configured to do so with a range from 0.5 to 1, and again, this works when playing the sound and updating the parameter in FMOD Studio. It’s only in Unity where the effect does not function.

So this definitely seems to be a bug with FMOD. And since it works as I would expect in FMOD Studio but not in Unity, I feel like the issue is likely with FMOD’s Unity integration.

1 Like

Thank you for the clarification.

Would it be possible to add my logging code and ensure the value is being changed on the DSP?

I found the correct index by using the following:

instance.getChannelGroup(out FMOD.ChannelGroup mCG);

mCG.isPlaying(out bool playing);
if (playing)
{
	mCG.getNumDSPs(out int numDSPs);

	for (int i = 0; i < numDSPs; i++)
	{
		mCG.getDSP(i, out FMOD.DSP dsp);
		dsp.getInfo(out string name, out _, out _, out _, out _);
		Debug.Log($"DSP at index: {i}, is called: {name}");
	}
}

I will also send you some profiler recordings when I am adjusting the pitch and please let me know if it sounds as you’d expect.

1 Like

Thanks, this is helpful, and I really appreciate the level of support you’re providing.

I’ve imported and played back the profiler recordings you sent. In both of them, I can clearly hear the pitch changing as expected, so that bit is definitely working.

Back to Unity: Here are the logs. I increased the pitch 3 times. (The logs naming the DSP logged each time, but I’m only including them once here.) Although the logs show the pitch increasing, the audible pitch of the sound from Unity does not actually increase.

DSP at index: 0, is called: FMOD Compressor
DSP at index: 1, is called: FMOD Pitch Shifter
DSP at index: 2, is called: FMOD Pan
DSP at index: 3, is called: ChanGroup Fader
Current pitch value 0.8749336
Current pitch value 1.250996
Current pitch value 1.627058

1 Like

Thank you for testing that. Have you recently rebuilt the banks for the Unity project? It may be that it is using older banks which are not representative of what you view in the Studio project. Just confirm that the banks are building into the expected location by checking the Build Preferences:


I have been stumped by this multiple times. Could you also please record a profiler session and upload it?

Again, thanks for all the information so far.

Hi, sorry for the delayed response. I was out of town last week. I’m certain the banks are up to date. My bank files show as created on July 30, which was the day before I left for vacation. My output directory shows blank like yours.

The profiler session is interesting. While I recorded it (while playing the game in Unity) the pitch did not change. However, when playing the profiler session from within FMOD Studio, the pitch does change.

No worries.

Thanks for testing that, would it be possible to share those profiler sessions? An option may be to get a screen/audio recording while changing the pitch so I can hear you are hearing without FMOD getting involved.

Okay, I think I uploaded the profiler session as part of FMOD Profiler Session.fspackage. Please take a look and let me know if that’s what you’re needing. I also uploaded a video of the issue happening in Unity so you can compare.

1 Like

Thank you for everything. I am looking into the issue and will hopefully have a solution soon.

1 Like

Thank you for your patience. I believe I may have identified a potential issue but there are a few more tests I would like to try.

I have DM’d you an updated simple_test.cpp file which if possible could you swap with the file at "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\examples\simple_event.cpp" and then try running the simple_event project in the "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\examples\vs2019\examples.sln". If you do not have the FMOD Engine installed, please download it here: https://fmod.com/download#fmodengine. Then copy and paste the built Master.bank and Master.strings.bank that you gave me over the ones in the C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\examples\media directory. If you need more detailed steps please let me know.

Finally, would it be possible to copy the event to a new project and upload it to your profile with the assets included?

Again, thank you so much for your help and patience.

Hi Connor, you bet, and thanks for your continued help with this. I may need some additional instructions. I’m on macOS. I downloaded FMOD Engine and found the CPP to replace. I swapped it with the one you sent. I also copied over my Master bank files. I’m not sure how to run the project though.

I did create a minimum test case version of our project for you and uploaded it to my profile as FMOD Project Test Case.zip. You should have everything you need in there to play back the problem event. Its path is event:/Environment/Buildings/Power Station/Aux Building Loop.

1 Like