mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
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>
This commit is contained in:
parent
00faabef5e
commit
d37bf24d90
44 changed files with 677 additions and 230 deletions
|
@ -25,6 +25,7 @@
|
|||
#include "fracmul.h"
|
||||
#include "fixedpoint.h"
|
||||
#include "dsp_proc_entry.h"
|
||||
#include "dsp_misc.h"
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
|
@ -50,9 +51,10 @@ static struct resample_data
|
|||
int32_t history[2][3]; /* 08h: Last samples for interpolation (L+R)
|
||||
0 = oldest, 2 = newest */
|
||||
/* 20h */
|
||||
int32_t frequency; /* Virtual samplerate */
|
||||
unsigned int frequency; /* Virtual input samplerate */
|
||||
unsigned int frequency_out; /* Resampler output samplerate */
|
||||
struct dsp_buffer resample_buf; /* Buffer descriptor for resampled data */
|
||||
int32_t *resample_out_p[2]; /* Actual output buffer pointers */
|
||||
int32_t *resample_out_p[2]; /* Actual output buffer pointers */
|
||||
} resample_data[DSP_COUNT] IBSS_ATTR;
|
||||
|
||||
/* Actual worker function. Implemented here or in target assembly code. */
|
||||
|
@ -73,14 +75,16 @@ static void resample_flush(struct dsp_proc_entry *this)
|
|||
}
|
||||
|
||||
static bool resample_new_delta(struct resample_data *data,
|
||||
struct sample_format *format)
|
||||
struct sample_format *format,
|
||||
unsigned int fout)
|
||||
{
|
||||
int32_t frequency = format->frequency; /* virtual samplerate */
|
||||
unsigned int frequency = format->frequency; /* virtual samplerate */
|
||||
|
||||
data->frequency = frequency;
|
||||
data->delta = fp_div(frequency, NATIVE_FREQUENCY, 16);
|
||||
data->frequency_out = fout;
|
||||
data->delta = fp_div(frequency, fout, 16);
|
||||
|
||||
if (frequency == NATIVE_FREQUENCY)
|
||||
if (frequency == data->frequency_out)
|
||||
{
|
||||
/* NOTE: If fully glitch-free transistions from no resampling to
|
||||
resampling are desired, history should be maintained even when
|
||||
|
@ -232,20 +236,23 @@ static intptr_t resample_new_format(struct dsp_proc_entry *this,
|
|||
|
||||
DSP_PRINT_FORMAT(DSP_PROC_RESAMPLE, *format);
|
||||
|
||||
int32_t frequency = data->frequency;
|
||||
unsigned int frequency = data->frequency;
|
||||
unsigned int fout = dsp_get_output_frequency(dsp);
|
||||
bool active = dsp_proc_active(dsp, DSP_PROC_RESAMPLE);
|
||||
|
||||
if (format->frequency != frequency)
|
||||
if ((unsigned int)format->frequency != frequency ||
|
||||
data->frequency_out != fout)
|
||||
{
|
||||
DEBUGF(" DSP_PROC_RESAMPLE- new delta\n");
|
||||
active = resample_new_delta(data, format);
|
||||
DEBUGF(" DSP_PROC_RESAMPLE- new settings: %u %u\n",
|
||||
format->frequency, fout);
|
||||
active = resample_new_delta(data, format, fout);
|
||||
dsp_proc_activate(dsp, DSP_PROC_RESAMPLE, active);
|
||||
}
|
||||
|
||||
/* Everything after us is NATIVE_FREQUENCY */
|
||||
/* Everything after us is fout */
|
||||
dst->format = *format;
|
||||
dst->format.frequency = NATIVE_FREQUENCY;
|
||||
dst->format.codec_frequency = NATIVE_FREQUENCY;
|
||||
dst->format.frequency = fout;
|
||||
dst->format.codec_frequency = fout;
|
||||
|
||||
if (active)
|
||||
return PROC_NEW_FORMAT_OK;
|
||||
|
@ -287,8 +294,10 @@ static void INIT_ATTR resample_dsp_init(struct dsp_config *dsp,
|
|||
static void INIT_ATTR resample_proc_init(struct dsp_proc_entry *this,
|
||||
struct dsp_config *dsp)
|
||||
{
|
||||
struct resample_data *data = &resample_data[dsp_get_id(dsp)];
|
||||
this->data = (intptr_t)data;
|
||||
dsp_proc_set_in_place(dsp, DSP_PROC_RESAMPLE, false);
|
||||
this->data = (intptr_t)&resample_data[dsp_get_id(dsp)];
|
||||
data->frequency_out = DSP_OUT_DEFAULT_HZ;
|
||||
this->process = resample_process;
|
||||
}
|
||||
|
||||
|
@ -322,6 +331,10 @@ static intptr_t resample_configure(struct dsp_proc_entry *this,
|
|||
case DSP_PROC_NEW_FORMAT:
|
||||
retval = resample_new_format(this, dsp, (struct sample_format *)value);
|
||||
break;
|
||||
|
||||
case DSP_SET_OUT_FREQUENCY:
|
||||
dsp_proc_want_format_update(dsp, DSP_PROC_RESAMPLE);
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue