@@ -438,6 +438,25 @@ The following file formats are supported
438
438
| If value < 0.0, the volume will not be changed
439
439
| If value > 1.0, the volume will be set to 1.0
440
440
441
+ .. note ::
442
+ The values are internally converted and kept as integer values in range [0, 128], which means
443
+ that ``get_volume() `` may return a different volume than it was set to. For example,
444
+
445
+ >>> sound.set_volume(0.1 )
446
+ >>> sound.get_volume()
447
+ 0.09375
448
+
449
+ This is because when you ``set_volume(0.1) ``, the volume is internally calculated like so
450
+
451
+ >>> int (0.1 * 128 )
452
+ 12
453
+
454
+ This means that some of the precision is lost, so when you retrieve it again using ``get_volume() ``,
455
+ it is converted back to a ``float `` using that integer
456
+
457
+ >>> 12 / 128
458
+ 0.09375
459
+
441
460
.. ## Sound.set_volume ##
442
461
443
462
.. method :: get_volume
@@ -447,6 +466,9 @@ The following file formats are supported
447
466
448
467
Return a value from 0.0 to 1.0 (inclusive) representing the volume for this Sound.
449
468
469
+ .. note ::
470
+ See :func: `Sound.set_volume ` for more information regarding the returned value
471
+
450
472
.. ## Sound.get_volume ##
451
473
452
474
.. method :: get_num_channels
@@ -627,6 +649,9 @@ The following file formats are supported
627
649
sound.set_volume(0.6) # Now plays at 60% (previous value replaced).
628
650
channel.set_volume(0.5) # Now plays at 30% (0.6 * 0.5).
629
651
652
+ .. note ::
653
+ See :func: `Sound.set_volume ` for more information regarding how the value is stored internally
654
+
630
655
.. ## Channel.set_volume ##
631
656
632
657
.. method :: get_volume
@@ -640,6 +665,9 @@ The following file formats are supported
640
665
:meth: `Channel.set_volume `. The Sound object also has its own volume
641
666
which is mixed with the channel.
642
667
668
+ .. note ::
669
+ See :func: `Sound.set_volume ` for more information regarding the returned value
670
+
643
671
.. ## Channel.get_volume ##
644
672
645
673
.. method :: get_busy
0 commit comments