Commit fea75bca authored by Ryan C. Gordon's avatar Ryan C. Gordon

First shot at new audio resampling code.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403483
parent 8ca737d4
...@@ -147,15 +147,10 @@ typedef struct SDL_AudioCVT ...@@ -147,15 +147,10 @@ typedef struct SDL_AudioCVT
SDL_AudioFormat dst_format; /* Target audio format */ SDL_AudioFormat dst_format; /* Target audio format */
double rate_incr; /* Rate conversion increment */ double rate_incr; /* Rate conversion increment */
Uint8 *buf; /* Buffer to hold entire audio data */ Uint8 *buf; /* Buffer to hold entire audio data */
Uint8 *coeff; /* Filter coefficients: either big windowed sinc filter, or 6 IIR lowpass coefficients */
Uint8 *state_buf; /* Sample history for either the FIR or IIR filter. For IIR filter, first two elements are X, second two are Y, and state_pos toggles the order */
int state_pos; /* Position in the state */
int len_sinc; /* Length of windowed sinc filter, in appropriate units (not necessarily bytes) */
int len; /* Length of original audio buffer */ int len; /* Length of original audio buffer */
int len_cvt; /* Length of converted audio buffer */ int len_cvt; /* Length of converted audio buffer */
int len_mult; /* buffer must be len*len_mult big */ int len_mult; /* buffer must be len*len_mult big */
int len_div; /* destination length = len_mult / len_div * src length */ double len_ratio; /* Given len, final size is len*len_ratio */
double len_ratio; /* Given len, final size is len*len_ratio ( len_ratio = len_mult / len_div ) */
SDL_AudioFilter filters[10]; /* Filter list */ SDL_AudioFilter filters[10]; /* Filter list */
int filter_index; /* Current audio conversion function */ int filter_index; /* Current audio conversion function */
} SDL_AudioCVT; } SDL_AudioCVT;
......
...@@ -371,6 +371,7 @@ SDL_RunAudio(void *devicep) ...@@ -371,6 +371,7 @@ SDL_RunAudio(void *devicep)
silence = 0; silence = 0;
} }
#if 0 /* !!! FIXME: I took len_div out of the structure. Use rate_incr instead? */
/* If the result of the conversion alters the length, i.e. resampling is being used, use the streamer */ /* If the result of the conversion alters the length, i.e. resampling is being used, use the streamer */
if (device->convert.len_mult != 1 || device->convert.len_div != 1) { if (device->convert.len_mult != 1 || device->convert.len_div != 1) {
/* The streamer's maximum length should be twice whichever is larger: spec.size or len_cvt */ /* The streamer's maximum length should be twice whichever is larger: spec.size or len_cvt */
...@@ -391,6 +392,7 @@ SDL_RunAudio(void *devicep) ...@@ -391,6 +392,7 @@ SDL_RunAudio(void *devicep)
device->spec.size * device->convert.len_div / device->spec.size * device->convert.len_div /
device->convert.len_mult; device->convert.len_mult;
} }
#endif
/* stream_len = device->convert.len; */ /* stream_len = device->convert.len; */
stream_len = device->spec.size; stream_len = device->spec.size;
......
...@@ -42,4 +42,15 @@ typedef struct ...@@ -42,4 +42,15 @@ typedef struct
} SDL_AudioTypeFilters; } SDL_AudioTypeFilters;
extern const SDL_AudioTypeFilters sdl_audio_type_filters[]; extern const SDL_AudioTypeFilters sdl_audio_type_filters[];
/* this is used internally to access some autogenerated code. */
typedef struct
{
SDL_AudioFormat fmt;
int channels;
int upsample;
int multiple;
SDL_AudioFilter filter;
} SDL_AudioRateFilters;
extern const SDL_AudioRateFilters sdl_audio_rate_filters[];
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment