Sound properties


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