[Gambas-devel] gb.sdl.sound channel volume bug
Kevin Fishburne
kevinfishburne at ...590...
Sat May 4 09:11:36 CEST 2013
When setting the Volume property (type float according to the
documentation) of a channel, the assignable values are of a lower
resolution than advertised resulting in audibly abrupt changes in
amplitude. Here's an example:
' Audio effects.
Public Struct Audio_Effect ' Structure containing one effect's data.
Current As Single ' Current amplitude.
Target As Single ' Target amplitude.
Velocity As Single ' Speed at which current amplitude is moving
toward target amplitude.
Scale As Single ' Audible amplitude coefficient.
Chan As Channel ' Default channel to play on.
Name As String ' Name of sample.
Sample As Sound ' Sample data (file).
End Struct
Public Environment[16] As Struct Audio_Effect ' Environmental effects.
' Start wind effect.
Environment[7].Sample = New Sound(Render.BasePath & "/sound/Wind.wav")
Environment[7].Name = "Wind"
Environment[7].Chan = Environment[7].Sample.Play(-1)
Environment[7].Chan.Volume = 0
Environment[7].Chan.Volume = 0.01
Print Environment[7].Chan.Volume
0
Environment[7].Chan.Volume = 0.02
Print Environment[7].Chan.Volume
0.01333477219943
This has been plaguing me for a while but I just now zeroed in on what
was actually happening. I've noticed that when performing a calculation
if you use the wrong datatype in the wrong place it can cause overflows
or otherwise invalidate the equation. Maybe something like this is
responsible?
--
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...590...
phone: (770) 853-6271
More information about the Devel
mailing list