I expect to see the value 0.5 printed. Instead, I get 0.6. Even after the sample finishes playing, the volume is not reset to 0.5.
I expected the playAt call to only affect the volume of that single playback. At no point in time to I expect to get 0.6 as a result from the getVolume() call
I agree, looking at that usage I wouldn't expect playAt() there would change the volume setting. But I can't decide whether the sound would play at 60% volume and then return to 50%, or if it setVolume() would scale the playAt() volume--i.e., it'd be 0.5*0.6 = 30% volume. What's your take?
You might search for a similar case in the sdk for consistency, but my expectation at least would be an override rather that scaling factor. To playback at 30%, I'd expect to use landing_sound:playAt(0, landing_sound:getVolume()*0.6)
So, this is a little more complicated than I thought. Turns out the way it works now is because @shaun filed a bug last year when the following didn't work as expected:
bees:play(0)
bees:setVolume(0.0, 0.0)
print(bees:getVolume()) -- reports (0,0) but it's playing at full volume
To fix your case without breaking Shaun's, I've now got it tracking whether you specified a volume when you triggered playback. If so, setVolume() doesn't affect the sound if something's currently playing and getVolume() returns the default player volume. If playback was triggered without giving a volume, setVolume() will change its volume.
I think that makes sense in these cases and the others I can think of. Am I missing anything?