summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2019-08-07 17:16:48 -0400
committerSolomon Peachy <pizza@shaftnet.org>2019-08-08 22:37:30 +0200
commit5b23c9eb0a97534f0d0fc3aa0c1ad302199eb8dc (patch)
tree7151fdb71b085b9a43113832c0d478b84bfbbf49 /apps
parenta430e275dddab24059ba15d2621e518562392540 (diff)
downloadrockbox-5b23c9eb0a97534f0d0fc3aa0c1ad302199eb8dc.tar.gz
rockbox-5b23c9eb0a97534f0d0fc3aa0c1ad302199eb8dc.zip
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
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/midi/midiutil.h57
-rw-r--r--apps/plugins/mikmod/mikmod_supp.h23
-rw-r--r--apps/plugins/sdl/include/SDL_config_rockbox.h6
3 files changed, 71 insertions, 15 deletions
diff --git a/apps/plugins/midi/midiutil.h b/apps/plugins/midi/midiutil.h
index 72bff11b3f..ee9769b108 100644
--- a/apps/plugins/midi/midiutil.h
+++ b/apps/plugins/midi/midiutil.h
@@ -27,28 +27,67 @@
27#define NBUF 2 27#define NBUF 2
28#define MAX_SAMPLES 512 28#define MAX_SAMPLES 512
29 29
30#ifndef SIMULATOR 30#ifdef SIMULATOR
31 31
32#define SAMPLE_RATE SAMPR_44 /* 44100 */ 32/* Simulator requires 44100Hz, and we can afford to use more voices */
33#define SAMPLE_RATE SAMPR_44
34#define MAX_VOICES 48
35
36#elif (CONFIG_PLATFORM & PLATFORM_HOSTED)
37
38/* All hosted targets have CPU to spare */
39#define MAX_VOICES 48
40#define SAMPLE_RATE SAMPR_44
41
42#elif defined(CPU_PP)
33 43
34/* Some of the pp based targets can't handle too many voices 44/* Some of the pp based targets can't handle too many voices
35 mainly because they have to use 44100Hz sample rate, this could be 45 mainly because they have to use 44100Hz sample rate, this could be
36 improved to increase MAX_VOICES for targets that can do 22kHz */ 46 improved to increase MAX_VOICES for targets that can do 22kHz */
37#ifdef CPU_PP 47#define SAMPLE_RATE HW_SAMPR_MIN_GE_22
48#if HW_SAMPR_CAPS & SAMPR_CAP_22
49#define MAX_VOICES 24 /* General MIDI minimum */
50#else
38#define MAX_VOICES 16 51#define MAX_VOICES 16
39#elif (CONFIG_PLATFORM & PLATFORM_HOSTED) 52#endif
53
54#elif defined(CPU_MIPS)
55
56/* All MIPS targets are pretty fast */
40#define MAX_VOICES 48 57#define MAX_VOICES 48
41#else 58#define SAMPLE_RATE SAMPR_44
42#define MAX_VOICES 24 /* Note: 24 midi channels is the minimum general midi spec implementation */
43#endif /* CPU_PP */
44 59
45#else /* Simulator requires 44100Hz, and we can afford to use more voices */ 60#elif defined(CPU_ARM)
46 61
62/* ARMv4 targets are slow, but treat everything else as fast */
63
64#if (ARM_ARCH >= 6)
65#define MAX_VOICES 32
47#define SAMPLE_RATE SAMPR_44 66#define SAMPLE_RATE SAMPR_44
48#define MAX_VOICES 48 67#elif (ARM_ARCH >= 5)
68#define MAX_VOICES 32
69#define SAMPLE_RATE HW_SAMPR_MIN_GE_22
70#else /* ie v4 */
71#define SAMPLE_RATE HW_SAMPR_MIN_GE_22
72#if HW_SAMPR_CAPS & SAMPR_CAP_22
73#define MAX_VOICES 24 /* General MIDI minimum */
74#else
75#define MAX_VOICES 16
76#endif
77#endif /* ARM_ARCH < 5*/
78
79#else /* !CPU_ARM */
49 80
81/* Treat everything else as slow */
82#define SAMPLE_RATE HW_SAMPR_MIN_GE_22
83#if HW_SAMPR_CAPS & SAMPR_CAP_22
84#define MAX_VOICES 24 /* General MIDI minimum */
85#else
86#define MAX_VOICES 16
50#endif 87#endif
51 88
89#endif /* Wrap it up. */
90
52#define BYTE unsigned char 91#define BYTE unsigned char
53 92
54/* Data chunk ID types, returned by readID() */ 93/* Data chunk ID types, returned by readID() */
diff --git a/apps/plugins/mikmod/mikmod_supp.h b/apps/plugins/mikmod/mikmod_supp.h
index 29fa7ebf35..ad8aaafebc 100644
--- a/apps/plugins/mikmod/mikmod_supp.h
+++ b/apps/plugins/mikmod/mikmod_supp.h
@@ -63,8 +63,29 @@ int mmsupp_sprintf(char *buf, const char *fmt, ... );
63 63
64extern const struct plugin_api * rb; 64extern const struct plugin_api * rb;
65 65
66#ifdef SIMULATOR
66 67
67#define SAMPLE_RATE SAMPR_44 /* 44100 */ 68#define SAMPLE_RATE SAMPR_44 /* Required by Simulator */
69
70#elif ((CONFIG_PLATFORM & PLATFORM_HOSTED) || defined(CPU_MIPS))
71
72#define SAMPLE_RATE SAMPR_44 /* All MIPS and hosted targets are fast */
73
74#elif defined(CPU_ARM)
75
76/* Treat ARMv5+ as fast */
77#if (ARM_ARCH >= 5)
78#define SAMPLE_RATE SAMPR_44
79#else
80#define SAMPLE_RATE SAMPR_MIN_GE_22
81#endif
82
83#else /* !CPU_ARM */
84
85/* Treat everyone else as slow */
86#define SAMPLE_RATE HW_SAMPR_MIN_GE_22
87
88#endif /* !SIMULATOR */
68 89
69#define BUF_SIZE 4096*8 90#define BUF_SIZE 4096*8
70#define NBUF 2 91#define NBUF 2
diff --git a/apps/plugins/sdl/include/SDL_config_rockbox.h b/apps/plugins/sdl/include/SDL_config_rockbox.h
index 40bd7fe177..91183ebf88 100644
--- a/apps/plugins/sdl/include/SDL_config_rockbox.h
+++ b/apps/plugins/sdl/include/SDL_config_rockbox.h
@@ -47,11 +47,7 @@
47#ifdef SIMULATOR 47#ifdef SIMULATOR
48#define RB_SAMPR SAMPR_44 48#define RB_SAMPR SAMPR_44
49#else 49#else
50#if HW_SAMPR_CAPS & SAMPR_CAP_22 50#define RB_SAMPR HW_SAMPR_MIN_GE_22 /* Min HW rate at least 22KHz */
51#define RB_SAMPR SAMPR_22
52#else
53#define RB_SAMPR HW_SAMPR_MIN
54#endif
55#endif 51#endif
56 52
57/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ 53/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */