[vlc-devel] [PATCH 3/6] equalizer: Add support for extra sets of ISO bands
Ronald Wright
logiconcepts819 at gmail.com
Thu Jul 24 19:19:19 CEST 2014
Note: This patch cannot be applied without patch 2, and patches 3 through 6
must be applied all together.
---
modules/audio_filter/equalizer.c | 233 ++++++++--
modules/audio_filter/equalizer_presets.h | 751 +++++++++++++++++++++++++++++--
2 files changed, 903 insertions(+), 81 deletions(-)
diff --git a/modules/audio_filter/equalizer.c b/modules/audio_filter/equalizer.c
index 98a4a7e..f45ba8b 100644
--- a/modules/audio_filter/equalizer.c
+++ b/modules/audio_filter/equalizer.c
@@ -1,7 +1,7 @@
/*****************************************************************************
* equalizer.c:
*****************************************************************************
- * Copyright (C) 2004-2012 VLC authors and VideoLAN
+ * Copyright (C) 2004-2012, 2014 VLC authors and VideoLAN
* $Id$
*
* Authors: Laurent Aimar <fenrir at via.ecp.fr>
@@ -34,16 +34,16 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_charset.h>
+#include <vlc_interpolation.h>
#include <vlc_aout.h>
#include <vlc_filter.h>
+#define EQZ_INCLUDE_MATH_ROUTINES 1
#include "equalizer_presets.h"
/* TODO:
* - optimize a bit (you can hardly do slower ;)
- * - add tables for more bands (15 and 32 would be cool), maybe with auto coeffs
- * computation (not too hard once the Q is found).
* - support for external preset
* - callback to handle preset changes on the fly
* - ...
@@ -60,14 +60,29 @@ static void Close( vlc_object_t * );
#define BANDS_TEXT N_( "Bands gain")
#define BANDS_LONGTEXT N_( \
- "Don't use presets, but manually specified bands. You need to " \
- "provide 10 values between -20dB and 20dB, separated by spaces, " \
- "e.g. \"0 2 4 2 0 -2 -4 -2 0 2\"." )
-
-#define VLC_BANDS_TEXT N_( "Use VLC frequency bands" )
-#define VLC_BANDS_LONGTEXT N_( \
- "Use the VLC frequency bands. Otherwise, use the ISO Standard " \
- "frequency bands." )
+ "Don't use presets, but manually specified bands. You need to " \
+ "provide 10, 15, or 31 values between -20dB and 20dB, separated by " \
+ "spaces. You may optionally append a parameter \"v\" or \"i\" to " \
+ "help VLC differentiate between VLC bands and ISO bands, " \
+ "respectively. The \"v\" parameter is valid for 10 values only, " \
+ "and the \"i\" parameter is valid for 10, 15 and 31 values. " \
+ "Without this parameter specified, or with an invalid parameter, " \
+ "the default is to assume VLC bands if there are 10 values or " \
+ "ISO bands if there are 15 or 31 values.\n\nThe band values are " \
+ "interpolated if the number of bands is valid (i.e. 10, 15, or " \
+ "31), and the type of equalization suggested by the specified " \
+ "string differs from the current equalizer type (e.g. 10 VLC bands " \
+ "vs. a 10-band ISO equalizer or 15 ISO bands vs. a 31-band ISO " \
+ "equalizer). Otherwise, each value is mapped to the corresponding " \
+ "band of the current equalizer type, starting at the lowest band, " \
+ "until there are no more spaces or values left.\n\nExamples: \"0 2 " \
+ "4 2 0 -2 -4 -2 0 2 v\" represent 10 VLC bands, and \"0 2 4 2 0 -2 " \
+ "-4 -2 0 2 4 2 0 -2 -4\" represent 15 ISO bands." )
+
+#define VLC_EQZTYPE_TEXT N_( "Equalizer type" )
+#define VLC_EQZTYPE_LONGTEXT N_( \
+ "Select the equalizer type to use. Options include the 10-band VLC " \
+ "equalizer and the 10-, 15-, and 31-band ISO equalizers." )
#define TWOPASS_TEXT N_( "Two pass" )
#define TWOPASS_LONGTEXT N_( "Filter the audio twice. This provides a more " \
@@ -90,8 +105,9 @@ vlc_module_begin ()
BANDS_LONGTEXT, true )
add_bool( "equalizer-2pass", false, TWOPASS_TEXT,
TWOPASS_LONGTEXT, true )
- add_bool( "equalizer-vlcfreqs", true, VLC_BANDS_TEXT,
- VLC_BANDS_LONGTEXT, true )
+ add_string( "equalizer-type", "vlc10", VLC_EQZTYPE_TEXT,
+ VLC_EQZTYPE_LONGTEXT, true )
+ change_string_list( eqz_types, eqz_types_text )
add_float( "equalizer-preamp", 12.0f, PREAMP_TEXT,
PREAMP_LONGTEXT, true )
set_callbacks( Open, Close )
@@ -105,6 +121,7 @@ struct filter_sys_t
{
/* Filter static config */
int i_band;
+ int i_type;
float *f_alpha;
float *f_beta;
float *f_gamma;
@@ -214,25 +231,22 @@ typedef struct
} eqz_config_t;
/* Equalizer coefficient calculation function based on equ-xmms */
-static void EqzCoeffs( int i_rate, float f_octave_percent,
- bool b_use_vlc_freqs,
- eqz_config_t *p_eqz_config )
+static void EqzCoeffs( int i_rate, int i_type, eqz_config_t *p_eqz_config )
{
- const float *f_freq_table_10b = b_use_vlc_freqs
- ? f_vlc_frequency_table_10b
- : f_iso_frequency_table_10b;
+ const eqz_base_freqtable_t *p_freq_table = EqzGetFrequencyTable( i_type );
+ int i_band = EqzGetNumBandsByType( i_type );
+ float f_octave_percent = p_freq_table->f_bandwidth;
float f_rate = (float) i_rate;
float f_nyquist_freq = 0.5f * f_rate;
float f_octave_factor = powf( 2.0f, 0.5f * f_octave_percent );
float f_octave_factor_1 = 0.5f * ( f_octave_factor + 1.0f );
float f_octave_factor_2 = 0.5f * ( f_octave_factor - 1.0f );
- p_eqz_config->i_band = EQZ_BANDS_MAX;
+ p_eqz_config->i_band = i_band;
- for( int i = 0; i < EQZ_BANDS_MAX; i++ )
+ for( int i = 0; i < i_band; i++ )
{
- float f_freq = f_freq_table_10b[i];
-
+ float f_freq = EqzGetTrueFrequency( i_type, i );
p_eqz_config->band[i].f_frequency = f_freq;
if( f_freq <= f_nyquist_freq )
@@ -285,11 +299,25 @@ static int EqzInit( filter_t *p_filter, int i_rate )
vlc_object_t *p_aout = p_filter->p_parent;
int i_ret = VLC_ENOMEM;
- bool b_vlcFreqs = var_InheritBool( p_aout, "equalizer-vlcfreqs" );
- EqzCoeffs( i_rate, 1.0f, b_vlcFreqs, &cfg );
+ /* Fetch the type of equalizer */
+ const char *psz_eqz_type = var_InheritString( p_aout, "equalizer-type" );
+ int i_type = EqzGetTypeNumber( psz_eqz_type );
+ if( i_type == EQZ_UNKNOWN_TYPE )
+ {
+ msg_Err( p_aout, "equalizer type '%s' not found", psz_eqz_type );
+ msg_Info( p_aout, "full list:" );
+ for( unsigned i = 0; i < NB_EQZ_TYPES; i++ )
+ msg_Info( p_aout, " - '%s'", eqz_types[i] );
+ return VLC_EGENERIC;
+ }
+
+ /* Load the equalizer configuration with frequencies and coefficients
+ * according to the equalizer type */
+ EqzCoeffs( i_rate, i_type, &cfg );
/* Create the static filter config */
p_sys->i_band = cfg.i_band;
+ p_sys->i_type = i_type;
p_sys->f_alpha = malloc( p_sys->i_band * sizeof(float) );
p_sys->f_beta = malloc( p_sys->i_band * sizeof(float) );
p_sys->f_gamma = malloc( p_sys->i_band * sizeof(float) );
@@ -469,32 +497,41 @@ static void EqzClean( filter_t *p_filter )
static int PresetCallback( vlc_object_t *p_aout, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
- const eqz_preset_t *preset = NULL;
+ filter_sys_t *p_sys = p_data;
+ const eqz_base_preset_t *table = EqzGetPresetTable( p_sys->i_type );
+ const eqz_base_preset_t *preset = NULL;
const char *psz_preset = newval.psz_string;
for( unsigned i = 0; i < NB_PRESETS; i++ )
- if( !strcasecmp( eqz_preset_10b[i].psz_name, psz_preset ) )
+ {
+ const eqz_base_preset_t *p = EqzGetPresetAt( table, i );
+ if( !strcasecmp( p->psz_name, psz_preset ) )
{
- preset = eqz_preset_10b + i;
+ preset = p;
break;
}
+ }
if( preset == NULL )
{
msg_Err( p_aout, "equalizer preset '%s' not found", psz_preset );
msg_Info( p_aout, "full list:" );
for( unsigned i = 0; i < NB_PRESETS; i++ )
- msg_Info( p_aout, " - '%s'", eqz_preset_10b[i].psz_name );
+ {
+ msg_Info( p_aout, " - '%s'",
+ EqzGetPresetAt( table, i )->psz_name );
+ }
return VLC_EGENERIC;
}
char *bands = NULL;
+ const float *pf_amp = EqzGetAmpPtr( preset );
- for( unsigned i = 0; i < EQZ_BANDS_MAX; i++ )
+ for( int i = 0; i < p_sys->i_band; i++ )
{
char *psz;
- lldiv_t d = lldiv( lroundf(preset->f_amp[i] * 10000000.f), 10000000 );
+ lldiv_t d = lldiv( lroundf(pf_amp[i] * 10000000.f), 10000000 );
if( asprintf( &psz, "%s %lld.%07llu", i ? bands : "",
d.quot, d.rem ) == -1 )
@@ -506,10 +543,25 @@ static int PresetCallback( vlc_object_t *p_aout, char const *psz_cmd,
bands = psz;
}
+ /* For 10 bands, we must help VLC differentiate between VLC bands and ISO
+ * bands */
+ if( p_sys->i_band == EQZ_ISO10_BANDS_MAX )
+ {
+ char * psz;
+ if( asprintf( &psz, "%s %c", bands,
+ EqzGetIdentifier( p_sys->i_type ) ) == -1 )
+ psz = NULL;
+
+ free( bands );
+ if( unlikely( psz == NULL ) )
+ return VLC_ENOMEM;
+ bands = psz;
+ }
+
var_SetFloat( p_aout, "equalizer-preamp", preset->f_preamp );
var_SetString( p_aout, "equalizer-bands", bands );
free( bands );
- (void) psz_cmd; (void) oldval; (void) p_data;
+ (void) psz_cmd; (void) oldval;
return VLC_SUCCESS;
}
@@ -536,31 +588,118 @@ static int PreampCallback( vlc_object_t *p_this, char const *psz_cmd,
static int BandsCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
- VLC_UNUSED(p_this); VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
+ VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
filter_sys_t *p_sys = p_data;
- const char *p = newval.psz_string;
- int i = 0;
+ int i = 0, i_toks = 0;
+
+ /* Duplicate memory of new string value */
+ char *p = strdup( newval.psz_string ), *q = NULL, *saved;
+ if( unlikely( !p ) )
+ return VLC_ENOMEM;
+
+ /* Allocate temporary memory for storing bands */
+ int i_ret_val = VLC_ENOMEM;
+ float *pf_amp = malloc( EQZ_BANDS_MAX * sizeof( *pf_amp ) );
+ if( unlikely( !pf_amp ) )
+ {
+ goto free_p;
+ }
/* Same thing for bands */
- vlc_mutex_lock( &p_sys->lock );
- while( i < p_sys->i_band )
+ for( char *tok = strtok_r( p, " ", &saved ); tok != NULL;
+ tok = strtok_r( NULL, " ", &saved ) )
{
- char *next;
- /* Read dB -20/20 */
- float f = us_strtof( p, &next );
- if( next == p || isnan( f ) )
- break; /* no conversion */
+ if( i < EQZ_BANDS_MAX )
+ {
+ char *r = tok;
+ float f = us_strtof( tok, &r );
+ if( r == tok || *r != '\0' || isnan( f ) )
+ pf_amp[i++] = 0.f;
+ else
+ pf_amp[i++] = EqzConvertdB( f );
+ }
- p_sys->f_amp[i++] = EqzConvertdB( f );
+ /* Even if we exceed EQZ_BANDS_MAX or encounter malformed tokens,
+ * keep counting the number of tokens */
+ i_toks++;
+ q = tok;
+ }
+
+ /* Check whether we have a potential identifier at the end of the string.
+ * One way to check is if the last token is numeric. If not, then we
+ * consider it as a potential token. */
+ if( q ) /* q is non-NULL if we have at least one token */
+ {
+ char *r = q;
+ float f = us_strtof( q, &r );
+ if( r == q || *r != '\0' || isnan( f ) )
+ {
+ /* In this case, the last token could not be converted into a
+ * float, so we treat it as a potential identifier by excluding it
+ * from all counts */
+ if( i <= EQZ_BANDS_MAX )
+ i--; /* potential identifier found within bounds */
+ i_toks--;
+ }
+ else
+ q = NULL; /* don't treat any tokens as potential identifiers */
+ }
- if( *next == '\0' )
- break; /* end of line */
- p = &next[1];
+ i_ret_val = VLC_SUCCESS;
+ if( i > 0 )
+ {
+ /* Should there be a mismatch in the number or type of bands,
+ * interpolate */
+ char id = EqzGetValidIdentifier( p_this, p_sys->i_type, q, i_toks );
+ if( i != p_sys->i_band || id != EqzGetIdentifier( p_sys->i_type ) )
+ {
+ int i_type = EqzGetTypeByNumBands( i_toks, id );
+ if( i_type != EQZ_UNKNOWN_TYPE )
+ {
+ /* Try creating the interpolant */
+ i_ret_val = VLC_ENOMEM;
+ float * pf_freq = malloc( i * sizeof( *pf_freq ) );
+ if( unlikely( !pf_freq ) )
+ goto free_pf_amp;
+
+ for( int k = 0; k < i; k++ )
+ pf_freq[k] = EqzGetTrueFrequency( i_type, k );
+
+ vlc_interpolant_t itp;
+ i_ret_val = vlc_create_interpolant( &itp, pf_freq, pf_amp, i );
+ if( i_ret_val == VLC_SUCCESS )
+ {
+ /* In this case, we successfully created the interpolant.
+ * Now, we construct the interpolated set of bands */
+ vlc_mutex_lock( &p_sys->lock );
+ for( int k = 0; k < p_sys->i_band; k++ )
+ {
+ float f_freq = EqzGetTrueFrequency( p_sys->i_type, k );
+ p_sys->f_amp[k] = vlc_interpolate( &itp, f_freq );
+ }
+ vlc_mutex_unlock( &p_sys->lock );
+ vlc_destroy_interpolant( &itp );
+ }
+ free( pf_freq );
+ goto free_pf_amp;
+ }
+ }
}
+
+ /* If we have not interpolated any values, simply copy whatever is present
+ * from the given string */
+ vlc_mutex_lock( &p_sys->lock );
+ for( int k = 0; k < i; k++ )
+ p_sys->f_amp[k] = pf_amp[k];
while( i < p_sys->i_band )
p_sys->f_amp[i++] = EqzConvertdB( 0.f );
vlc_mutex_unlock( &p_sys->lock );
- return VLC_SUCCESS;
+
+free_pf_amp:
+ free( pf_amp );
+free_p:
+ free( p );
+ return i_ret_val;
}
static int TwoPassCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
diff --git a/modules/audio_filter/equalizer_presets.h b/modules/audio_filter/equalizer_presets.h
index 3ea70ca..803de76 100644
--- a/modules/audio_filter/equalizer_presets.h
+++ b/modules/audio_filter/equalizer_presets.h
@@ -1,10 +1,11 @@
/*****************************************************************************
* equalizer_presets.h:
*****************************************************************************
- * Copyright (C) 2004 VLC authors and VideoLAN
+ * Copyright (C) 2004, 2014 VLC authors and VideoLAN
* $Id$
*
* Authors: Laurent Aimar <fenrir at via.ecp.fr>
+ * Ronald Wright <logiconcepts819 at gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
@@ -31,19 +32,250 @@
* get these values even if the equalizer is not enabled.
*/
-#define EQZ_BANDS_MAX 10
+/* Maximum number of equalizer bands */
+#define EQZ_ISO10_BANDS_MAX 10
+#define EQZ_VLC10_BANDS_MAX EQZ_ISO10_BANDS_MAX
+#define EQZ_ISO15_BANDS_MAX 15
+#define EQZ_ISO31_BANDS_MAX 31
-/* The frequency tables */
-static const float f_vlc_frequency_table_10b[EQZ_BANDS_MAX] =
+#define EQZ_BANDS_MAX EQZ_ISO31_BANDS_MAX
+
+/* **************************** Equalizer types **************************** */
+
+/* Identifiers */
+#define EQZ_UNKNOWN_TYPE -1
+#define EQZ_VLC10_TYPE 0
+#define EQZ_ISO10_TYPE 1
+#define EQZ_ISO15_TYPE 2
+#define EQZ_ISO31_TYPE 3
+
+#define EQZ_VLC_IDENTIFIER 'v'
+#define EQZ_ISO_IDENTIFIER 'i'
+
+#define NB_EQZ_TYPES 4
+static const char *const eqz_types[NB_EQZ_TYPES] = {
+ "vlc10", "iso10", "iso15", "iso31"
+};
+
+static const char *const eqz_types_text[NB_EQZ_TYPES] = {
+ N_("10-band VLC equalizer"), N_("10-band ISO equalizer"),
+ N_("15-band ISO equalizer"), N_("31-band ISO equalizer"),
+};
+
+/* Lookup equalizer type number from the given string type */
+static inline int EqzGetTypeNumber( const char * psz_type )
+{
+ for( int i = 0; i < NB_EQZ_TYPES; i++ )
+ {
+ if( !strcasecmp( eqz_types[i], psz_type ) )
+ {
+ return i;
+ }
+ }
+ return EQZ_UNKNOWN_TYPE;
+}
+
+/* Lookup equalizer identifier from the given type number */
+static inline char EqzGetIdentifier( int i_type_number )
+{
+ switch( i_type_number )
+ {
+ case EQZ_ISO10_TYPE:
+ /* fall-through */
+ case EQZ_ISO15_TYPE:
+ /* fall-through */
+ case EQZ_ISO31_TYPE:
+ return EQZ_ISO_IDENTIFIER;
+ default:
+ return EQZ_VLC_IDENTIFIER;
+ }
+}
+
+/* Lookup default equalizer identifier from the given number of bands */
+static inline char EqzGetDefaultIdentifier( int i_band )
{
- 60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000,
+ return i_band > EQZ_ISO10_BANDS_MAX ? EQZ_ISO_IDENTIFIER
+ : EQZ_VLC_IDENTIFIER;
+}
+
+/* Determine string identifier from the given character identifier */
+#define EqzGetStringIdentifier( ch ) \
+ ( ( ch ) == EQZ_ISO_IDENTIFIER ? "ISO" : "VLC" )
+
+/* Macro for declaring equalizer and preset tables with an arbitrary number of
+ * bands */
+#define EQZ_FREQTABLE_TYPE( nbands ) eqz_freqtable##nbands##_t
+#define EQZ_PRESET_TYPE( nbands ) eqz_preset##nbands##_t
+
+/* Casts to the base type */
+#define EQZ_BASE_FREQTABLE( ptr ) ( ( const eqz_base_freqtable_t * ) ( ptr ) )
+#define EQZ_BASE_PRESET( ptr ) ( ( const eqz_base_preset_t * ) ( ptr ) )
+
+/* Members common to all frequency table types */
+#define EQZ_FREQTABLE_COMMON_MEMBERS \
+ int i_band_offset; /* offset of the first band from 1 kHz */ \
+ float f_bandwidth; /* bandwidth */ \
+
+/* Members common to all preset types */
+#define EQZ_PRESET_COMMON_MEMBERS \
+ const char psz_name[16]; /* preset name */ \
+ int i_band; /* number of bands */ \
+ float f_preamp; /* preamp */ \
+
+/* Base structure for a frequency table */
+typedef struct
+{
+ EQZ_FREQTABLE_COMMON_MEMBERS
+} eqz_base_freqtable_t;
+
+/* Base structure for a preset table */
+typedef struct
+{
+ EQZ_PRESET_COMMON_MEMBERS
+} eqz_base_preset_t;
+
+/* Macro for defining a frequency table and a preset, which have an arbitrary
+ * number of bands */
+#define DEFINE_EQZ_TYPES( nbands ) \
+ /* Structure for defining a frequency table */ \
+ typedef struct \
+ { \
+ EQZ_FREQTABLE_COMMON_MEMBERS /* common struct members */ \
+ float f_frequencies[nbands]; /* array of displayable frequencies */ \
+ } EQZ_FREQTABLE_TYPE( nbands ); \
+ \
+ /* Structure for defining a preset */ \
+ typedef struct \
+ { \
+ EQZ_PRESET_COMMON_MEMBERS /* common struct members */ \
+ float f_amp[nbands]; /* array of boosts and cuts */ \
+ } EQZ_PRESET_TYPE( nbands ); \
+
+/* We have the 10-band VLC equalizer, and we also have 10-, 15-, and 31-band
+ * ISO equalizers */
+DEFINE_EQZ_TYPES( EQZ_ISO10_BANDS_MAX )
+DEFINE_EQZ_TYPES( EQZ_ISO15_BANDS_MAX )
+DEFINE_EQZ_TYPES( EQZ_ISO31_BANDS_MAX )
+
+/* *************************** Frequency tables **************************** */
+
+/* 10-band VLC table */
+static const EQZ_FREQTABLE_TYPE( 10 ) vlc_frequency_table_10b =
+{
+ -4, 1.0f,
+ {
+ 60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000
+ }
};
-static const float f_iso_frequency_table_10b[EQZ_BANDS_MAX] =
+/* 10-band ISO table */
+static const EQZ_FREQTABLE_TYPE( 10 ) iso_frequency_table_10b =
{
- 31.25, 62.5, 125, 250, 500, 1000, 2000, 4000, 8000, 16000,
+ -5, 1.0f,
+ {
+ 31.5, 63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000
+ }
};
+/* 15-band ISO table */
+static const EQZ_FREQTABLE_TYPE( 15 ) iso_frequency_table_15b =
+{
+ -8, 2.0f / 3.0f,
+ {
+ 25, 40, 63, 100, 160, 250, 400, 630, 1000, 1600, 2500, 4000, 6300,
+ 10000, 16000
+ }
+};
+
+/* 31-band ISO table */
+static const EQZ_FREQTABLE_TYPE( 31 ) iso_frequency_table_31b =
+{
+ -17, 1.0f / 3.0f,
+ {
+ 20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500,
+ 630, 800, 1000, 1250, 1600, 2000, 2500, 3150, 4000, 5000, 6300, 8000,
+ 10000, 12500, 16000, 20000
+ }
+};
+
+/* ******************* Frequency table helper functions ******************** */
+
+/* Function for retrieving a pointer to the (displayable) frequencies */
+static inline
+const float * EqzGetFrequencyPtr( const eqz_base_freqtable_t * p_freq_table )
+{
+ return ( const float * ) ( p_freq_table + 1 );
+}
+
+/* Function for retrieving the correct frequency table by type */
+static inline
+const eqz_base_freqtable_t * EqzGetFrequencyTable( int i_type_number )
+{
+ switch( i_type_number )
+ {
+ case EQZ_VLC10_TYPE:
+ return EQZ_BASE_FREQTABLE( &vlc_frequency_table_10b );
+ case EQZ_ISO10_TYPE:
+ return EQZ_BASE_FREQTABLE( &iso_frequency_table_10b );
+ case EQZ_ISO15_TYPE:
+ return EQZ_BASE_FREQTABLE( &iso_frequency_table_15b );
+ case EQZ_ISO31_TYPE:
+ return EQZ_BASE_FREQTABLE( &iso_frequency_table_31b );
+ default:
+ return NULL;
+ }
+}
+
+/* Function for retrieving the type of equalizer by number of bands and
+ * equalizer identifier */
+static inline int EqzGetTypeByNumBands( int i_band, char identifier )
+{
+ switch( i_band )
+ {
+ case EQZ_ISO10_BANDS_MAX:
+ {
+ if( identifier == EQZ_ISO_IDENTIFIER )
+ return EQZ_ISO10_TYPE;
+ else
+ return EQZ_VLC10_TYPE;
+ }
+ case EQZ_ISO15_BANDS_MAX:
+ return EQZ_ISO15_TYPE;
+ case EQZ_ISO31_BANDS_MAX:
+ return EQZ_ISO31_TYPE;
+ default:
+ return EQZ_UNKNOWN_TYPE;
+ }
+}
+
+/* Function for retrieving the true frequency at the specified index. A build
+ * error will result if math.h is not included before equalizer_presets.h is
+ * included, so this routine is guarded by the EQZ_INCLUDE_MATH_ROUTINES macro.
+ * If math.h is included before equalizer_presets.h, then
+ * EQZ_INCLUDE_MATH_ROUTINES may be optionally defined before the inclusion of
+ * equalizer_presets.h so that EqzGetTrueFrequency() can be called */
+#ifdef EQZ_INCLUDE_MATH_ROUTINES
+static inline float EqzGetTrueFrequency( int i_type, int i_index )
+{
+ if( i_type == EQZ_VLC10_TYPE )
+ {
+ /* True VLC frequencies are the same as displayable VLC frequencies */
+ return EqzGetFrequencyPtr( EqzGetFrequencyTable( i_type ) )[ i_index ];
+ }
+ else
+ {
+ /* True ISO frequencies are slightly different from displayable ISO
+ * frequencies */
+ const eqz_base_freqtable_t *p_table = EqzGetFrequencyTable( i_type );
+ int i_offset = p_table->i_band_offset + i_index;
+ float f_octave_percent = p_table->f_bandwidth;
+ return 1000.0f * powf( 2.0f, i_offset * f_octave_percent );
+ }
+}
+#endif
+
+/* ***************************** Preset tables ***************************** */
+
#define NB_PRESETS 18
static const char *const preset_list[NB_PRESETS] = {
"flat", "classical", "club", "dance", "fullbass", "fullbasstreble",
@@ -57,101 +289,552 @@ static const char *const preset_list_text[NB_PRESETS] = {
N_("Rock"), N_("Ska"), N_("Soft"), N_("Soft rock"), N_("Techno"),
};
-typedef struct
-{
- const char psz_name[16];
- int i_band;
- float f_preamp;
- float f_amp[EQZ_BANDS_MAX];
-} eqz_preset_t;
-
-static const eqz_preset_t eqz_preset_10b[NB_PRESETS] =
+/* Preset table for the 10-band VLC equalizer */
+static const EQZ_PRESET_TYPE( 10 ) eqz_preset_vlc_10b[NB_PRESETS] =
{
{
- "flat", 10, 12.0f,
+ "flat", EQZ_VLC10_BANDS_MAX, 12.0f,
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
},
{
- "classical", 10, 12.0f,
+ "classical", EQZ_VLC10_BANDS_MAX, 12.0f,
{ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
-1.11022e-15f, -1.11022e-15f, -7.2f, -7.2f, -7.2f, -9.6f }
},
{
- "club", 10, 6.0f,
+ "club", EQZ_VLC10_BANDS_MAX, 6.0f,
{ -1.11022e-15f, -1.11022e-15f, 8.0f, 5.6f, 5.6f, 5.6f, 3.2f,
-1.11022e-15f, -1.11022e-15f, -1.11022e-15f }
},
{
- "dance", 10, 5.0f,
+ "dance", EQZ_VLC10_BANDS_MAX, 5.0f,
{ 9.6f, 7.2f, 2.4f, -1.11022e-15f, -1.11022e-15f, -5.6f, -7.2f, -7.2f,
-1.11022e-15f, -1.11022e-15f }
},
{
- "fullbass", 10, 5.0f,
+ "fullbass", EQZ_VLC10_BANDS_MAX, 5.0f,
{ -8.0f, 9.6f, 9.6f, 5.6f, 1.6f, -4.0f, -8.0f, -10.4f, -11.2f, -11.2f }
},
{
- "fullbasstreble", 10, 4.0f,
+ "fullbasstreble", EQZ_VLC10_BANDS_MAX, 4.0f,
{ 7.2f, 5.6f, -1.11022e-15f, -7.2f, -4.8f, 1.6f, 8.0f, 11.2f,
12.0f, 12.0f }
},
{
- "fulltreble", 10, 3.0f,
+ "fulltreble", EQZ_VLC10_BANDS_MAX, 3.0f,
{ -9.6f, -9.6f, -9.6f, -4.0f, 2.4f, 11.2f, 16.0f, 16.0f, 16.0f, 16.8f }
},
{
- "headphones", 10, 4.0f,
+ "headphones", EQZ_VLC10_BANDS_MAX, 4.0f,
{ 4.8f, 11.2f, 5.6f, -3.2f, -2.4f, 1.6f, 4.8f, 9.6f, 12.8f, 14.4f }
},
{
- "largehall", 10, 5.0f,
+ "largehall", EQZ_VLC10_BANDS_MAX, 5.0f,
{ 10.4f, 10.4f, 5.6f, 5.6f, -1.11022e-15f, -4.8f, -4.8f, -4.8f,
-1.11022e-15f, -1.11022e-15f }
},
{
- "live", 10, 7.0f,
+ "live", EQZ_VLC10_BANDS_MAX, 7.0f,
{ -4.8f, -1.11022e-15f, 4.0f, 5.6f, 5.6f, 5.6f, 4.0f, 2.4f,
2.4f, 2.4f }
},
{
- "party", 10, 6.0f,
+ "party", EQZ_VLC10_BANDS_MAX, 6.0f,
{ 7.2f, 7.2f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
-1.11022e-15f, -1.11022e-15f, -1.11022e-15f, 7.2f, 7.2f }
},
{
- "pop", 10, 6.0f,
+ "pop", EQZ_VLC10_BANDS_MAX, 6.0f,
{ -1.6f, 4.8f, 7.2f, 8.0f, 5.6f, -1.11022e-15f, -2.4f, -2.4f,
-1.6f, -1.6f }
},
{
- "reggae", 10, 8.0f,
+ "reggae", EQZ_VLC10_BANDS_MAX, 8.0f,
{ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -5.6f, -1.11022e-15f,
6.4f, 6.4f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f }
},
{
- "rock", 10, 5.0f,
+ "rock", EQZ_VLC10_BANDS_MAX, 5.0f,
{ 8.0f, 4.8f, -5.6f, -8.0f, -3.2f, 4.0f, 8.8f, 11.2f, 11.2f, 11.2f }
},
{
- "ska", 10, 6.0f,
+ "ska", EQZ_VLC10_BANDS_MAX, 6.0f,
{ -2.4f, -4.8f, -4.0f, -1.11022e-15f, 4.0f, 5.6f, 8.8f, 9.6f,
11.2f, 9.6f }
},
{
- "soft", 10, 5.0f,
+ "soft", EQZ_VLC10_BANDS_MAX, 5.0f,
{ 4.8f, 1.6f, -1.11022e-15f, -2.4f, -1.11022e-15f, 4.0f, 8.0f, 9.6f,
11.2f, 12.0f }
},
{
- "softrock", 10, 7.0f,
+ "softrock", EQZ_VLC10_BANDS_MAX, 7.0f,
{ 4.0f, 4.0f, 2.4f, -1.11022e-15f, -4.0f, -5.6f, -3.2f, -1.11022e-15f,
2.4f, 8.8f }
},
{
- "techno", 10, 5.0f,
+ "techno", EQZ_VLC10_BANDS_MAX, 5.0f,
{ 8.0f, 5.6f, -1.11022e-15f, -5.6f, -4.8f, -1.11022e-15f, 8.0f, 9.6f,
9.6f, 8.8f }
},
};
+/* Preset table for the 10-band ISO equalizer. The boosts and cuts were
+ * sampled from the VLC presets at the true ISO frequency centers using
+ * monotone cubic interpolation and then rounded to the nearest tenth */
+static const EQZ_PRESET_TYPE( 10 ) eqz_preset_iso_10b[NB_PRESETS] =
+{
+ {
+ "flat", EQZ_ISO10_BANDS_MAX, 12.0f,
+ { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+ },
+ {
+ "classical", EQZ_ISO10_BANDS_MAX, 12.0f,
+ { -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.9f, -7.2f, -9.6f }
+ },
+ {
+ "club", EQZ_ISO10_BANDS_MAX, 6.0f,
+ { -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, 4.9f, 6.3f, 5.6f, 5.6f,
+ 5.1f, 1.8f, -1.11022e-15f }
+ },
+ {
+ "dance", EQZ_ISO10_BANDS_MAX, 5.0f,
+ { 9.6f, 9.5f, 8.3f, 4.2f, 0.3f, -1.11022e-15f, -2.6f, -6.4f, -7.2f,
+ -1.11022e-15f }
+ },
+ {
+ "fullbass", EQZ_ISO10_BANDS_MAX, 5.0f,
+ { -8.0f, -7.6f, 4.9f, 9.6f, 7.2f, 1.6f, -2.0f, -5.7f, -9.0f, -11.2f }
+ },
+ {
+ "fullbasstreble", EQZ_ISO10_BANDS_MAX, 4.0f,
+ { 7.2f, 7.2f, 6.4f, 2.5f, -5.9f, -4.8f, -1.1f, 4.2f, 9.4f, 12.0f }
+ },
+ {
+ "fulltreble", EQZ_ISO10_BANDS_MAX, 3.0f,
+ { -9.6f, -9.6f, -9.6f, -9.6f, -6.3f, 2.4f, 8.2f, 13.5f, 16.0f, 16.8f }
+ },
+ {
+ "headphones", EQZ_ISO10_BANDS_MAX, 4.0f,
+ { 4.8f, 4.9f, 9.5f, 8.5f, -1.6f, -2.4f, -0.3f, 2.9f, 6.4f, 14.4f }
+ },
+ {
+ "largehall", EQZ_ISO10_BANDS_MAX, 5.0f,
+ { 10.4f, 10.4f, 10.4f, 7.5f, 5.6f, -1.11022e-15f, -3.6f, -4.8f, -4.8f,
+ -1.11022e-15f }
+ },
+ {
+ "live", EQZ_ISO10_BANDS_MAX, 7.0f,
+ { -4.8f, -4.7f, -1.8f, 2.7f, 5.4f, 5.6f, 5.6f, 5.3f, 3.3f, 2.4f }
+ },
+ {
+ "party", EQZ_ISO10_BANDS_MAX, 6.0f,
+ { 7.2f, 7.2f, 7.2f, 2.8f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, 7.2f }
+ },
+ {
+ "pop", EQZ_ISO10_BANDS_MAX, 6.0f,
+ { -1.6f, -1.5f, 2.7f, 6.6f, 7.9f, 5.6f, 2.1f, -1.2f, -2.4f, -1.6f }
+ },
+ {
+ "reggae", EQZ_ISO10_BANDS_MAX, 8.0f,
+ { -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -4.1f, -1.11022e-15f, 4.7f, 6.4f, 4.7f, -1.11022e-15f }
+ },
+ {
+ "rock", EQZ_ISO10_BANDS_MAX, 5.0f,
+ { 8.0f, 7.9f, 6.3f, -1.8f, -7.7f, -3.2f, 1.4f, 6.1f, 10.0f, 11.2f }
+ },
+ {
+ "ska", EQZ_ISO10_BANDS_MAX, 6.0f,
+ { -2.4f, -2.5f, -4.2f, -4.5f, -1.4f, 4.0f, 5.0f, 6.8f, 9.1f, 9.6f }
+ },
+ {
+ "soft", EQZ_ISO10_BANDS_MAX, 5.0f,
+ { 4.8f, 4.7f, 2.7f, 0.6f, -2.0f, -1.11022e-15, 2.4f, 5.7f, 8.6f,
+ 12.0f }
+ },
+ {
+ "softrock", EQZ_ISO10_BANDS_MAX, 7.0f,
+ { 4.0f, 4.0f, 4.0f, 3.2f, 0.8f, -4.0f, -5.3f, -5.1f, -2.1f, 8.8f }
+ },
+ {
+ "techno", EQZ_ISO10_BANDS_MAX, 5.0f,
+ { 8.0f, 7.9f, 6.7f, 2.3f, -4.6f, -4.8f, -2.5f, 3.1f, 8.9f, 8.8f }
+ },
+};
+
+/* Preset table for the 15-band ISO equalizer. The boosts and cuts were
+ * sampled from the VLC presets at the true ISO frequency centers using
+ * monotone cubic interpolation and then rounded to the nearest tenth */
+static const EQZ_PRESET_TYPE( 15 ) eqz_preset_iso_15b[NB_PRESETS] =
+{
+ {
+ "flat", EQZ_ISO15_BANDS_MAX, 12.0f,
+ { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f },
+ },
+ {
+ "classical", EQZ_ISO15_BANDS_MAX, 12.0f,
+ { -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.9f, -7.2f, -7.2f,
+ -9.6f }
+ },
+ {
+ "club", EQZ_ISO15_BANDS_MAX, 6.0f,
+ { -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, 4.9f, 7.5f, 5.6f, 5.6f, 5.6f, 5.6f, 5.1f, 3.0f, 0.5f,
+ -1.11022e-15f }
+ },
+ {
+ "dance", EQZ_ISO15_BANDS_MAX, 5.0f,
+ { 9.6f, 9.6f, 9.5f, 8.7f, 7.5f, 4.2f, 1.3f, -1.11022e-15f,
+ -1.11022e-15f, -1.1f, -4.5f, -6.4f, -7.2f, -7.2f, -1.11022e-15f }
+ },
+ {
+ "fullbass", EQZ_ISO15_BANDS_MAX, 5.0f,
+ { -8.0f, -8.0f, -7.6f, -0.3f, 9.1f, 9.6f, 9.0f, 5.2f, 1.6f, -0.8f,
+ -3.1f, -5.7f, -8.2f, -9.7f, -11.2f }
+ },
+ {
+ "fullbasstreble", EQZ_ISO15_BANDS_MAX, 4.0f,
+ { 7.2f, 7.2f, 7.2f, 6.7f, 5.8f, 2.5f, -2.9f, -7.2f, -4.8f, -2.5f, 0.3f,
+ 4.2f, 8.3f, 10.4f, 12.0f }
+ },
+ {
+ "fulltreble", EQZ_ISO15_BANDS_MAX, 3.0f,
+ { -9.6f, -9.6f, -9.6f, -9.6f, -9.6f, -9.6f, -8.7f, -3.5f, 2.4f, 6.3f,
+ 9.9f, 13.5f, 16.0f, 16.0f, 16.8f }
+ },
+ {
+ "headphones", EQZ_ISO15_BANDS_MAX, 4.0f,
+ { 4.8f, 4.8f, 4.9f, 7.6f, 11.0f, 8.5f, 2.2f, -3.2f, -2.4f, -1.2f, 0.8f,
+ 2.9f, 5.1f, 7.8f, 14.4f }
+ },
+ {
+ "largehall", EQZ_ISO15_BANDS_MAX, 5.0f,
+ { 10.4f, 10.4f, 10.4f, 10.4f, 10.4f, 7.5f, 5.6f, 5.5f, -1.11022e-15f,
+ -2.4f, -4.5f, -4.8f, -4.8f, -4.8f, -1.11022e-15f }
+ },
+ {
+ "live", EQZ_ISO15_BANDS_MAX, 7.0f,
+ { -4.8f, -4.8f, -4.7f, -3.0f, -0.5f, 2.7f, 4.7f, 5.6f, 5.6f, 5.6f,
+ 5.6f, 5.3f, 3.9f, 2.6f, 2.4f }
+ },
+ {
+ "party", EQZ_ISO15_BANDS_MAX, 6.0f,
+ { 7.2f, 7.2f, 7.2f, 7.2f, 7.2f, 2.8f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, 7.2f }
+ },
+ {
+ "pop", EQZ_ISO15_BANDS_MAX, 6.0f,
+ { -1.6f, -1.6f, -1.5f, 1.0f, 4.4f, 6.6f, 7.6f, 8.0f, 5.6f, 3.4f, 0.8f,
+ -1.2f, -2.4f, -2.4f, -1.6f }
+ },
+ {
+ "reggae", EQZ_ISO15_BANDS_MAX, 8.0f,
+ { -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.2f, -5.5f, -1.11022e-15f, 3.1f,
+ 6.0f, 6.4f, 6.3f, 1.5f, -1.11022e-15f }
+ },
+ {
+ "rock", EQZ_ISO15_BANDS_MAX, 5.0f,
+ { 8.0f, 8.0f, 7.9f, 7.0f, 5.3f, -1.8f, -6.8f, -7.9f, -3.2f, -0.1f,
+ 2.9f, 6.1f, 9.0f, 10.9f, 11.2f }
+ },
+ {
+ "ska", EQZ_ISO15_BANDS_MAX, 6.0f,
+ { -2.4f, -2.4f, -2.5f, -3.5f, -4.7f, -4.5f, -3.0f, 0.4f, 4.0f, 4.8f,
+ 5.3f, 6.8f, 8.9f, 9.3f, 9.6f }
+ },
+ {
+ "soft", EQZ_ISO15_BANDS_MAX, 5.0f,
+ { 4.8f, 4.8f, 4.7f, 3.5f, 1.8f, 0.6f, -0.9f, -2.4f, -1.11022e-15, 1.6f,
+ 3.3f, 5.7f, 8.2f, 9.0f, 12.0f }
+ },
+ {
+ "softrock", EQZ_ISO15_BANDS_MAX, 7.0f,
+ { 4.0f, 4.0f, 4.0f, 4.0f, 4.0f, 3.2f, 1.6f, -0.3f, -4.0f, -4.9f, -5.5f,
+ -5.1f, -3.0f, -1.2f, 8.8f }
+ },
+ {
+ "techno", EQZ_ISO15_BANDS_MAX, 5.0f,
+ { 8.0f, 8.0f, 7.9f, 7.2f, 5.9f, 2.3f, -2.4f, -5.6f, -4.8f, -3.4f,
+ -1.2f, 3.1f, 8.2f, 9.4f, 8.8f }
+ },
+};
+
+/* Preset table for the 31-band ISO equalizer. The boosts and cuts were
+ * sampled from the VLC presets at the true ISO frequency centers using
+ * monotone cubic interpolation and then rounded to the nearest tenth */
+static const EQZ_PRESET_TYPE( 31 ) eqz_preset_iso_31b[NB_PRESETS] =
+{
+ {
+ "flat", EQZ_ISO31_BANDS_MAX, 12.0f,
+ { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+ },
+ {
+ "classical", EQZ_ISO31_BANDS_MAX, 12.0f,
+ { -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -0.1f, -1.9f, -5.5f, -7.2f, -7.2f,
+ -7.2f, -7.2f, -9.6f, -9.6f }
+ },
+ {
+ "club", EQZ_ISO31_BANDS_MAX, 6.0f,
+ { -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, 0.9f, 4.9f, 8.0f, 7.5f, 6.3f, 5.6f,
+ 5.6f, 5.6f, 5.6f, 5.6f, 5.6f, 5.6f, 5.6f, 5.1f, 4.1f, 3.0f, 1.8f,
+ 0.5f, -1.11022e-15f, -1.11022e-15f }
+ },
+ {
+ "dance", EQZ_ISO31_BANDS_MAX, 5.0f,
+ { 9.6f, 9.6f, 9.6f, 9.6f, 9.6f, 9.5f, 9.2f, 8.7f, 8.3f, 7.5f, 6.3f,
+ 4.2f, 2.3f, 1.3f, 0.3f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -0.2f, -1.1f, -2.6f, -4.5f, -5.8f, -6.4f, -7.0f, -7.2f, -7.2f, -7.2f,
+ -5.2f, -1.11022e-15f, -1.11022e-15f }
+ },
+ {
+ "fullbass", EQZ_ISO31_BANDS_MAX, 5.0f,
+ { -8.0f, -8.0f, -8.0f, -8.0f, -8.0f, -7.6f, -4.6f, -0.3f, 4.9f, 9.1f,
+ 9.6f, 9.6f, 9.6f, 9.0f, 7.2f, 5.2f, 3.3f, 1.6f, 0.4f, -0.8f, -2.0f,
+ -3.1f, -4.3f, -5.7f, -7.1f, -8.2f, -9.0f, -9.7f, -10.7f, -11.2f,
+ -11.2f }
+ },
+ {
+ "fullbasstreble", EQZ_ISO31_BANDS_MAX, 4.0f,
+ { 7.2f, 7.2f, 7.2f, 7.2f, 7.2f, 7.2f, 6.9f, 6.7f, 6.4f, 5.8f, 4.8f,
+ 2.5f, -0.2f, -2.9f, -5.9f, -7.2f, -6.3f, -4.8f, -3.7f, -2.5f, -1.1f,
+ 0.3f, 2.1f, 4.2f, 6.6f, 8.3f, 9.4f, 10.4f, 11.6f, 12.0f, 12.0f }
+ },
+ {
+ "fulltreble", EQZ_ISO31_BANDS_MAX, 3.0f,
+ { -9.6f, -9.6f, -9.6f, -9.6f, -9.6f, -9.6f, -9.6f, -9.6f, -9.6f, -9.6f,
+ -9.6f, -9.6f, -9.6f, -8.7f, -6.3f, -3.5f, -0.4f, 2.4f, 4.3f, 6.3f,
+ 8.2f, 9.9f, 11.6f, 13.5f, 15.3f, 16.0f, 16.0f, 16.0f, 16.0f, 16.8f,
+ 16.8f }
+ },
+ {
+ "headphones", EQZ_ISO31_BANDS_MAX, 4.0f,
+ { 4.8f, 4.8f, 4.8f, 4.8f, 4.8f, 4.9f, 6.0f, 7.6f, 9.5f, 11.0f, 10.8f,
+ 8.5f, 5.4f, 2.2f, -1.6f, -3.2f, -2.9f, -2.4f, -1.9f, -1.2f, -0.3f,
+ 0.8f, 1.8f, 2.9f, 3.9f, 5.1f, 6.4f, 7.8f, 10.7f, 14.4f, 14.4f }
+ },
+ {
+ "largehall", EQZ_ISO31_BANDS_MAX, 5.0f,
+ { 10.4f, 10.4f, 10.4f, 10.4f, 10.4f, 10.4f, 10.4f, 10.4f, 10.4f, 10.4f,
+ 9.9f, 7.5f, 5.6f, 5.6f, 5.6f, 5.5f, 3.2f, -1.11022e-15f, -1.2f,
+ -2.4f, -3.6f, -4.5f, -4.8f, -4.8f, -4.8f, -4.8f, -4.8f, -4.8f, -3.5f,
+ -1.11022e-15f, -1.11022e-15f }
+ },
+ {
+ "live", EQZ_ISO31_BANDS_MAX, 7.0f,
+ { -4.8f, -4.8f, -4.8f, -4.8f, -4.8f, -4.7f, -4.0f, -3.0f, -1.8f, -0.5f,
+ 1.0f, 2.7f, 4.0f, 4.7f, 5.4f, 5.6f, 5.6f, 5.6f, 5.6f, 5.6f, 5.6f,
+ 5.6f, 5.6f, 5.3f, 4.6f, 3.9f, 3.3f, 2.6f, 2.4f, 2.4f, 2.4f }
+ },
+ {
+ "party", EQZ_ISO31_BANDS_MAX, 6.0f,
+ { 7.2f, 7.2f, 7.2f, 7.2f, 7.2f, 7.2f, 7.2f, 7.2f, 7.2f, 7.2f, 6.4f,
+ 2.8f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, 2.0f,
+ 7.2f, 7.2f }
+ },
+ {
+ "pop", EQZ_ISO31_BANDS_MAX, 6.0f,
+ { -1.6f, -1.6f, -1.6f, -1.6f, -1.6f, -1.5f, -0.4f, 1.0f, 2.7f, 4.4f,
+ 5.5f, 6.6f, 7.2f, 7.6f, 7.9f, 8.0f, 7.1f, 5.6f, 4.6f, 3.4f, 2.1f,
+ 0.8f, -0.2f, -1.2f, -2.1f, -2.4f, -2.4f, -2.4f, -2.2f, -1.6f, -1.6f }
+ },
+ {
+ "reggae", EQZ_ISO31_BANDS_MAX, 8.0f,
+ { -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f, -1.11022e-15f, -1.11022e-15f,
+ -1.11022e-15f, -1.2f, -4.1f, -5.5f, -3.2f, -1.11022e-15f, 1.5f, 3.1f,
+ 4.7f, 6.0f, 6.4f, 6.4f, 6.4f, 6.3f, 4.7f, 1.5f, -1.11022e-15f,
+ -1.11022e-15f, -1.11022e-15f }
+ },
+ {
+ "rock", EQZ_ISO31_BANDS_MAX, 5.0f,
+ { 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 7.9f, 7.5f, 7.0f, 6.3f, 5.3f, 3.0f,
+ -1.8f, -5.7f, -6.8f, -7.7f, -7.9f, -6.0f, -3.2f, -1.7f, -0.1f,
+ 1.4f, 2.9f, 4.4f, 6.1f, 7.8f, 9.0f, 10.0f, 10.9f, 11.2f, 11.2f,
+ 11.2f }
+ },
+ {
+ "ska", EQZ_ISO31_BANDS_MAX, 6.0f,
+ { -2.4f, -2.4f, -2.4f, -2.4f, -2.4f, -2.5f, -2.9f, -3.5f, -4.2f, -4.7f,
+ -4.7f, -4.5f, -4.0f, -3.0f, -1.4, 0.4f, 2.4f, 4.0f, 4.4f, 4.8f, 5.0f,
+ 5.3f, 5.8f, 6.8f, 8.1f, 8.9f, 9.1f, 9.3f, 10.1f, 9.6f, 9.6f }
+ },
+ {
+ "soft", EQZ_ISO31_BANDS_MAX, 5.0f,
+ { 4.8f, 4.8f, 4.8f, 4.8f, 4.8f, 4.7f, 4.2f, 3.5f, 2.7f, 1.8f, 1.1f,
+ 0.6f, -1.11022e-15, -0.9f, -2.0f, -2.4f, -1.4f, -1.11022e-15, 0.8f,
+ 1.6f, 2.4f, 3.3f, 4.3f, 5.7f, 7.2f, 8.2f, 8.6f, 9.0f, 10.1f, 12.0f,
+ 12.0f }
+ },
+ {
+ "softrock", EQZ_ISO31_BANDS_MAX, 7.0f,
+ { 4.0f, 4.0f, 4.0f, 4.0f, 4.0f, 4.0f, 4.0f, 4.0f, 4.0f, 4.0f, 3.9f,
+ 3.2f, 2.4f, 1.6f, 0.8f, -0.3f, -2.3f, -4.0f, -4.4f, -4.9f, -5.3f,
+ -5.5f, -5.6f, -5.1f, -4.1f, -3.0f, -2.1f, -1.2f, 0.6f, 8.8f, 8.8f }
+ },
+ {
+ "techno", EQZ_ISO31_BANDS_MAX, 5.0f,
+ { 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 7.9f, 7.6f, 7.2f, 6.7f, 5.9f, 4.6f,
+ 2.3f, -0.1f, -2.4f, -4.7f, -5.6f, -5.3f, -4.8f, -4.2f, -3.4f, -2.5f,
+ -1.2f, 0.5f, 3.1f, 6.4f, 8.2f, 8.9f, 9.4f, 9.6f, 8.8f, 8.8f }
+ },
+};
+
+/* ********************* Preset table helper functions ********************* */
+
+/* Function for retrieving a pointer to the boosts/cuts */
+static inline
+const float * EqzGetAmpPtr( const eqz_base_preset_t * p_preset )
+{
+ return ( const float * ) ( p_preset + 1 );
+}
+
+/* Function for easily finding the size of a single preset table structure */
+static inline
+size_t EqzGetPresetSize( const eqz_base_preset_t * p_preset )
+{
+ return sizeof( *p_preset ) + p_preset->i_band * sizeof( float );
+}
+
+/* Function for retrieving the preset table at the specified zero-based
+ * index */
+static inline const eqz_base_preset_t *
+EqzGetPresetAt( const eqz_base_preset_t * p_preset_table, int i_index )
+{
+ return ( const eqz_base_preset_t * ) ( ( int8_t * ) p_preset_table
+ + i_index * EqzGetPresetSize( p_preset_table ) );
+}
+
+/* Function for retrieving the correct preset table by type */
+static inline
+const eqz_base_preset_t * EqzGetPresetTable( int i_type_number )
+{
+ switch( i_type_number )
+ {
+ case EQZ_VLC10_TYPE:
+ return EQZ_BASE_PRESET( &eqz_preset_vlc_10b );
+ case EQZ_ISO10_TYPE:
+ return EQZ_BASE_PRESET( &eqz_preset_iso_10b );
+ case EQZ_ISO15_TYPE:
+ return EQZ_BASE_PRESET( &eqz_preset_iso_15b );
+ case EQZ_ISO31_TYPE:
+ return EQZ_BASE_PRESET( &eqz_preset_iso_31b );
+ default:
+ return NULL;
+ }
+}
+
+/* ********************** More type-related functions ********************** */
+
+/* Function for retrieving the number of bands in an equalizer by its type */
+static inline int EqzGetNumBandsByType( int i_type_number )
+{
+ return EqzGetPresetTable( i_type_number )->i_band;
+}
+
+/* Determine the most valid equalizer identifier from the number of bands and
+ * a string with a possibly invalid identifier */
+static inline char EqzGetValidIdentifier( vlc_object_t *p_obj, int i_cur_type,
+ const char * psz_identifier,
+ int i_bands )
+{
+ char eqz_identifier;
+ switch( i_bands )
+ {
+ case EQZ_ISO10_BANDS_MAX:
+ /* fall-through */
+ case EQZ_ISO15_BANDS_MAX:
+ /* fall-through */
+ case EQZ_ISO31_BANDS_MAX:
+ {
+ size_t i_id_len = psz_identifier ? strlen( psz_identifier ) : 0;
+ if( i_id_len != 1 ||
+ ( psz_identifier[0] != EQZ_VLC_IDENTIFIER &&
+ psz_identifier[0] != EQZ_ISO_IDENTIFIER ) )
+ {
+ eqz_identifier = EqzGetDefaultIdentifier( i_bands );
+ if( i_id_len == 0 )
+ {
+ /* No identifier specified in string */
+ if( i_bands == EQZ_ISO10_BANDS_MAX )
+ {
+ msg_Warn( p_obj, "equalizer identifier not specified "
+ "for 10 bands; assuming VLC bands" );
+ }
+ }
+ else
+ {
+ /* Found invalid identifier */
+ msg_Warn( p_obj, "invalid equalizer identifier '%s'; "
+ "assuming default equalizer type for %d bands ('%c')",
+ psz_identifier, i_bands, eqz_identifier );
+ }
+ }
+ else if( i_bands != EQZ_ISO10_BANDS_MAX &&
+ psz_identifier[0] == EQZ_VLC_IDENTIFIER )
+ {
+ /* Found VLC equalizer type for 15 and 31 bands, but we only
+ * provide ISO bands in these cases */
+ eqz_identifier = EQZ_ISO_IDENTIFIER;
+ msg_Warn( p_obj, "equalizer identifier '%s' not defined for "
+ "%d bands; using ISO bands", psz_identifier, i_bands );
+ }
+ else
+ {
+ /* Found VLC or ISO identifier for 10 bands and ISO identifier
+ * for 15 and 31 bands */
+ eqz_identifier = psz_identifier[0];
+ }
+ break;
+ }
+ default:
+ {
+ /* Default is to assume current mode */
+ int i_cur_bands = EqzGetNumBandsByType( i_cur_type );
+ int i_smallest_bands = __MIN( i_cur_bands, i_bands );
+ eqz_identifier = EqzGetIdentifier( i_cur_type );
+ if( i_smallest_bands == 1 )
+ {
+ msg_Warn( p_obj, "found only one band (which is not 10, 15, "
+ "or 31, as it ought to be); assuming it corresponds to "
+ "the first band of the currently active equalizer type "
+ "(%d-band %s equalizer)", i_cur_bands,
+ EqzGetStringIdentifier( eqz_identifier ) );
+ }
+ else
+ {
+ msg_Warn( p_obj, "found unexpected number of bands (%d, which "
+ "is not 10, 15, or 31, as it ought to be); assuming the "
+ "%s%d bands correspond to the %s%d bands of the currently "
+ "active equalizer type (%d-band %s equalizer)", i_bands,
+ i_cur_bands < i_bands ? "first " : "", i_smallest_bands,
+ i_cur_bands > i_bands ? "first " : "", i_smallest_bands,
+ i_cur_bands, EqzGetStringIdentifier( eqz_identifier ) );
+ }
+ break;
+ }
+ }
+ return eqz_identifier;
+}
+
#endif
--
1.9.1
More information about the vlc-devel
mailing list