From 5b23c9eb0a97534f0d0fc3aa0c1ad302199eb8dc Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Wed, 7 Aug 2019 17:16:48 -0400 Subject: Introduce HW_SAMPR_MIN_GE_22 macro Gives us the lowest HW sample rate that's >= 22KHz. Needed because some targets that don't support 22K support 11K or 8K, so HW_SAMPR_MIN will give us much lower quality than is acceptable. Take advantage of this new macro in the SDL, MIDI, and MIKMOD plugins, and implement a crude "fast enough" test to enable higher sample rates on more capable targets. Change-Id: I6ad38026fb3410c62da028e78512e027729bb851 --- firmware/export/pcm_sampr.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'firmware') diff --git a/firmware/export/pcm_sampr.h b/firmware/export/pcm_sampr.h index dcb1bdd80f..84f4466308 100644 --- a/firmware/export/pcm_sampr.h +++ b/firmware/export/pcm_sampr.h @@ -80,6 +80,11 @@ SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \ SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8) +/* List of sampling rates that are good enough for most purposes. */ +#define SAMPR_CAP_ALL_GE_22 (SAMPR_CAP_96 | SAMPR_CAP_88 | SAMPR_CAP_64 | \ + SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \ + SAMPR_CAP_24 | SAMPR_CAP_22) + #ifndef PCM_SAMPR_CONFIG_ONLY /* Master list of all "standard" rates supported. */ extern const unsigned long audio_master_sampr_list[SAMPR_NUM_FREQ]; @@ -231,6 +236,17 @@ extern const unsigned long hw_freq_sampr[HW_NUM_FREQ]; # define HW_SAMPR_MIN SAMPR_44 #endif +#define HW_SAMPR_CAPS_QUAL (HW_SAMPR_CAPS & SAMPR_CAP_ALL_GE_22) +#if HW_SAMPR_CAPS_QUAL & SAMPR_CAP_22 +# define HW_SAMPR_MIN_GE_22 SAMPR_22 +#elif HW_SAMPR_CAPS_QUAL & SAMPR_CAP_24 +# define HW_SAMPR_MIN_GE_22 SAMPR_24 +#elif HW_SAMPR_CAPS_QUAL & SAMPR_CAP_32 +# define HW_SAMPR_MIN_GE_22 SAMPR_32 +#else +# define HW_SAMPR_MIN_GE_22 SAMPR_44 +#endif + #ifdef HAVE_RECORDING #ifndef PCM_SAMPR_CONFIG_ONLY -- cgit