WLED icon indicating copy to clipboard operation
WLED copied to clipboard

Allow ADC attenuation for audio input to be selected

Open lvml opened this issue 6 months ago • 4 comments

Is your feature request related to a problem? Please describe.

Documents such as this or this describe "cheap microphone modules" as unusable for the "audio-reactive" modes primarily because the range of digital values obtained from the "cheap" microphones via the ADC is small.

However, in https://github.com/Aircoookie/WLED/blob/main/usermods/audioreactive/audio_source.h#L625 a fixed attenuation of 11db is deliberately set, in expectation of analog input between 150mV to 2450mV. This, of course, reduces the range of values to expect from the analog to digital conversion from "cheap" microphone modules that happen to deliver a smaller analog voltage range.

Describe the solution you'd like

Make the parameter to the adc1_config_channel_atten() call at https://github.com/Aircoookie/WLED/blob/main/usermods/audioreactive/audio_source.h#L625 subject to a configuration parameter, such that no attenuation (ADC_ATTEN_DB_0) can be selected.

Describe alternatives you've considered

Buying "better" microphones is probably always an option, but given that this is just about some lights blinking according to the music, this should really not require "high fidelity" input.

Additional context

none

lvml avatar Aug 04 '24 20:08 lvml