Skip to content

Sample rate monitoring

This class is accessed via the rate property on a CamillaClient instance.

It provides methods for reading the output of the sample rate monitoring.

class: RateMonitor

Bases: _CommandGroup

Methods for rate monitoring

Source code in camilladsp\ratemonitor.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class RateMonitor(_CommandGroup):
    """
    Methods for rate monitoring
    """

    def capture_raw(self) -> int:
        """
        Get current capture rate, raw value.

        Returns:
            int: The current raw capture rate.
        """
        rate = self.client.query("GetCaptureRate")
        return int(rate)

    def capture(self) -> Optional[int]:
        """
        Get current capture rate.
        Returns the nearest common rate, as long as it's within +-4% of the measured value.

        Returns:
            int: The current capture rate.
        """
        rate = self.capture_raw()
        if 0.96 * _STANDARD_RATES[0] < rate < 1.04 * _STANDARD_RATES[-1]:
            nearest = min(_STANDARD_RATES, key=lambda val: abs(val - rate))
            if 0.96 < rate / nearest < 1.04:
                return nearest
        return None

capture()

Get current capture rate. Returns the nearest common rate, as long as it's within +-4% of the measured value.

Returns:

Name Type Description
int Optional[int]

The current capture rate.

Source code in camilladsp\ratemonitor.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def capture(self) -> Optional[int]:
    """
    Get current capture rate.
    Returns the nearest common rate, as long as it's within +-4% of the measured value.

    Returns:
        int: The current capture rate.
    """
    rate = self.capture_raw()
    if 0.96 * _STANDARD_RATES[0] < rate < 1.04 * _STANDARD_RATES[-1]:
        nearest = min(_STANDARD_RATES, key=lambda val: abs(val - rate))
        if 0.96 < rate / nearest < 1.04:
            return nearest
    return None

capture_raw()

Get current capture rate, raw value.

Returns:

Name Type Description
int int

The current raw capture rate.

Source code in camilladsp\ratemonitor.py
18
19
20
21
22
23
24
25
26
def capture_raw(self) -> int:
    """
    Get current capture rate, raw value.

    Returns:
        int: The current raw capture rate.
    """
    rate = self.client.query("GetCaptureRate")
    return int(rate)