From d37bf24d9011addbfbd40942a4e9bbf26de7df00 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Thu, 23 May 2013 13:58:51 -0400 Subject: 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 Tested-by: Michael Sevakis --- apps/plugins/oscilloscope.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'apps/plugins/oscilloscope.c') 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) /** Waveform View **/ #ifdef OSCILLOSCOPE_GRAPHMODE -static int16_t waveform_buffer[2*ALIGN_UP(NATIVE_FREQUENCY, 2048)+2*2048] +static int16_t waveform_buffer[2*ALIGN_UP(PLAY_SAMPR_MAX, 2048)+2*2048] MEM_ALIGN_ATTR; static size_t waveform_buffer_threshold = 0; static size_t volatile waveform_buffer_have = 0; static size_t waveform_buffer_break = 0; +static unsigned long mixer_sampr = PLAY_SAMPR_DEFAULT; #define PCM_SAMPLESIZE (2*sizeof(int16_t)) -#define PCM_BYTERATE (NATIVE_FREQUENCY*PCM_SAMPLESIZE) +#define PCM_BYTERATE(sampr) ((sampr)*PCM_SAMPLESIZE) #define WAVEFORM_SCALE_PCM(full_scale, sample) \ ((((full_scale) * (sample)) + (1 << 14)) >> 15) @@ -1390,7 +1391,7 @@ static long anim_waveform_horizontal(void) return cur_tick + HZ/5; } - int count = (NATIVE_FREQUENCY*osc_delay + 100*HZ - 1) / (100*HZ); + int count = (mixer_sampr*osc_delay + 100*HZ - 1) / (100*HZ); waveform_buffer_set_threshold(count*PCM_SAMPLESIZE); @@ -1516,7 +1517,8 @@ static long anim_waveform_horizontal(void) osd_lcd_update(); long delay = get_next_delay(); - return cur_tick + delay - waveform_buffer_have * HZ / PCM_BYTERATE; + return cur_tick + delay - waveform_buffer_have * HZ / + PCM_BYTERATE(mixer_sampr); } static void anim_waveform_plot_filled_v(int y, int y_prev, @@ -1583,7 +1585,7 @@ static long anim_waveform_vertical(void) return cur_tick + HZ/5; } - int count = (NATIVE_FREQUENCY*osc_delay + 100*HZ - 1) / (100*HZ); + int count = (mixer_sampr*osc_delay + 100*HZ - 1) / (100*HZ); waveform_buffer_set_threshold(count*PCM_SAMPLESIZE); @@ -1709,7 +1711,8 @@ static long anim_waveform_vertical(void) osd_lcd_update(); long delay = get_next_delay(); - return cur_tick + delay - waveform_buffer_have * HZ / PCM_BYTERATE; + return cur_tick + delay - waveform_buffer_have * HZ + / PCM_BYTERATE(mixer_sampr); } static void anim_waveform_exit(void) @@ -1872,6 +1875,10 @@ static void osc_setup(void) osd_lcd_update(); #endif +#ifdef OSCILLOSCOPE_GRAPHMODE + mixer_sampr = rb->mixer_get_frequency(); +#endif + /* Turn off backlight timeout */ backlight_ignore_timeout(); graphmode_setup(); -- cgit v1.2.3