Various improvements to the nabu media player to prepare for merging into ESPHome. The biggest change uses the audio_dac component in #59 for mute and volume controls.
Notable new features:
Volume control is handled by an audio_dac component. If it isn't available, it falls back to software volume control.
Volume and mute states are saved using a preference object and are restored after soft and hard resets.
HTTP connections are kept alive to properly handle long pauses. It also ends an audio stream after encountering HTTP errors to avoid going into a stuck state.
Code improvements:
Local media files are properly validated at the codegen stage
The AudioMixer class has been cleaned up and refactored for readability
The Helix MP3 decoder no longer requires compiling with no-narrowing
Removed code for idle muting; it wasn't used anymore. We can use the base media_player's on_idle trigger to cut power to the on-board amp to avoid quiet hissing at idle.
Buffers have been tuned a bit better. Adjustments to the dma buffers in the speaker task reduce audio stutters at the start of mixing media and announcement streams.
Attempts to reduce the amount of blocking in the reading and decoding tasks. Needs more experimentation to see if the current values are optimal.
The major TODO list is going down! Here are some of the big ones:
Move the various audio decoders and resampler into their own separate PlatformIO library
The AudioResampler class still needs a lot of work. Eventually I want to have an esp-dsp based resampler for upsampling by integer values. It will use less CPU to upsample 16kHz PCM audio using these optimized functions compared to decoding 48 kHz FLAC. This will only be used for announcements. It is partially implemented, but it still causes some audio pops. As such, the current code always uses the slower floating point based resampler.
Add a YAML action to play local media files. I've started the process in some commented out code, but it missing a registry of local files in the codegen stage.
Various improvements to the nabu media player to prepare for merging into ESPHome. The biggest change uses the
audio_dac
component in #59 for mute and volume controls.Notable new features:
audio_dac
component. If it isn't available, it falls back to software volume control.Code improvements:
no-narrowing
media_player
'son_idle
trigger to cut power to the on-board amp to avoid quiet hissing at idle.The major TODO list is going down! Here are some of the big ones: