summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2010-12-14 21:36:52 +0100
committerGravatar waker <wakeroid@gmail.com>2010-12-14 21:36:52 +0100
commit4144d40b1a6fb5223e076b33b4cea82788bc3b89 (patch)
tree3be79b793af8b4455fad1eae471907a02043bd55
parentf3c8e6b96c752dcb921dba1f5ea847da97684a30 (diff)
changed dsp plugin api to allow modification of any aspect of wave format
-rw-r--r--deadbeef.h8
-rw-r--r--plugins/dsp_libsrc/src.c18
-rw-r--r--plugins/supereq/supereq.c14
-rw-r--r--streamer.c7
4 files changed, 23 insertions, 24 deletions
diff --git a/deadbeef.h b/deadbeef.h
index 06f009b1..114bfc4a 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -779,10 +779,12 @@ typedef struct DB_dsp_s {
void (*close) (ddb_dsp_context_t *ctx);
- // samples are interleaved
+ // samples are always interleaved floating point
// returned value is number of output frames
- // can change samplerate and number of channels
- int (*process) (ddb_dsp_context_t *ctx, float *samples, int frames, int *samplerate, int *channels);
+ // can change channels, samplerate, channelmask
+ // buffer size should always have reserved space for upsampling/upmixing
+ // TODO: decide on buffer size
+ int (*process) (ddb_dsp_context_t *ctx, float *samples, int frames, ddb_waveformat_t *fmt);
void (*reset) (ddb_dsp_context_t *ctx);
diff --git a/plugins/dsp_libsrc/src.c b/plugins/dsp_libsrc/src.c
index 3f972d64..432bf871 100644
--- a/plugins/dsp_libsrc/src.c
+++ b/plugins/dsp_libsrc/src.c
@@ -87,38 +87,38 @@ ddb_src_set_ratio (ddb_dsp_context_t *_src, float ratio) {
}
int
-ddb_src_process (ddb_dsp_context_t *_src, float *samples, int nframes, int *samplerate, int *nchannels) {
+ddb_src_process (ddb_dsp_context_t *_src, float *samples, int nframes, ddb_waveformat_t *fmt) {
ddb_src_libsamplerate_t *src = (ddb_src_libsamplerate_t*)_src;
- if (*samplerate == src->samplerate) {
+ if (fmt->samplerate == src->samplerate) {
return nframes;
}
- if (src->need_reset || src->channels != *nchannels || src->quality_changed || !src->src) {
+ if (src->need_reset || src->channels != fmt->channels || src->quality_changed || !src->src) {
src->quality_changed = 0;
src->remaining = 0;
if (src->src) {
src_delete (src->src);
src->src = NULL;
}
- src->channels = *nchannels;
+ src->channels = fmt->channels;
src->src = src_new (src->quality, src->channels, NULL);
src->need_reset = 0;
}
- float ratio = src->samplerate / *samplerate;
+ float ratio = src->samplerate / fmt->samplerate;
ddb_src_set_ratio (_src, ratio);
- *samplerate = src->samplerate;
+ fmt->samplerate = src->samplerate;
int numoutframes = nframes * src->srcdata.src_ratio;
- float outbuf[numoutframes*(*nchannels)];
+ float outbuf[numoutframes*fmt->channels];
memset (outbuf, 0, sizeof (outbuf));
int buffersize = sizeof (outbuf);
char *output = (char *)outbuf;
float *input = samples;
int inputsize = numoutframes;
- int samplesize = *nchannels * sizeof (float);
+ int samplesize = fmt->channels * sizeof (float);
do {
// add more frames to input SRC buffer
@@ -131,7 +131,7 @@ ddb_src_process (ddb_dsp_context_t *_src, float *samples, int nframes, int *samp
memcpy (&src->in_fbuffer[src->remaining*samplesize], samples, n * samplesize);
src->remaining += n;
- samples += n * (*nchannels);
+ samples += n * fmt->channels;
nframes -= n;
}
if (!src->remaining) {
diff --git a/plugins/supereq/supereq.c b/plugins/supereq/supereq.c
index d3d83389..afa06359 100644
--- a/plugins/supereq/supereq.c
+++ b/plugins/supereq/supereq.c
@@ -75,27 +75,27 @@ supereq_plugin_stop (void) {
}
int
-supereq_process (ddb_dsp_context_t *ctx, float *samples, int frames, int *samplerate, int *channels) {
+supereq_process (ddb_dsp_context_t *ctx, float *samples, int frames, ddb_waveformat_t *fmt) {
ddb_supereq_ctx_t *supereq = (ddb_supereq_ctx_t *)ctx;
if (supereq->params_changed) {
recalc_table (supereq);
supereq->params_changed = 0;
}
- if (supereq->last_srate != *samplerate) {
+ if (supereq->last_srate != fmt->samplerate) {
deadbeef->mutex_lock (supereq->mutex);
- supereq->last_srate = *samplerate;
- supereq->last_nch = *channels;
+ supereq->last_srate = fmt->samplerate;
+ supereq->last_nch = fmt->channels;
recalc_table (supereq);
deadbeef->mutex_unlock (supereq->mutex);
equ_clearbuf(&supereq->state);
}
- else if (supereq->last_nch != *channels) {
+ else if (supereq->last_nch != fmt->channels) {
deadbeef->mutex_lock (supereq->mutex);
- supereq->last_nch = *channels;
+ supereq->last_nch = fmt->channels;
deadbeef->mutex_unlock (supereq->mutex);
equ_clearbuf(&supereq->state);
}
- equ_modifySamples_float(&supereq->state, (char *)samples,frames,*channels);
+ equ_modifySamples_float(&supereq->state, (char *)samples,frames,fmt->channels);
return frames;
}
diff --git a/streamer.c b/streamer.c
index 4f8b2ebc..dcc36fa3 100644
--- a/streamer.c
+++ b/streamer.c
@@ -1384,16 +1384,13 @@ streamer_read_async (char *bytes, int size) {
int nframes = inputsize / inputsamplesize;
ddb_dsp_context_t *dsp = dsp_chain;
- int samplerate = fileinfo->fmt.samplerate;
- int channels = dspfmt.channels;
+ dspfmt.samplerate = fileinfo->fmt.samplerate;
while (dsp) {
if (dsp->enabled) {
- nframes = dsp->plugin->process (dsp, (float *)tempbuf, nframes, &samplerate, &channels);
+ nframes = dsp->plugin->process (dsp, (float *)tempbuf, nframes, &dspfmt);
}
dsp = dsp->next;
}
- dspfmt.samplerate = samplerate;
- dspfmt.channels = channels;
int n = pcm_convert (&dspfmt, tempbuf, &output->fmt, bytes, nframes * dspsamplesize);
bytesread = n;