How to use the ledfx.effects.audio.AudioReactiveEffect 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 / spectrum.py View on Github external
from ledfx.effects.audio import AudioReactiveEffect
import voluptuous as vol
import numpy as np

class SpectrumAudioEffect(AudioReactiveEffect):

    NAME = "Spectrum"
    _prev_y = None

    def config_updated(self, config):

        # Create all the filters used for the effect
        self._r_filter = self.create_filter(
            alpha_decay = 0.2,
            alpha_rise = 0.99)
        self._b_filter = self.create_filter(
            alpha_decay = 0.1,
            alpha_rise = 0.5)

    def audio_data_updated(self, data):
github ahodges9 / LedFx / ledfx / effects / scroll.py View on Github external
from ledfx.effects.audio import AudioReactiveEffect, FREQUENCY_RANGES_SIMPLE
from ledfx.effects.gradient import GradientEffect
import voluptuous as vol
import numpy as np


class ScrollAudioEffect(AudioReactiveEffect):

    NAME = "Scroll"

    CONFIG_SCHEMA = vol.Schema({
        vol.Optional('blur', description='Amount to blur the effect', default = 3.0): vol.Coerce(float),
        vol.Optional('mirror', description='Mirror the effect', default = True): bool,
        vol.Optional('speed', description='Speed of the effect', default = 4):  vol.All(vol.Coerce(int), vol.Range(min=1)),
        vol.Optional('decay', description='Decay rate of the scroll', default = 0.97):  vol.All(vol.Coerce(float), vol.Range(min=0.2, max=1.0)),
    })

    def config_updated(self, config):

        # TODO: Determine how buffers based on the pixels should be
        # allocated. Technically there is no guarantee that the effect
        # is bound to a device while the config gets updated. Might need
        # to move to a model where effects are created for a device and
github ahodges9 / LedFx / ledfx / effects / energy.py View on Github external
from ledfx.effects.audio import AudioReactiveEffect
import voluptuous as vol
import numpy as np

class EnergyAudioEffect(AudioReactiveEffect):

    NAME = "Energy"
    CONFIG_SCHEMA = vol.Schema({
        vol.Optional('blur', description='Amount to blur the effect', default = 4.0): vol.Coerce(float),
        vol.Optional('mirror', description='Mirror the effect', default = True): bool,
        vol.Optional('scale', description='Scale factor for the energy', default = 1.0):  vol.All(vol.Coerce(float), vol.Range(min=0.0, max=5.0)),
    })

    def config_updated(self, config):
        self._p_filter = self.create_filter(
            alpha_decay = 0.1,
            alpha_rise = 0.50)

    def audio_data_updated(self, data):

        # Calculate the low, mids, and high indexes scaling based on the pixel count