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