Following sprite properties, sound component should also have its properties like gain, pan, pitch that can be animated using go.animate("#sound", ...)
without workarounds.
Given the sound component is more like a factory, spawning voices (instances) of a sound, (each having separate initial properties):
#sound voice 1: gain1, pan1, speed1
#sound voice 2: gain2, pan2, speed2
Currently, the msg.post("#sound", "set_gain", ...)
works on all playing voices of that sound component.
The same mechanic would then go into the go.animate("#sound", "gain")
, addressing all voices.
I assume this is what you mean though, the same functionality as the “set_gain”, but without the need to manually set the values each frame ?
Yeah, exactly, animating:
sound.play("#sound")
sound.set_gain("#sound", 0)
go.animate("#sound", "gain", go.PLAYBACK_ONCE_FORWARD, 1, go.EASING_INOUTSINE, 3)
should cause the sound that is playing to fade in. For now it’s causing an error:
ERROR:SCRIPT: /main/test.script:4: '193[main:/go#sound]' does not have any property called 'gain'
stack traceback:
[C]: in function 'animate'
/main/test.script:4: in function </main/test.script:1>
Currently we have only a workaround to this: sound.set_gain()/msg.post("#sound", "set_gain",...)
either with a timer or in update().
I don’t understand one thing in this:
Currently one sound component can have only one Sound property, so why you’re highlighting “on all playing voices”?
What about the error when animating its property? I still didn’t manage to animate sound’s gain, nor pan, nor even speed with go.animate()
. Is there any feature request to allow it ongoing?
This should have been released already. We are investigating.
You can use go.animate() but the sound must be playing, which means that you need to delay the go.animate() call.
Added https://github.com/defold/defold/issues/4725 to investigate and possibly fix this.
Thanks for looking into this!
(and still no access to issues )
We know. We will be able to provide a single unified issue list just a couple of weeks. And these links will work then.
Even after a sound started playing, it is not possible:
ERROR:SCRIPT: /main/sound.script:4: '192[main:/go#sound]' does not have any property called 'gain'
stack traceback:
[C]: in function 'animate'
/main/sound.script:4: in function </main/sound.script:3>
I’m attaching a simple repro:
Empty Project.zip (9.3 MB)
It’s working in this example: https://defold.com/examples/sound/fade_in_out/
You can’t make the call to play and then immediately animate. You must let the call to play process first. Either animate after a msg.post or timer.delay(0
First of all, either downloaded or pulled project with those examples is not working for me (tried several times), because several files appears to be damaged
Secondly, I can’t play the sound from my examples even with the code provided in that example (I changed name of sound to music), because of the same reason:
ERROR:SCRIPT: /main/sound.script:11: '22[main:/go#music]' does not have any property called 'gain'
stack traceback:
[C]: in function 'animate'
/main/sound.script:11: in function </main/sound.script:9>
In my code, there is also a timer of 2 seconds after sound.play(), so I’m sure the music is playing, but I can’t animate its gain
Ok - updating to 1.2.166 instantly solved this problem