[SOLVED] Soundinterval fadeout

Evening,
I’m currently struggling with a Problem and start to wonder if it is even possible.

My intention is that a a Soundinterval that is playing will fadeout ,when a triggerevent occurs.

My Idea was to reduce the interval.volume over time after the event(within the update loop) but it seems like the interval ignores all changes to the volume variable till it has finished.

Is this the case?
And would changing the volume of the sfx file it is using have any effect on the already started interval?

I use this code and it works:

import direct.directbase.DirectStart
from direct.interval.IntervalGlobal import Sequence
from direct.interval.LerpInterval import LerpFunc
def startFade():
  Sequence(
    LerpFunc( s.setVolume, fromData = 1, toData = 0, duration = 4 )
  ).start()
s = loader.loadSfx( 'foo.ogg' )
s.play()
base.accept( 'mouse1', startFade )
run()

Aye setVolume of a loaded SFK file works all the time.

But my Question is about SoundIntervals.

like

mySound = loader.loadSfx("mySound.wav")
self.myInterval = SoundInterval(mySound, volume=1)
self.myInterval.start()


base.accept( 'mouse1', self.functionA ) 

def FunctionA(self):
     self.myInterval.Volume=0.0

Won’t reduce the audible volume of the Interval until it gets started again.

So I wonder if it is supposed to be that way and if reducing the volume of “mySound” as you did will effect the Soundinterval right away .

Ok, sorry, I overlooked the word “SoundInterval” (and it was in the title, lol), I assumed you were talking about intervals, generally, excuse me.
Afaik:

Indeed, this:

seems to show another precomputation behaviour for intervals. So, I think you can’t use:

self.myInterval.Volume=0.0

interactively, but you can only modify:

self.myInterval.sound.setVolume(0.0)

Use tasks. They’re more flexible than intervals and the way to go for everything more than small, linear manipulations.