1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Solomon Peachy 2019-08-07 17:16:48 -04:00
parent a430e275dd
commit 5b23c9eb0a
4 changed files with 92 additions and 20 deletions

View file

@ -27,28 +27,67 @@
#define NBUF 2
#define MAX_SAMPLES 512
#ifndef SIMULATOR
#ifdef SIMULATOR
#define SAMPLE_RATE SAMPR_44 /* 44100 */
/* Simulator requires 44100Hz, and we can afford to use more voices */
#define SAMPLE_RATE SAMPR_44
#define MAX_VOICES 48
#elif (CONFIG_PLATFORM & PLATFORM_HOSTED)
/* All hosted targets have CPU to spare */
#define MAX_VOICES 48
#define SAMPLE_RATE SAMPR_44
#elif defined(CPU_PP)
/* Some of the pp based targets can't handle too many voices
mainly because they have to use 44100Hz sample rate, this could be
improved to increase MAX_VOICES for targets that can do 22kHz */
#ifdef CPU_PP
#define MAX_VOICES 16
#elif (CONFIG_PLATFORM & PLATFORM_HOSTED)
#define MAX_VOICES 48
#define SAMPLE_RATE HW_SAMPR_MIN_GE_22
#if HW_SAMPR_CAPS & SAMPR_CAP_22
#define MAX_VOICES 24 /* General MIDI minimum */
#else
#define MAX_VOICES 24 /* Note: 24 midi channels is the minimum general midi spec implementation */
#endif /* CPU_PP */
#else /* Simulator requires 44100Hz, and we can afford to use more voices */
#define SAMPLE_RATE SAMPR_44
#define MAX_VOICES 48
#define MAX_VOICES 16
#endif
#elif defined(CPU_MIPS)
/* All MIPS targets are pretty fast */
#define MAX_VOICES 48
#define SAMPLE_RATE SAMPR_44
#elif defined(CPU_ARM)
/* ARMv4 targets are slow, but treat everything else as fast */
#if (ARM_ARCH >= 6)
#define MAX_VOICES 32
#define SAMPLE_RATE SAMPR_44
#elif (ARM_ARCH >= 5)
#define MAX_VOICES 32
#define SAMPLE_RATE HW_SAMPR_MIN_GE_22
#else /* ie v4 */
#define SAMPLE_RATE HW_SAMPR_MIN_GE_22
#if HW_SAMPR_CAPS & SAMPR_CAP_22
#define MAX_VOICES 24 /* General MIDI minimum */
#else
#define MAX_VOICES 16
#endif
#endif /* ARM_ARCH < 5*/
#else /* !CPU_ARM */
/* Treat everything else as slow */
#define SAMPLE_RATE HW_SAMPR_MIN_GE_22
#if HW_SAMPR_CAPS & SAMPR_CAP_22
#define MAX_VOICES 24 /* General MIDI minimum */
#else
#define MAX_VOICES 16
#endif
#endif /* Wrap it up. */
#define BYTE unsigned char
/* Data chunk ID types, returned by readID() */