return to src
 
Volume Class

The Volume class allows for changing the volume level and applying gain coefficients to audio signals. 
To use it, import the class, create an instance, use the config() method to configure the volume parameter
given a knob value, use the calculate_gain() method to calculate the gain coefficients, 
and the change_gain() method to dynamically adjust the gain.

 
Modules
       
numpy
numpy.typing

 
Classes
       
builtins.object
Volume

 
class Volume
    Volume(volume_level: int = 9, offset: int = 9) -> None
 
Allows for changing the volume level and applying gain coefficients to audio signals.
 
Attributes:
    volume_level: level of the audio signal
    offset: reference point for the volume control
 
  Methods defined here:
__init__(self, volume_level: int = 9, offset: int = 9) -> None
Initialize self.  See help(type(self)) for accurate signature.
calculate_gain(self) -> float
calculate the gain coefficient based on default offset and current knob
volume level setting.
change_gain(self, samples: numpy.ndarray[typing.Any, numpy.dtype[numpy.int16]]) -> numpy.ndarray[typing.Any, numpy.dtype[numpy.int16]]
change the gain of a given sound wave.
config(self, volume_level: int) -> None
configure all volume parameter given a knob value.