diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2013-05-23 13:58:51 -0400 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2013-07-06 04:22:04 +0200 |
commit | d37bf24d9011addbfbd40942a4e9bbf26de7df00 (patch) | |
tree | dafb7eaeb494081668a4841d490fce2bfbb2438d /apps/plugins/oscilloscope.c | |
parent | 00faabef5e902008172e08d3bcd77683cbafef51 (diff) | |
download | rockbox-d37bf24d9011addbfbd40942a4e9bbf26de7df00.tar.gz rockbox-d37bf24d9011addbfbd40942a4e9bbf26de7df00.zip |
Enable setting of global output samplerate on certain targets.
Replaces the NATIVE_FREQUENCY constant with a configurable frequency.
The user may select 48000Hz if the hardware supports it. The default is
still 44100Hz and the minimum is 44100Hz. The setting is located in the
playback settings, under "Frequency".
"Frequency" was duplicated in english.lang for now to avoid having to
fix every .lang file for the moment and throwing everything out of sync
because of the new play_frequency feature in features.txt. The next
cleanup should combine it with the one included for recording and
generalize the ID label.
If the hardware doesn't support 48000Hz, no setting will be available.
On particular hardware where very high rates are practical and desireable,
the upper bound can be extended by patching.
The PCM mixer can be configured to play at the full hardware frequency
range. The DSP core can configure to the hardware minimum up to the
maximum playback setting (some buffers must be reserved according to
the maximum rate).
If only 44100Hz is supported or possible on a given target for playback,
using the DSP and mixer at other samperates is possible if the hardware
offers them.
Change-Id: I6023cf0c0baa8bc6292b6919b4dd3618a6a25622
Reviewed-on: http://gerrit.rockbox.org/479
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested-by: Michael Sevakis <jethead71@rockbox.org>
Diffstat (limited to 'apps/plugins/oscilloscope.c')
-rw-r--r-- | apps/plugins/oscilloscope.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c index a4ec6a8789..4d807493d3 100644 --- a/apps/plugins/oscilloscope.c +++ b/apps/plugins/oscilloscope.c | |||
@@ -1200,13 +1200,14 @@ static long anim_peaks_vertical(void) | |||
1200 | /** Waveform View **/ | 1200 | /** Waveform View **/ |
1201 | 1201 | ||
1202 | #ifdef OSCILLOSCOPE_GRAPHMODE | 1202 | #ifdef OSCILLOSCOPE_GRAPHMODE |
1203 | static int16_t waveform_buffer[2*ALIGN_UP(NATIVE_FREQUENCY, 2048)+2*2048] | 1203 | static int16_t waveform_buffer[2*ALIGN_UP(PLAY_SAMPR_MAX, 2048)+2*2048] |
1204 | MEM_ALIGN_ATTR; | 1204 | MEM_ALIGN_ATTR; |
1205 | static size_t waveform_buffer_threshold = 0; | 1205 | static size_t waveform_buffer_threshold = 0; |
1206 | static size_t volatile waveform_buffer_have = 0; | 1206 | static size_t volatile waveform_buffer_have = 0; |
1207 | static size_t waveform_buffer_break = 0; | 1207 | static size_t waveform_buffer_break = 0; |
1208 | static unsigned long mixer_sampr = PLAY_SAMPR_DEFAULT; | ||
1208 | #define PCM_SAMPLESIZE (2*sizeof(int16_t)) | 1209 | #define PCM_SAMPLESIZE (2*sizeof(int16_t)) |
1209 | #define PCM_BYTERATE (NATIVE_FREQUENCY*PCM_SAMPLESIZE) | 1210 | #define PCM_BYTERATE(sampr) ((sampr)*PCM_SAMPLESIZE) |
1210 | 1211 | ||
1211 | #define WAVEFORM_SCALE_PCM(full_scale, sample) \ | 1212 | #define WAVEFORM_SCALE_PCM(full_scale, sample) \ |
1212 | ((((full_scale) * (sample)) + (1 << 14)) >> 15) | 1213 | ((((full_scale) * (sample)) + (1 << 14)) >> 15) |
@@ -1390,7 +1391,7 @@ static long anim_waveform_horizontal(void) | |||
1390 | return cur_tick + HZ/5; | 1391 | return cur_tick + HZ/5; |
1391 | } | 1392 | } |
1392 | 1393 | ||
1393 | int count = (NATIVE_FREQUENCY*osc_delay + 100*HZ - 1) / (100*HZ); | 1394 | int count = (mixer_sampr*osc_delay + 100*HZ - 1) / (100*HZ); |
1394 | 1395 | ||
1395 | waveform_buffer_set_threshold(count*PCM_SAMPLESIZE); | 1396 | waveform_buffer_set_threshold(count*PCM_SAMPLESIZE); |
1396 | 1397 | ||
@@ -1516,7 +1517,8 @@ static long anim_waveform_horizontal(void) | |||
1516 | osd_lcd_update(); | 1517 | osd_lcd_update(); |
1517 | 1518 | ||
1518 | long delay = get_next_delay(); | 1519 | long delay = get_next_delay(); |
1519 | return cur_tick + delay - waveform_buffer_have * HZ / PCM_BYTERATE; | 1520 | return cur_tick + delay - waveform_buffer_have * HZ / |
1521 | PCM_BYTERATE(mixer_sampr); | ||
1520 | } | 1522 | } |
1521 | 1523 | ||
1522 | static void anim_waveform_plot_filled_v(int y, int y_prev, | 1524 | static void anim_waveform_plot_filled_v(int y, int y_prev, |
@@ -1583,7 +1585,7 @@ static long anim_waveform_vertical(void) | |||
1583 | return cur_tick + HZ/5; | 1585 | return cur_tick + HZ/5; |
1584 | } | 1586 | } |
1585 | 1587 | ||
1586 | int count = (NATIVE_FREQUENCY*osc_delay + 100*HZ - 1) / (100*HZ); | 1588 | int count = (mixer_sampr*osc_delay + 100*HZ - 1) / (100*HZ); |
1587 | 1589 | ||
1588 | waveform_buffer_set_threshold(count*PCM_SAMPLESIZE); | 1590 | waveform_buffer_set_threshold(count*PCM_SAMPLESIZE); |
1589 | 1591 | ||
@@ -1709,7 +1711,8 @@ static long anim_waveform_vertical(void) | |||
1709 | osd_lcd_update(); | 1711 | osd_lcd_update(); |
1710 | 1712 | ||
1711 | long delay = get_next_delay(); | 1713 | long delay = get_next_delay(); |
1712 | return cur_tick + delay - waveform_buffer_have * HZ / PCM_BYTERATE; | 1714 | return cur_tick + delay - waveform_buffer_have * HZ |
1715 | / PCM_BYTERATE(mixer_sampr); | ||
1713 | } | 1716 | } |
1714 | 1717 | ||
1715 | static void anim_waveform_exit(void) | 1718 | static void anim_waveform_exit(void) |
@@ -1872,6 +1875,10 @@ static void osc_setup(void) | |||
1872 | osd_lcd_update(); | 1875 | osd_lcd_update(); |
1873 | #endif | 1876 | #endif |
1874 | 1877 | ||
1878 | #ifdef OSCILLOSCOPE_GRAPHMODE | ||
1879 | mixer_sampr = rb->mixer_get_frequency(); | ||
1880 | #endif | ||
1881 | |||
1875 | /* Turn off backlight timeout */ | 1882 | /* Turn off backlight timeout */ |
1876 | backlight_ignore_timeout(); | 1883 | backlight_ignore_timeout(); |
1877 | graphmode_setup(); | 1884 | graphmode_setup(); |