MetaSound Array Doesn't Shrink?

I have an MS that I would like to feed different array values in at different times depending on game events. In other words stop the currently playing theme, reload the array, then start the new theme. The themes are a variable number of waves that are fed into the array Input (of type Wave->Array).

What happens is that if the previous theme had fewer entries than the new one, this would be fine, the Array Num function shows the correct size. If I reload with a theme that contains fewer elements than the previous one, the Num function reports it still has the larger number and the residue remains in the array. Is it normal behavior that arrays don’t size to the current Set Object Array entry?

I created this simple example to illustrate what I was trying to do. When run, it prints 3 which is the size of LargeArray, then when I press C, it loads from the SmallArray, but the display still shows that three entries via the Array Num expression. Array element 2 is still set to the wave from the previous theme. Is there any way to wipe the array out while the MetaSound is running so it can be reloaded?

I had a similar issue but in my case I was managing my array in BP and sending wave assets as individual inputs. Wave assets would get “stuck” from the previous cue and would need to be flushed out. I could work around this by sending null to those inputs, but this would cause an error to print in the output log (even though it seemed to work fine).

I didn’t like this so I ended up going a slightly different route—creating a new sound component and destroying the old one.

I haven’t tried this, but just spotted it while writing this post. You could try using a Reset Parameters node before setting the new array. This would have the downside of resetting all of your other parameters of course, but it’s something to look into.

Thanks Very Much.

The Reset didn’t work when I tried it, but I will mess with it further because it didn’t seem to do anything, so kind of suspicious.

I tried the null too by passing a null array in and that does seem to do the trick. I didn’t consider that that might work because I assumed if going to a smaller array wouldn’t work, it wouldn’t either. It did and interestingly I see no error in the output log.

I’d already changed the version in the game to destroy the component and fire up a new one, but then I decided to include my weather manager into the same component as the music, and keeping the audio component running (without break down and restart) would be necessary to accomplish that or music and weather would have to change at the same time (wouldn’t make sense).

Looks like your idea will work. Thanks

Edit: don’t want to report this if it’s not a bug, but if so, it should be. Any thoughts from anyone on whether this is intentional behavior?