rockbox/apps/dsp.h
Michael Sevakis 1ab9d14c77 Move to compressor out of dsp.c and into its own source to reduce DSP clutter.
A bit of a rough job for the moment but all works.

Change-Id: Id40852e0dec99caee02f943d0da8a1cdc16f022a
2012-02-08 14:55:37 -05:00

125 lines
4.2 KiB
C

/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2005 Miika Pekkarinen
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef _DSP_H
#define _DSP_H
#include <stdlib.h>
#include <stdbool.h>
#define NATIVE_FREQUENCY 44100
enum
{
STEREO_INTERLEAVED = 0,
STEREO_NONINTERLEAVED,
STEREO_MONO,
STEREO_NUM_MODES,
};
enum
{
CODEC_IDX_AUDIO = 0,
CODEC_IDX_VOICE,
};
enum
{
DSP_MYDSP = 1,
DSP_SET_FREQUENCY,
DSP_SWITCH_FREQUENCY,
DSP_SET_SAMPLE_DEPTH,
DSP_SET_STEREO_MODE,
DSP_RESET,
DSP_FLUSH,
DSP_SET_TRACK_GAIN,
DSP_SET_ALBUM_GAIN,
DSP_SET_TRACK_PEAK,
DSP_SET_ALBUM_PEAK,
DSP_CROSSFEED
};
/****************************************************************************
* NOTE: Any assembly routines that use these structures must be updated
* if current data members are moved or changed.
*/
struct resample_data
{
uint32_t delta; /* 00h */
uint32_t phase; /* 04h */
int32_t last_sample[2]; /* 08h */
/* 10h */
};
/* This is for passing needed data to external dsp routines. If another
* dsp parameter needs to be passed, add to the end of the structure
* and remove from dsp_config.
* If another function type becomes assembly/external and requires dsp
* config info, add a pointer paramter of type "struct dsp_data *".
* If removing something from other than the end, reserve the spot or
* else update every implementation for every target.
* Be sure to add the offset of the new member for easy viewing as well. :)
* It is the first member of dsp_config and all members can be accessesed
* through the main aggregate but this is intended to make a safe haven
* for these items whereas the c part can be rearranged at will. dsp_data
* could even moved within dsp_config without disurbing the order.
*/
struct dsp_data
{
int output_scale; /* 00h */
int num_channels; /* 04h */
struct resample_data resample_data; /* 08h */
int32_t clip_min; /* 18h */
int32_t clip_max; /* 1ch */
int32_t gain; /* 20h - Note that this is in S8.23 format. */
int frac_bits; /* 24h */
/* 28h */
};
struct dsp_config;
int dsp_process(struct dsp_config *dsp, char *dest,
const char *src[], int count);
int dsp_input_count(struct dsp_config *dsp, int count);
int dsp_output_count(struct dsp_config *dsp, int count);
intptr_t dsp_configure(struct dsp_config *dsp, int setting,
intptr_t value);
int get_replaygain_mode(bool have_track_gain, bool have_album_gain);
void dsp_set_replaygain(void);
void dsp_set_crossfeed(bool enable);
void dsp_set_crossfeed_direct_gain(int gain);
void dsp_set_crossfeed_cross_params(long lf_gain, long hf_gain,
long cutoff);
void dsp_set_eq(bool enable);
void dsp_set_eq_precut(int precut);
void dsp_set_eq_coefs(int band);
void dsp_dither_enable(bool enable);
void dsp_timestretch_enable(bool enable);
bool dsp_timestretch_available(void);
void sound_set_pitch(int32_t r);
int32_t sound_get_pitch(void);
void dsp_set_timestretch(int32_t percent);
int32_t dsp_get_timestretch(void);
int dsp_callback(int msg, intptr_t param);
void dsp_set_compressor(void);
#endif