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:
parent
a430e275dd
commit
5b23c9eb0a
4 changed files with 92 additions and 20 deletions
|
@ -27,28 +27,67 @@
|
||||||
#define NBUF 2
|
#define NBUF 2
|
||||||
#define MAX_SAMPLES 512
|
#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
|
/* Some of the pp based targets can't handle too many voices
|
||||||
mainly because they have to use 44100Hz sample rate, this could be
|
mainly because they have to use 44100Hz sample rate, this could be
|
||||||
improved to increase MAX_VOICES for targets that can do 22kHz */
|
improved to increase MAX_VOICES for targets that can do 22kHz */
|
||||||
#ifdef CPU_PP
|
#define SAMPLE_RATE HW_SAMPR_MIN_GE_22
|
||||||
#define MAX_VOICES 16
|
#if HW_SAMPR_CAPS & SAMPR_CAP_22
|
||||||
#elif (CONFIG_PLATFORM & PLATFORM_HOSTED)
|
#define MAX_VOICES 24 /* General MIDI minimum */
|
||||||
#define MAX_VOICES 48
|
|
||||||
#else
|
#else
|
||||||
#define MAX_VOICES 24 /* Note: 24 midi channels is the minimum general midi spec implementation */
|
#define MAX_VOICES 16
|
||||||
#endif /* CPU_PP */
|
|
||||||
|
|
||||||
#else /* Simulator requires 44100Hz, and we can afford to use more voices */
|
|
||||||
|
|
||||||
#define SAMPLE_RATE SAMPR_44
|
|
||||||
#define MAX_VOICES 48
|
|
||||||
|
|
||||||
#endif
|
#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
|
#define BYTE unsigned char
|
||||||
|
|
||||||
/* Data chunk ID types, returned by readID() */
|
/* Data chunk ID types, returned by readID() */
|
||||||
|
|
|
@ -63,8 +63,29 @@ int mmsupp_sprintf(char *buf, const char *fmt, ... );
|
||||||
|
|
||||||
extern const struct plugin_api * rb;
|
extern const struct plugin_api * rb;
|
||||||
|
|
||||||
|
#ifdef SIMULATOR
|
||||||
|
|
||||||
#define SAMPLE_RATE SAMPR_44 /* 44100 */
|
#define SAMPLE_RATE SAMPR_44 /* Required by Simulator */
|
||||||
|
|
||||||
|
#elif ((CONFIG_PLATFORM & PLATFORM_HOSTED) || defined(CPU_MIPS))
|
||||||
|
|
||||||
|
#define SAMPLE_RATE SAMPR_44 /* All MIPS and hosted targets are fast */
|
||||||
|
|
||||||
|
#elif defined(CPU_ARM)
|
||||||
|
|
||||||
|
/* Treat ARMv5+ as fast */
|
||||||
|
#if (ARM_ARCH >= 5)
|
||||||
|
#define SAMPLE_RATE SAMPR_44
|
||||||
|
#else
|
||||||
|
#define SAMPLE_RATE SAMPR_MIN_GE_22
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else /* !CPU_ARM */
|
||||||
|
|
||||||
|
/* Treat everyone else as slow */
|
||||||
|
#define SAMPLE_RATE HW_SAMPR_MIN_GE_22
|
||||||
|
|
||||||
|
#endif /* !SIMULATOR */
|
||||||
|
|
||||||
#define BUF_SIZE 4096*8
|
#define BUF_SIZE 4096*8
|
||||||
#define NBUF 2
|
#define NBUF 2
|
||||||
|
|
|
@ -47,11 +47,7 @@
|
||||||
#ifdef SIMULATOR
|
#ifdef SIMULATOR
|
||||||
#define RB_SAMPR SAMPR_44
|
#define RB_SAMPR SAMPR_44
|
||||||
#else
|
#else
|
||||||
#if HW_SAMPR_CAPS & SAMPR_CAP_22
|
#define RB_SAMPR HW_SAMPR_MIN_GE_22 /* Min HW rate at least 22KHz */
|
||||||
#define RB_SAMPR SAMPR_22
|
|
||||||
#else
|
|
||||||
#define RB_SAMPR HW_SAMPR_MIN
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */
|
/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */
|
||||||
|
|
|
@ -80,6 +80,11 @@
|
||||||
SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \
|
SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \
|
||||||
SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8)
|
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
|
#ifndef PCM_SAMPR_CONFIG_ONLY
|
||||||
/* Master list of all "standard" rates supported. */
|
/* Master list of all "standard" rates supported. */
|
||||||
extern const unsigned long audio_master_sampr_list[SAMPR_NUM_FREQ];
|
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
|
# define HW_SAMPR_MIN SAMPR_44
|
||||||
#endif
|
#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
|
#ifdef HAVE_RECORDING
|
||||||
|
|
||||||
#ifndef PCM_SAMPR_CONFIG_ONLY
|
#ifndef PCM_SAMPR_CONFIG_ONLY
|
||||||
|
|
Loading…
Reference in a new issue