diff --git a/libs/libc/Kconfig b/libs/libc/Kconfig index 3c271532962..0496f030df2 100644 --- a/libs/libc/Kconfig +++ b/libs/libc/Kconfig @@ -6,6 +6,7 @@ comment "Standard C Library Options" source libs/libc/stdio/Kconfig +source libs/libc/audio/Kconfig source libs/libc/math/Kconfig source libs/libc/machine/Kconfig source libs/libc/stdlib/Kconfig diff --git a/libs/libc/Makefile b/libs/libc/Makefile index ca0d4122bc1..572ec229f30 100644 --- a/libs/libc/Makefile +++ b/libs/libc/Makefile @@ -149,7 +149,7 @@ endif # Context -context: +context:: ifeq ($(CONFIG_LIB_ZONEINFO_ROMFS),y) $(Q) $(MAKE) -C zoneinfo context BIN=$(BIN) endif @@ -166,11 +166,11 @@ ifeq ($(CONFIG_LIB_ZONEINFO_ROMFS),y) endif $(Q) touch $@ -depend: .depend +depend:: .depend # Clean most derived files, retaining the configuration -clean: +clean:: $(Q) $(MAKE) -C bin clean $(Q) $(MAKE) -C kbin clean $(Q) $(MAKE) -C zoneinfo clean BIN=$(BIN) @@ -180,7 +180,7 @@ clean: # Deep clean -- removes all traces of the configuration -distclean: clean +distclean:: clean $(Q) $(MAKE) -C bin distclean $(Q) $(MAKE) -C kbin distclean $(Q) $(MAKE) -C zoneinfo distclean BIN=$(BIN) diff --git a/libs/libc/audio/Kconfig b/libs/libc/audio/Kconfig new file mode 100644 index 00000000000..df8024422e0 --- /dev/null +++ b/libs/libc/audio/Kconfig @@ -0,0 +1,7 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + + +source libs/libc/audio/libsrc/Kconfig diff --git a/libs/libc/audio/Make.defs b/libs/libc/audio/Make.defs index 33ea6e97406..ae41ee2b77c 100644 --- a/libs/libc/audio/Make.defs +++ b/libs/libc/audio/Make.defs @@ -36,6 +36,8 @@ ifeq ($(CONFIG_AUDIO),y) CSRCS += lib_buffer.c +include audio/libsrc/Make.defs + # Add the audio/ directory to the build DEPPATH += --dep-path audio diff --git a/libs/libc/audio/libsrc/0001-add-audio-quality-options.patch b/libs/libc/audio/libsrc/0001-add-audio-quality-options.patch new file mode 100644 index 00000000000..ec0cee8935c --- /dev/null +++ b/libs/libc/audio/libsrc/0001-add-audio-quality-options.patch @@ -0,0 +1,82 @@ +From 8d709a69b23efc52030824ae21db889589467d8c Mon Sep 17 00:00:00 2001 +From: Alin Jerpelea +Date: Mon, 16 Nov 2020 09:44:17 +0100 +Subject: [PATCH] add audio quality options + +Many NuttX boards have limited rerources and will have to use +compile time quality options to reduce resource usage + +Signed-off-by: Alin Jerpelea +--- + src/src_sinc.c | 30 +++++++++++++++++++++++++----- + 1 files changed, 25 insertions(+), 5 deletions(-) + +diff --git a/src/src_sinc.c b/src/src_sinc.c +index 0a22708..b81326e 100644 +--- a/src/src_sinc.c ++++ b/src/src_sinc.c +@@ -40,9 +40,17 @@ typedef int32_t increment_t ; + typedef float coeff_t ; + typedef int _CHECK_SHIFT_BITS[2 * (SHIFT_BITS < sizeof (increment_t) * 8 - 1) - 1]; /* sanity check. */ + +-#include "fastest_coeffs.h" +-#include "mid_qual_coeffs.h" +-#include "high_qual_coeffs.h" ++#if CONFIG_AUDIO_SRC_QUALITY == 2 ++ #include "fastest_coeffs.h" ++#elif CONFIG_AUDIO_SRC_QUALITY == 1 ++ #include "mid_qual_coeffs.h" ++#elif if CONFIG_AUDIO_SRC_QUALITY == 0 ++ #include "high_qual_coeffs.h" ++#else ++ #include "fastest_coeffs.h" ++ #include "mid_qual_coeffs.h" ++ #include "high_qual_coeffs.h" ++#endif + + typedef struct + { int sinc_magic_marker ; +@@ -206,6 +214,19 @@ sinc_filter_new (int converter_type, int channels) + if (priv) + { + priv->sinc_magic_marker = SINC_MAGIC_MARKER ; ++#if CONFIG_AUDIO_SRC_QUALITY == 2 ++ priv->coeffs = fastest_coeffs.coeffs ; ++ priv->coeff_half_len = ARRAY_LEN (fastest_coeffs.coeffs) - 2 ; ++ priv->index_inc = fastest_coeffs.increment ; ++#elif CONFIG_AUDIO_SRC_QUALITY == 1 ++ priv->coeffs = slow_mid_qual_coeffs.coeffs ; ++ priv->coeff_half_len = ARRAY_LEN (slow_mid_qual_coeffs.coeffs) - 2 ; ++ priv->index_inc = slow_mid_qual_coeffs.increment ; ++#elif CONFIG_AUDIO_SRC_QUALITY == 0 ++ priv->coeffs = slow_high_qual_coeffs.coeffs ; ++ priv->coeff_half_len = ARRAY_LEN (slow_high_qual_coeffs.coeffs) - 2 ; ++ priv->index_inc = slow_high_qual_coeffs.increment ; ++#else + switch (converter_type) + { + case SRC_SINC_FASTEST : +@@ -213,19 +234,18 @@ sinc_filter_new (int converter_type, int channels) + priv->coeff_half_len = ARRAY_LEN (fastest_coeffs.coeffs) - 2 ; + priv->index_inc = fastest_coeffs.increment ; + break ; +- + case SRC_SINC_MEDIUM_QUALITY : + priv->coeffs = slow_mid_qual_coeffs.coeffs ; + priv->coeff_half_len = ARRAY_LEN (slow_mid_qual_coeffs.coeffs) - 2 ; + priv->index_inc = slow_mid_qual_coeffs.increment ; + break ; +- + case SRC_SINC_BEST_QUALITY : + priv->coeffs = slow_high_qual_coeffs.coeffs ; + priv->coeff_half_len = ARRAY_LEN (slow_high_qual_coeffs.coeffs) - 2 ; + priv->index_inc = slow_high_qual_coeffs.increment ; + break ; + } ++#endif + + priv->b_len = 3 * (int) lrint ((priv->coeff_half_len + 2.0) / priv->index_inc * SRC_MAX_RATIO + 1) ; + priv->b_len = MAX (priv->b_len, 4096) ; +-- +2.17.1 + diff --git a/libs/libc/audio/libsrc/Kconfig b/libs/libc/audio/libsrc/Kconfig new file mode 100644 index 00000000000..de7d0c1f43e --- /dev/null +++ b/libs/libc/audio/libsrc/Kconfig @@ -0,0 +1,23 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config AUDIO_SRC + bool "Audio Samplerate Convertor Library" + default n + ---help--- + Enable build for various SRC functions + +if AUDIO_SRC + +config AUDIO_SRC_QUALITY + int "Audio Conversion Quality [0/1/2]" + default 2 + ---help--- + Audio Conversion Quality [0/1/2] + 0 Slowest conversion speed with best quality. + 1 Medium conversion speed with medium qulity + 2 Fastest conversion with lowest Quality + +endif # LIBSRC diff --git a/libs/libc/audio/libsrc/Make.defs b/libs/libc/audio/libsrc/Make.defs new file mode 100644 index 00000000000..35ef8ac0b89 --- /dev/null +++ b/libs/libc/audio/libsrc/Make.defs @@ -0,0 +1,53 @@ +############################################################################ +# audio/libsrc/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +ifeq ($(CONFIG_AUDIO_SRC),y) + +PACKAGE=libsamplerate +VERSION=0.1.9 + +libsamplerate: + $(Q) wget https://codeload.github.com/libsndfile/libsamplerate/zip/master -O libsamplerate.zip + $(Q) unzip -o libsamplerate.zip + $(Q) mv libsamplerate-master libsamplerate + $(Q) patch -Np1 -d libsamplerate