server/libs/effects/effect.py
def detect_freqs(self):
        """
        Function that updates current_freq_detects. Any visualisation algorithm can check if
        there is currently a beat, low, mid, or high by querying the self.current_freq_detects dict.
        """
        n_fft_bins = self._config["general_settings"]["N_FFT_BINS"]
        channel_avgs = []
        differences = []

        for i in range(n_fft_bins):
            channel_avgs.append(sum(self.freq_channels[i]) / len(self.freq_channels[i]))
            if channel_avgs[i] != 0:
                differences.append(((self.freq_channels[i][0] - channel_avgs[i]) * 100) // channel_avgs[i])
            else:
                differences.append(0)
        for i in ["beat", "low", "mid", "high"]:
            if (any(differences[j] >= self.min_percent_diff[i]
                    and self.freq_channels[j][0] >= self.min_detect_amplitude[i]
                    for j in range(*self.detection_ranges[i]))
                and (time() - self.prev_freq_detects[i] > 0.2)
                    and len(self.freq_channels[0]) == self.freq_channel_history):
                self.prev_freq_detects[i] = time()
                self.current_freq_detects[i] = True
            else:
                self.current_freq_detects[i] = False

        Function that updates current_freq_detects. Any visualisation algorithm can check if
        there is currently a beat, low, mid, or high by querying the self.current_freq_detects dict.
        
Function that updates current_freq_detects. Any visualisation algorithm can check if
there is currently a beat, low, mid, or high by querying the self.current_freq_detects dict.
Function that updates current_freq_detects . Any visualisation algorithm can check if there is currently a beat low mid or high by querying the self . current_freq_detects dict .
def detect_freqs(self):
        n_fft_bins = self._config["general_settings"]["N_FFT_BINS"]
        channel_avgs = []
        differences = []
        for i in range(n_fft_bins):
            channel_avgs.append(sum(self.freq_channels[i]) / len(self.freq_channels[i]))
            if channel_avgs[i] != 0:
                differences.append(((self.freq_channels[i][0] - channel_avgs[i]) * 100) // channel_avgs[i])
            else:
                differences.append(0)
        for i in ["beat", "low", "mid", "high"]:
            if (any(differences[j] >= self.min_percent_diff[i]
                    and self.freq_channels[j][0] >= self.min_detect_amplitude[i]
                    for j in range(*self.detection_ranges[i]))
                and (time() - self.prev_freq_detects[i] > 0.2)
                    and len(self.freq_channels[0]) == self.freq_channel_history):
                self.prev_freq_detects[i] = time()
                self.current_freq_detects[i] = True
            else:
                self.current_freq_detects[i] = False
def detect_freqs ( self ) : n_fft_bins = self . _config [ "general_settings" ] [ "N_FFT_BINS" ] channel_avgs = [ ] differences = [ ] for i in range ( n_fft_bins ) : channel_avgs . append ( sum ( self . freq_channels [ i ] ) / len ( self . freq_channels [ i ] ) ) if channel_avgs [ i ] != 0 : differences . append ( ( ( self . freq_channels [ i ] [ 0 ] - channel_avgs [ i ] ) * 100 ) // channel_avgs [ i ] ) else : differences . append ( 0 ) for i in [ "beat" , "low" , "mid" , "high" ] : if ( any ( differences [ j ] >= self . min_percent_diff [ i ] and self . freq_channels [ j ] [ 0 ] >= self . min_detect_amplitude [ i ] for j in range ( * self . detection_ranges [ i ] ) ) and ( time ( ) - self . prev_freq_detects [ i ] > 0.2 ) and len ( self . freq_channels [ 0 ] ) == self . freq_channel_history ) : self . prev_freq_detects [ i ] = time ( ) self . current_freq_detects [ i ] = True else : self . current_freq_detects [ i ] = False
Function that updates current_freq_detects.
Function that updates current_freq_detects .
"""
        Function that updates current_freq_detects. Any visualisation algorithm can check if
        there is currently a beat, low, mid, or high by querying the self.current_freq_detects dict.
        """
self