[GREENFOOT-404] Volume-methods for SoundStreams is dysfunctional
the setVolume- and getVolume-methods in class SoundStream does not match their expected behaviours.
I: (Package sound, class SoundStream)
setVolume delegates a change of the volume to a logarithmic transformed value to the audio line. getVolume however directly returns the volume of the audioline.
Thus, for a given GreenfootSound-reference "gsound" resulting from an mp3-file the following odd behaviour occurs: {noformat} gsound.setVolume(5); System.out.println(gsound.getVolume()); // result: 34 {noformat}
Basically, if you give a specific value to the setVolume-methode, the getVolume-method should return exactly that value after that.
II: (Package sound, class SoundUtils)
Also, for performing the logarithmic transformation the method logToLin in class SoundUtils is used. This method claims to convert a value between 0-100 to a value in the same range. Actually, if 0 is the given parameter, this is incorrect. Instead, Math.log(0) is conducted and thus, the resulting value is something resulting from an operation on "negative infinity" (e.g. -2147483648); see javadoc of Math.log. {noformat} gsound.setVolume(0); System.out.println(gsound.getVolume()); // result: -2147483648 {noformat}
Issue metadata
- Issue type: Bug
- Priority: Medium