How to use the ledfx.events.GraphUpdateEvent function in LedFx

To help you get started, weโ€™ve selected a few LedFx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ahodges9 / LedFx / ledfx / effects / legacyAudio.py View on Github external
filter_banks = np.sum(filter_banks, axis=0)
        filter_banks = filter_banks**2.0

        # Gain normalization
        self.mel_gain.update(np.max(filter_banks))
        filter_banks /= self.mel_gain.value
        filter_banks = self.mel_smoothing.update(filter_banks)

        # # TODO: Look into some better gain normalization as there seems to be some
        # # issues with variable volume.
        # self.mel_gain.update(np.mean(gaussian_filter1d(filter_banks, sigma=1.0)))
        # #filter_banks -= (np.mean(filter_banks, axis=0) + 1e-8)
        # filter_banks /= self.mel_gain.value
        # filter_banks = self.mel_smoothing.update(filter_banks)

        self._ledfx.events.fire_event(GraphUpdateEvent(
            'legacyMelbank', filter_banks, self.melbank_frequencies))

        return filter_banks
github ahodges9 / LedFx / ledfx / effects / audio.py View on Github external
"""Returns the raw melbank curve"""

        if self.volume() > self._config['min_volume']:
            # Compute the filterbank from the frequency information
            raw_filter_banks = self.filterbank(self.frequency_domain())
            raw_filter_banks = raw_filter_banks ** 2.0

            self.mel_gain.update(np.max(smooth(raw_filter_banks, sigma=1.0)))
            filter_banks = raw_filter_banks / self.mel_gain.value
            filter_banks = self.mel_smoothing.update(filter_banks)
        else:
            raw_filter_banks = np.zeros(self._config['samples'])
            filter_banks = raw_filter_banks

        if self._ledfx.dev_enabled():
            self._ledfx.events.fire_event(GraphUpdateEvent(
                'raw', raw_filter_banks, np.array(self.melbank_frequencies)))
            self._ledfx.events.fire_event(GraphUpdateEvent(
                'melbank', filter_banks, np.array(self.melbank_frequencies)))
        return filter_banks
github ahodges9 / LedFx / ledfx / effects / audio.py View on Github external
if self.volume() > self._config['min_volume']:
            # Compute the filterbank from the frequency information
            raw_filter_banks = self.filterbank(self.frequency_domain())
            raw_filter_banks = raw_filter_banks ** 2.0

            self.mel_gain.update(np.max(smooth(raw_filter_banks, sigma=1.0)))
            filter_banks = raw_filter_banks / self.mel_gain.value
            filter_banks = self.mel_smoothing.update(filter_banks)
        else:
            raw_filter_banks = np.zeros(self._config['samples'])
            filter_banks = raw_filter_banks

        if self._ledfx.dev_enabled():
            self._ledfx.events.fire_event(GraphUpdateEvent(
                'raw', raw_filter_banks, np.array(self.melbank_frequencies)))
            self._ledfx.events.fire_event(GraphUpdateEvent(
                'melbank', filter_banks, np.array(self.melbank_frequencies)))
        return filter_banks
github ahodges9 / LedFx / ledfx / effects / audio.py View on Github external
# force all zeros when below the volume threshold
        if self._volume_filter.value > self._config['min_volume']:
            self._processed_audio_sample = self._raw_audio_sample

            # Perform a pre-emphasis to balance the highs and lows
            if self.pre_emphasis:
                self._processed_audio_sample = self.pre_emphasis(self._raw_audio_sample)

            # Pass into the phase vocoder to get a windowed FFT
            self._frequency_domain = self._phase_vocoder(self._processed_audio_sample)
        else:
            self._frequency_domain = self._frequency_domain_null

        # Light up some notifications for developer mode
        if self._ledfx.dev_enabled():
            self._ledfx.events.fire_event(GraphUpdateEvent(
                'fft', self._frequency_domain.norm, self._frequency_domain_x))