# Path: friture/ballistic_peak.py
# class BallisticPeak(QtCore.QObject):
#     peak_changed = QtCore.pyqtSignal(float)
# 
#     def __init__(self, parent=None):
#         super().__init__(parent)
# 
#         self._peak_iec = 0
#         self._peak_hold_counter = 0
#         self._peak_decay_factor = PEAK_DECAY_RATE
# 
#     @pyqtProperty(float, notify=peak_changed)
#     def peak_iec(self):
#         return self._peak_iec
#     
#     @peak_iec.setter
#     def peak_iec(self, peak_iec):
# 
#         # peak-hold-then-decay mechanism
#         if peak_iec > self._peak_iec:
#             # follow the peak
#             new_peak_iec = peak_iec
#             self._peak_hold_counter = 0  # reset the hold
#             self._peak_decay_factor = PEAK_DECAY_RATE
#         elif self._peak_hold_counter + 1 <= PEAK_FALLOFF:
#             # hold
#             new_peak_iec = self._peak_iec
#             self._peak_hold_counter += 1
#         else:
#             # decay
#             new_peak_iec = self._peak_decay_factor * float(self._peak_iec)
#             if new_peak_iec < peak_iec:
#                 new_peak_iec = peak_iec
#                 self._peak_hold_counter = 0  # reset the hold
#                 self._peak_decay_factor = PEAK_DECAY_RATE
#             else:
#                 self._peak_decay_factor *= self._peak_decay_factor
# 
#         if self._peak_iec != new_peak_iec:
#             self._peak_iec = new_peak_iec
#             self.peak_changed.emit(new_peak_iec)
# 
# Path: friture/level_data.py
# class LevelData(QtCore.QObject):
#     level_rms_changed = QtCore.pyqtSignal(float)
#     level_max_changed = QtCore.pyqtSignal(float)
# 
#     def __init__(self, parent=None):
#         super().__init__(parent)
# 
#         self._level_rms = -30.
#         self._level_max = -30.
# 
#     @pyqtProperty(float, notify=level_rms_changed)
#     def level_rms(self):
#         return self._level_rms
#     
#     @pyqtProperty(float, notify=level_rms_changed)
#     def level_rms_iec(self):
#         return dB_to_IEC(self._level_rms)
#     
#     @level_rms.setter
#     def level_rms(self, level_rms):
#         if self._level_rms != level_rms:
#             self._level_rms = level_rms
#             self.level_rms_changed.emit(level_rms)
# 
#     @pyqtProperty(float, notify=level_max_changed)
#     def level_max(self):
#         return self._level_max
# 
#     @pyqtProperty(float, notify=level_max_changed)
#     def level_max_iec(self):
#         return dB_to_IEC(self._level_max)
#     
#     @level_max.setter
#     def level_max(self, level_max):
#         if self._level_max != level_max:
#             self._level_max = level_max
#             self.level_max_changed.emit(level_max)


from PyQt5 import QtCore
from PyQt5.QtCore import pyqtProperty
from friture.ballistic_peak import BallisticPeak
from friture.level_data import LevelData
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (C) 2021 Timothée Lecomte

# This file is part of Friture.
#
# Friture is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as published by
# the Free Software Foundation.
#
# Friture is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Friture.  If not, see <http://www.gnu.org/licenses/>.



class LevelViewModel(QtCore.QObject):
    two_channels_changed = QtCore.pyqtSignal(bool)

    def __init__(self, parent=None):
        super().__init__(parent)

        self._two_channels = False


# Path: friture/ballistic_peak.py
# class BallisticPeak(QtCore.QObject):
#     peak_changed = QtCore.pyqtSignal(float)
# 
#     def __init__(self, parent=None):
#         super().__init__(parent)
# 
#         self._peak_iec = 0
#         self._peak_hold_counter = 0
#         self._peak_decay_factor = PEAK_DECAY_RATE
# 
#     @pyqtProperty(float, notify=peak_changed)
#     def peak_iec(self):
#         return self._peak_iec
#     
#     @peak_iec.setter
#     def peak_iec(self, peak_iec):
# 
#         # peak-hold-then-decay mechanism
#         if peak_iec > self._peak_iec:
#             # follow the peak
#             new_peak_iec = peak_iec
#             self._peak_hold_counter = 0  # reset the hold
#             self._peak_decay_factor = PEAK_DECAY_RATE
#         elif self._peak_hold_counter + 1 <= PEAK_FALLOFF:
#             # hold
#             new_peak_iec = self._peak_iec
#             self._peak_hold_counter += 1
#         else:
#             # decay
#             new_peak_iec = self._peak_decay_factor * float(self._peak_iec)
#             if new_peak_iec < peak_iec:
#                 new_peak_iec = peak_iec
#                 self._peak_hold_counter = 0  # reset the hold
#                 self._peak_decay_factor = PEAK_DECAY_RATE
#             else:
#                 self._peak_decay_factor *= self._peak_decay_factor
# 
#         if self._peak_iec != new_peak_iec:
#             self._peak_iec = new_peak_iec
#             self.peak_changed.emit(new_peak_iec)
# 
# Path: friture/level_data.py
# class LevelData(QtCore.QObject):
#     level_rms_changed = QtCore.pyqtSignal(float)
#     level_max_changed = QtCore.pyqtSignal(float)
# 
#     def __init__(self, parent=None):
#         super().__init__(parent)
# 
#         self._level_rms = -30.
#         self._level_max = -30.
# 
#     @pyqtProperty(float, notify=level_rms_changed)
#     def level_rms(self):
#         return self._level_rms
#     
#     @pyqtProperty(float, notify=level_rms_changed)
#     def level_rms_iec(self):
#         return dB_to_IEC(self._level_rms)
#     
#     @level_rms.setter
#     def level_rms(self, level_rms):
#         if self._level_rms != level_rms:
#             self._level_rms = level_rms
#             self.level_rms_changed.emit(level_rms)
# 
#     @pyqtProperty(float, notify=level_max_changed)
#     def level_max(self):
#         return self._level_max
# 
#     @pyqtProperty(float, notify=level_max_changed)
#     def level_max_iec(self):
#         return dB_to_IEC(self._level_max)
#     
#     @level_max.setter
#     def level_max(self, level_max):
#         if self._level_max != level_max:
#             self._level_max = level_max
#             self.level_max_changed.emit(level_max)


# Path: friture/level_view_model.py
from PyQt5 import QtCore
from PyQt5.QtCore import pyqtProperty
from friture.ballistic_peak import BallisticPeak
from friture.level_data import LevelData

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (C) 2021 Timothée Lecomte

# This file is part of Friture.
#
# Friture is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as published by
# the Free Software Foundation.
#
# Friture is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Friture.  If not, see <http://www.gnu.org/licenses/>.



class LevelViewModel(QtCore.QObject):
    two_channels_changed = QtCore.pyqtSignal(bool)

    def __init__(self, parent=None):
        super().__init__(parent)

        self._two_channels = False


        self._level_data = LevelData(self)