Sound properties (SOLVED)


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"#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")
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()/"#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”?



Because you can play the sound multiple times, simultaneously.
Documentation: play_sound

1 Like


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.

1 Like


You can use go.animate() but the sound must be playing, which means that you need to delay the go.animate() call.

Added to investigate and possibly fix this.



Thanks for looking into this! :wink:
(and still no access to issues :frowning: )



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 (9.3 MB)

1 Like


It’s working in this example:

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 or timer.delay(0

1 Like


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 :frowning:

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, so I’m sure the music is playing, but I can’t animate its gain :confused:



Ok - updating to 1.2.166 instantly solved this problem

1 Like