# Set Spatializer's Sound Size Programmatically

**URL:** https://qa.fmod.com/t/set-spatializers-sound-size-programmatically/16078
**Category:** FMOD Engine
**Created:** [August 12, 2020, 8:09pm UTC](https://qa.fmod.com/t/set-spatializers-sound-size-programmatically/16078 "2020-08-12T20:09:01Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![jag82](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@jag82](https://qa.fmod.com/u/jag82)
#### Post date: [August 12, 2020, 8:09pm UTC](https://qa.fmod.com/t/set-spatializers-sound-size-programmatically/16078/1 "2020-08-12T20:09:01Z")

</div>

Via the API I can set the Spatializer’s min/max distance (if it’s on the Master Track):

`eventInstance->setProperty(FMOD_STUDIO_EVENT_PROPERTY_MINIMUM_DISTANCE, customValue);`

I would like to be able to do the same for Spatializer \> Envelopment \> User \> Sound Size. I can’t find it in the API documentation and suspect it isn’t possible.

**Can I set Sound Size programmatically?**

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [August 17, 2020, 12:26am UTC](https://qa.fmod.com/t/set-spatializers-sound-size-programmatically/16078/2 "2020-08-17T00:26:53Z")

</div>

There isn’t an API for setting it but you can automate the Sound Size property and modify it by adjusting a parameter.

---

<div class="post-metadata">

### Author: ![jag82](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@jag82](https://qa.fmod.com/u/jag82)
#### Post date: [August 19, 2020, 7:57pm UTC](https://qa.fmod.com/t/set-spatializers-sound-size-programmatically/16078/3 "2020-08-19T19:57:54Z")

</div>

Thanks for the reply.

I tried this solution out and, while it sets the variable correctly, it has no effect on the Spatializer (e.g. if I set the Spatializer’s sound size to 0 in FMOD Studio, but change it to 10k programmatically, it continues to behave as if the sound size were 0, a.k.a. strong left-right differences, a.k.a. no envelope).

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [August 21, 2020, 1:04am UTC](https://qa.fmod.com/t/set-spatializers-sound-size-programmatically/16078/4 "2020-08-21T01:04:57Z")

</div>

I was able to get it working in a test.  
What versions of FMOD and Unity are you using?

---

<div class="post-metadata">

### Author: ![jag82](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@jag82](https://qa.fmod.com/u/jag82)
#### Post date: [August 21, 2020, 5:04pm UTC](https://qa.fmod.com/t/set-spatializers-sound-size-programmatically/16078/5 "2020-08-21T17:04:42Z")

</div>

Thanks for the follow up.

I’m using FMOD Studio 2.00.10.  
No Unity, I’m working on Android.

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [August 24, 2020, 1:09am UTC](https://qa.fmod.com/t/set-spatializers-sound-size-programmatically/16078/6 "2020-08-24T01:09:30Z")

</div>

Sorry, just assumed it was Unity.  
Are you able to share a snippet of the code you are using?

---

<div class="post-metadata">

### Author: ![jag82](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@jag82](https://qa.fmod.com/u/jag82)
#### Post date: [August 24, 2020, 10:11am UTC](https://qa.fmod.com/t/set-spatializers-sound-size-programmatically/16078/7 "2020-08-24T10:11:52Z")

</div>

This is where I update the sound size (and min/max distance):

```auto
    void Java_tools_jag_starball_modules_audio_FmodAudioModule_fmodUpdateEventLimits(JNIEnv *env, jobject thiz, jstring soundName, float innerLimit, float outerLimit) {
        const char* soundNamePtr = env->GetStringUTFChars(soundName, NULL);

        auto it = eventMap.find(soundNamePtr);
        if (it != eventMap.end()) {
            FMOD::Studio::EventInstance* eventInstance = it->second;
            ERRCHECK(eventInstance->setProperty(FMOD_STUDIO_EVENT_PROPERTY_MINIMUM_DISTANCE, innerLimit));
            ERRCHECK(eventInstance->setProperty(FMOD_STUDIO_EVENT_PROPERTY_MAXIMUM_DISTANCE, outerLimit));
            ERRCHECK(eventInstance->setParameterByName("SoundSize", innerLimit * 3, false));
        }
    }

```

(As an aside, if the SoundSize parameter is not connected to an event, I get an FMOD\_EVENT\_NOT\_FOUND error, which is ok, but a bit misleading.)

I’ve made sure that the event is loaded (by calling flushLoading, and checking with getLoadState) and that the value of SoundSize is being set to something reasonable (e.g. 75), but still I get heavy left right panning in a small range (e.g. 10-20m from the sound source).

Here’s my FMOD Studio setup:

 ![Screen Shot 2020-08-24 at 12.41.56 PM](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/9/964dfcd890fdf1d4fb0970e2e3e847a46d6eb232.png)

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [August 27, 2020, 2:14am UTC](https://qa.fmod.com/t/set-spatializers-sound-size-programmatically/16078/8 "2020-08-27T02:14:53Z")

</div>

Are you able to reproduce this in the sandbox/profiler in FMOD Studio at all?
