import math
from typing import Optional

from pojagi_dsp.channel.ecg import AECGChannel


class AECGSynthesizer(AECGChannel):
    def __init__(self, /, heart_rate: int, srate: Optional[float] = None):
        """
        :param:`heart_rate` - The heart rate in bpm.
        """
        super().__init__(srate)
        self.heart_rate = heart_rate

    @property
    def heart_rate(self): return self._heart_rate

    @heart_rate.setter
    def heart_rate(self, val: int):
        self._heart_rate = val
        self._wavelength = math.floor(self.srate * (60 / self.heart_rate))

    @property
    def wavelength(self): return self._wavelength
