Commit f4069644 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Constify and relocatablify EQ presets

Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 66f0d1a5
...@@ -505,20 +505,20 @@ static int PresetCallback( vlc_object_t *p_aout, char const *psz_cmd, ...@@ -505,20 +505,20 @@ static int PresetCallback( vlc_object_t *p_aout, char const *psz_cmd,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
for( unsigned i = 0; eqz_preset_10b[i] != NULL; i++ ) for( unsigned i = 0; i < NB_PRESETS; i++ )
{ {
if( !strcasecmp( eqz_preset_10b[i]->psz_name, psz_preset ) ) if( !strcasecmp( eqz_preset_10b[i].psz_name, psz_preset ) )
{ {
char *psz_newbands = NULL; char *psz_newbands = NULL;
p_sys->f_gamp *= pow( 10, eqz_preset_10b[i]->f_preamp / 20.0 ); p_sys->f_gamp *= pow( 10, eqz_preset_10b[i].f_preamp / 20.0 );
for( int j = 0; j < p_sys->i_band; j++ ) for( int j = 0; j < p_sys->i_band; j++ )
{ {
lldiv_t d; lldiv_t d;
char *psz; char *psz;
p_sys->f_amp[j] = EqzConvertdB( eqz_preset_10b[i]->f_amp[j] ); p_sys->f_amp[j] = EqzConvertdB( eqz_preset_10b[i].f_amp[j] );
d = lldiv( eqz_preset_10b[i]->f_amp[j] * 10000000, 10000000 ); d = lldiv( eqz_preset_10b[i].f_amp[j] * 10000000, 10000000 );
if( asprintf( &psz, "%s %lld.%07llu", if( asprintf( &psz, "%s %lld.%07llu",
psz_newbands ? psz_newbands : "", psz_newbands ? psz_newbands : "",
d.quot, d.rem ) == -1 ) d.quot, d.rem ) == -1 )
...@@ -535,13 +535,13 @@ static int PresetCallback( vlc_object_t *p_aout, char const *psz_cmd, ...@@ -535,13 +535,13 @@ static int PresetCallback( vlc_object_t *p_aout, char const *psz_cmd,
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
var_SetString( p_aout, "equalizer-bands", psz_newbands ); var_SetString( p_aout, "equalizer-bands", psz_newbands );
var_SetFloat( p_aout, "equalizer-preamp", var_SetFloat( p_aout, "equalizer-preamp",
eqz_preset_10b[i]->f_preamp ); eqz_preset_10b[i].f_preamp );
free( psz_newbands ); free( psz_newbands );
} }
else else
{ {
p_sys->psz_newbands = psz_newbands; p_sys->psz_newbands = psz_newbands;
p_sys->f_newpreamp = eqz_preset_10b[i]->f_preamp; p_sys->f_newpreamp = eqz_preset_10b[i].f_preamp;
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
} }
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -550,8 +550,8 @@ static int PresetCallback( vlc_object_t *p_aout, char const *psz_cmd, ...@@ -550,8 +550,8 @@ static int PresetCallback( vlc_object_t *p_aout, char const *psz_cmd,
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
msg_Err( p_aout, "equalizer preset '%s' not found", psz_preset ); msg_Err( p_aout, "equalizer preset '%s' not found", psz_preset );
msg_Info( p_aout, "full list:" ); msg_Info( p_aout, "full list:" );
for( unsigned i = 0; eqz_preset_10b[i] != NULL; i++ ) for( unsigned i = 0; i < NB_PRESETS; i++ )
msg_Info( p_aout, " - '%s'", eqz_preset_10b[i]->psz_name ); msg_Info( p_aout, " - '%s'", eqz_preset_10b[i].psz_name );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -31,12 +31,12 @@ ...@@ -31,12 +31,12 @@
#define EQZ_BANDS_MAX 10 #define EQZ_BANDS_MAX 10
#define NB_PRESETS 18 #define NB_PRESETS 18
static const char *const preset_list[] = { static const char *const preset_list[NB_PRESETS] = {
"flat", "classical", "club", "dance", "fullbass", "fullbasstreble", "flat", "classical", "club", "dance", "fullbass", "fullbasstreble",
"fulltreble", "headphones","largehall", "live", "party", "pop", "reggae", "fulltreble", "headphones","largehall", "live", "party", "pop", "reggae",
"rock", "ska", "soft", "softrock", "techno" "rock", "ska", "soft", "softrock", "techno"
}; };
static const char *const preset_list_text[] = { static const char *const preset_list_text[NB_PRESETS] = {
N_("Flat"), N_("Classical"), N_("Club"), N_("Dance"), N_("Full bass"), N_("Flat"), N_("Classical"), N_("Club"), N_("Dance"), N_("Full bass"),
N_("Full bass and treble"), N_("Full treble"), N_("Headphones"), N_("Full bass and treble"), N_("Full treble"), N_("Headphones"),
N_("Large Hall"), N_("Live"), N_("Party"), N_("Pop"), N_("Reggae"), N_("Large Hall"), N_("Live"), N_("Party"), N_("Pop"), N_("Reggae"),
...@@ -45,126 +45,90 @@ static const char *const preset_list_text[] = { ...@@ -45,126 +45,90 @@ static const char *const preset_list_text[] = {
typedef struct typedef struct
{ {
const char *psz_name; const char psz_name[16];
int i_band; int i_band;
float f_preamp; float f_preamp;
float f_amp[EQZ_BANDS_MAX]; float f_amp[EQZ_BANDS_MAX];
} eqz_preset_t; } eqz_preset_t;
static const eqz_preset_t eqz_preset_flat_10b= static const eqz_preset_t eqz_preset_10b[NB_PRESETS] =
{ {
"flat", 10, 12.0, {
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, "flat", 10, 12.0,
}; { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
static const eqz_preset_t eqz_preset_classical_10b= },
{ {
"classical", 10, 12.0, "classical", 10, 12.0,
{ -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15, -7.2, -7.2, -7.2, -9.6 } { -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15,
}; -1.11022e-15, -1.11022e-15, -7.2, -7.2, -7.2, -9.6 }
static const eqz_preset_t eqz_preset_club_10b= },
{ {
"club", 10, 6.0, "club", 10, 6.0,
{ -1.11022e-15, -1.11022e-15, 8, 5.6, 5.6, 5.6, 3.2, -1.11022e-15, -1.11022e-15, -1.11022e-15 } { -1.11022e-15, -1.11022e-15, 8, 5.6, 5.6, 5.6, 3.2, -1.11022e-15,
}; -1.11022e-15, -1.11022e-15 }
static const eqz_preset_t eqz_preset_dance_10b= },
{ {
"dance", 10, 5.0, "dance", 10, 5.0,
{ 9.6, 7.2, 2.4, -1.11022e-15, -1.11022e-15, -5.6, -7.2, -7.2, -1.11022e-15, -1.11022e-15 } { 9.6, 7.2, 2.4, -1.11022e-15, -1.11022e-15, -5.6, -7.2, -7.2,
}; -1.11022e-15, -1.11022e-15 }
static const eqz_preset_t eqz_preset_fullbass_10b= },
{ {
"fullbass", 10, 5.0, "fullbass", 10, 5.0,
{ -8, 9.6, 9.6, 5.6, 1.6, -4, -8, -10.4, -11.2, -11.2 } { -8, 9.6, 9.6, 5.6, 1.6, -4, -8, -10.4, -11.2, -11.2 }
}; },
static const eqz_preset_t eqz_preset_fullbasstreble_10b= {
{ "fullbasstreble", 10, 4.0,
"fullbasstreble", 10, 4.0, { 7.2, 5.6, -1.11022e-15, -7.2, -4.8, 1.6, 8, 11.2, 12, 12 }
{ 7.2, 5.6, -1.11022e-15, -7.2, -4.8, 1.6, 8, 11.2, 12, 12 } },
}; {
"fulltreble", 10, 3.0,
static const eqz_preset_t eqz_preset_fulltreble_10b= { -9.6, -9.6, -9.6, -4, 2.4, 11.2, 16, 16, 16, 16.8 }
{ },
"fulltreble", 10, 3.0, {
{ -9.6, -9.6, -9.6, -4, 2.4, 11.2, 16, 16, 16, 16.8 } "headphones", 10, 4.0,
}; { 4.8, 11.2, 5.6, -3.2, -2.4, 1.6, 4.8, 9.6, 12.8, 14.4 }
static const eqz_preset_t eqz_preset_headphones_10b= },
{ {
"headphones", 10, 4.0, "largehall", 10, 5.0,
{ 4.8, 11.2, 5.6, -3.2, -2.4, 1.6, 4.8, 9.6, 12.8, 14.4 } { 10.4, 10.4, 5.6, 5.6, -1.11022e-15, -4.8, -4.8, -4.8, -1.11022e-15,
}; -1.11022e-15 }
static const eqz_preset_t eqz_preset_largehall_10b= },
{ {
"largehall", 10, 5.0, "live", 10, 7.0,
{ 10.4, 10.4, 5.6, 5.6, -1.11022e-15, -4.8, -4.8, -4.8, -1.11022e-15, -1.11022e-15 } { -4.8, -1.11022e-15, 4, 5.6, 5.6, 5.6, 4, 2.4, 2.4, 2.4 }
}; },
static const eqz_preset_t eqz_preset_live_10b= {
{ "party", 10, 6.0,
"live", 10, 7.0, { 7.2, 7.2, -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15,
{ -4.8, -1.11022e-15, 4, 5.6, 5.6, 5.6, 4, 2.4, 2.4, 2.4 } -1.11022e-15, -1.11022e-15, 7.2, 7.2 }
}; },
static const eqz_preset_t eqz_preset_party_10b= {
{ "pop", 10, 6.0,
"party", 10, 6.0, { -1.6, 4.8, 7.2, 8, 5.6, -1.11022e-15, -2.4, -2.4, -1.6, -1.6 }
{ 7.2, 7.2, -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15, 7.2, 7.2 } },
}; {
static const eqz_preset_t eqz_preset_pop_10b= "reggae", 10, 8.0,
{ { -1.11022e-15, -1.11022e-15, -1.11022e-15, -5.6, -1.11022e-15, 6.4,
"pop", 10, 6.0, 6.4, -1.11022e-15, -1.11022e-15, -1.11022e-15 }
{ -1.6, 4.8, 7.2, 8, 5.6, -1.11022e-15, -2.4, -2.4, -1.6, -1.6 } },
}; {
static const eqz_preset_t eqz_preset_reggae_10b= "rock", 10, 5.0,
{ { 8, 4.8, -5.6, -8, -3.2, 4, 8.8, 11.2, 11.2, 11.2 }
"reggae", 10, 8.0, },
{ -1.11022e-15, -1.11022e-15, -1.11022e-15, -5.6, -1.11022e-15, 6.4, 6.4, -1.11022e-15, -1.11022e-15, -1.11022e-15 } {
}; "ska", 10, 6.0,
static const eqz_preset_t eqz_preset_rock_10b= { -2.4, -4.8, -4, -1.11022e-15, 4, 5.6, 8.8, 9.6, 11.2, 9.6 }
{ },
"rock", 10, 5.0, {
{ 8, 4.8, -5.6, -8, -3.2, 4, 8.8, 11.2, 11.2, 11.2 } "soft", 10, 5.0,
}; { 4.8, 1.6, -1.11022e-15, -2.4, -1.11022e-15, 4, 8, 9.6, 11.2, 12 }
static const eqz_preset_t eqz_preset_ska_10b= },
{ {
"ska", 10, 6.0, "softrock", 10, 7.0,
{ -2.4, -4.8, -4, -1.11022e-15, 4, 5.6, 8.8, 9.6, 11.2, 9.6 } { 4, 4, 2.4, -1.11022e-15, -4, -5.6, -3.2, -1.11022e-15, 2.4, 8.8 }
}; },
static const eqz_preset_t eqz_preset_soft_10b= {
{ "techno", 10, 5.0,
"soft", 10, 5.0, { 8, 5.6, -1.11022e-15, -5.6, -4.8, -1.11022e-15, 8, 9.6, 9.6, 8.8 }
{ 4.8, 1.6, -1.11022e-15, -2.4, -1.11022e-15, 4, 8, 9.6, 11.2, 12 } },
}; };
static const eqz_preset_t eqz_preset_softrock_10b=
{
"softrock", 10, 7.0,
{ 4, 4, 2.4, -1.11022e-15, -4, -5.6, -3.2, -1.11022e-15, 2.4, 8.8 }
};
static const eqz_preset_t eqz_preset_techno_10b=
{
"techno", 10, 5.0,
{ 8, 5.6, -1.11022e-15, -5.6, -4.8, -1.11022e-15, 8, 9.6, 9.6, 8.8 }
};
static const eqz_preset_t *eqz_preset_10b[] =
{
&eqz_preset_flat_10b,
&eqz_preset_classical_10b,
&eqz_preset_club_10b,
&eqz_preset_dance_10b,
&eqz_preset_fullbass_10b,
&eqz_preset_fullbasstreble_10b,
&eqz_preset_fulltreble_10b,
&eqz_preset_headphones_10b,
&eqz_preset_largehall_10b,
&eqz_preset_live_10b,
&eqz_preset_party_10b,
&eqz_preset_pop_10b,
&eqz_preset_reggae_10b,
&eqz_preset_rock_10b,
&eqz_preset_ska_10b,
&eqz_preset_soft_10b,
&eqz_preset_softrock_10b,
&eqz_preset_techno_10b,
NULL
};
...@@ -196,7 +196,7 @@ static bool GetEqualizerStatus( intf_thread_t *p_custom_intf, ...@@ -196,7 +196,7 @@ static bool GetEqualizerStatus( intf_thread_t *p_custom_intf,
VLC_VAR_DOINHERIT ); VLC_VAR_DOINHERIT );
psz_preset = var_GetNonEmptyString( p_object, "equalizer-preset" ); psz_preset = var_GetNonEmptyString( p_object, "equalizer-preset" );
for( i = 0 ; (psz_preset != NULL) && (i < 18) ; i++ ) for( i = 0 ; i < NB_PRESETS ; i++ )
{ {
if( strcmp( preset_list[i], psz_preset ) ) if( strcmp( preset_list[i], psz_preset ) )
continue; continue;
...@@ -204,8 +204,8 @@ static bool GetEqualizerStatus( intf_thread_t *p_custom_intf, ...@@ -204,8 +204,8 @@ static bool GetEqualizerStatus( intf_thread_t *p_custom_intf,
[o_eq_presets_popup selectItemAtIndex: i]; [o_eq_presets_popup selectItemAtIndex: i];
[o_eq_preamp_sld setFloatValue: eqz_preset_10b[i]->f_preamp]; [o_eq_preamp_sld setFloatValue: eqz_preset_10b[i],f_preamp];
[self setBandSlidersValues: (float *)eqz_preset_10b[i]->f_amp]; [self setBandSlidersValues: (float *)eqz_preset_10b[i].f_amp];
if( strcmp( psz_preset, "flat" ) ) if( strcmp( psz_preset, "flat" ) )
{ {
...@@ -214,23 +214,23 @@ static bool GetEqualizerStatus( intf_thread_t *p_custom_intf, ...@@ -214,23 +214,23 @@ static bool GetEqualizerStatus( intf_thread_t *p_custom_intf,
snprintf( psz_bands, sizeof( psz_bands ), snprintf( psz_bands, sizeof( psz_bands ),
"%.1f %.1f %.1f %.1f %.1f %.1f %.1f " "%.1f %.1f %.1f %.1f %.1f %.1f %.1f "
"%.1f %.1f %.1f", "%.1f %.1f %.1f",
eqz_preset_10b[i]->f_amp[0], eqz_preset_10b[i].f_amp[0],
eqz_preset_10b[i]->f_amp[1], eqz_preset_10b[i].f_amp[1],
eqz_preset_10b[i]->f_amp[2], eqz_preset_10b[i].f_amp[2],
eqz_preset_10b[i]->f_amp[3], eqz_preset_10b[i].f_amp[3],
eqz_preset_10b[i]->f_amp[4], eqz_preset_10b[i].f_amp[4],
eqz_preset_10b[i]->f_amp[5], eqz_preset_10b[i].f_amp[5],
eqz_preset_10b[i]->f_amp[6], eqz_preset_10b[i].f_amp[6],
eqz_preset_10b[i]->f_amp[7], eqz_preset_10b[i].f_amp[7],
eqz_preset_10b[i]->f_amp[8], eqz_preset_10b[i].f_amp[8],
eqz_preset_10b[i]->f_amp[9] ); eqz_preset_10b[i].f_amp[9] );
var_Create( p_object, "equalizer-preamp", VLC_VAR_FLOAT | var_Create( p_object, "equalizer-preamp", VLC_VAR_FLOAT |
VLC_VAR_DOINHERIT ); VLC_VAR_DOINHERIT );
var_Create( p_object, "equalizer-bands", VLC_VAR_STRING | var_Create( p_object, "equalizer-bands", VLC_VAR_STRING |
VLC_VAR_DOINHERIT ); VLC_VAR_DOINHERIT );
var_SetFloat( p_object, "equalizer-preamp", var_SetFloat( p_object, "equalizer-preamp",
eqz_preset_10b[i]->f_preamp ); eqz_preset_10b[i].f_preamp );
var_SetString( p_object, "equalizer-bands", psz_bands ); var_SetString( p_object, "equalizer-bands", psz_bands );
} }
} }
...@@ -382,23 +382,23 @@ static bool GetEqualizerStatus( intf_thread_t *p_custom_intf, ...@@ -382,23 +382,23 @@ static bool GetEqualizerStatus( intf_thread_t *p_custom_intf,
NSString *preset = @""; NSString *preset = @"";
const char *psz_values; const char *psz_values;
for( int i = 0; i < 10; i++ ) for( int i = 0; i < EQZ_BANDS_MAX; i++ )
{ {
preset = [preset stringByAppendingFormat:@"%.1f ", eqz_preset_10b[[sender indexOfSelectedItem]]->f_amp[i] ]; preset = [preset stringByAppendingFormat:@"%.1f ", eqz_preset_10b[[sender indexOfSelectedItem]].f_amp[i] ];
} }
psz_values = [preset UTF8String]; psz_values = [preset UTF8String];
var_SetString( p_object, "equalizer-bands", psz_values ); var_SetString( p_object, "equalizer-bands", psz_values );
var_SetFloat( p_object, "equalizer-preamp", eqz_preset_10b[[sender indexOfSelectedItem]]->f_preamp); var_SetFloat( p_object, "equalizer-preamp", eqz_preset_10b[[sender indexOfSelectedItem]].f_preamp);
[o_eq_preamp_sld setFloatValue: eqz_preset_10b[[sender indexOfSelectedItem]]->f_preamp]; [o_eq_preamp_sld setFloatValue: eqz_preset_10b[[sender indexOfSelectedItem]].f_preamp];
[self setBandSlidersValues:(float *)eqz_preset_10b[[sender indexOfSelectedItem]]->f_amp]; [self setBandSlidersValues:(float *)eqz_preset_10b[[sender indexOfSelectedItem]].f_amp];
if( (BOOL)config_GetInt( p_intf, "macosx-eq-keep" ) == YES ) if( (BOOL)config_GetInt( p_intf, "macosx-eq-keep" ) == YES )
{ {
/* save changed to config */ /* save changed to config */
config_PutPsz( p_intf, "equalizer-bands", psz_values ); config_PutPsz( p_intf, "equalizer-bands", psz_values );
config_PutFloat( p_intf, "equalizer-preamp", eqz_preset_10b[[sender indexOfSelectedItem]]->f_preamp ); config_PutFloat( p_intf, "equalizer-preamp", eqz_preset_10b[[sender indexOfSelectedItem]].f_preamp );
config_PutPsz( p_intf, "equalizer-preset", preset_list[[sender indexOfSelectedItem]] ); config_PutPsz( p_intf, "equalizer-preset", preset_list[[sender indexOfSelectedItem]] );
} }
......
...@@ -1058,7 +1058,7 @@ char * Equalizer::createValuesFromPreset( int i_preset ) ...@@ -1058,7 +1058,7 @@ char * Equalizer::createValuesFromPreset( int i_preset )
/* Create the QString in Qt */ /* Create the QString in Qt */
for( int i = 0 ; i< BANDS ;i++ ) for( int i = 0 ; i< BANDS ;i++ )
values += QString( " %1" ).arg( eqz_preset_10b[i_preset]->f_amp[i], 5, 'f', 1 ); values += QString( " %1" ).arg( eqz_preset_10b[i_preset].f_amp[i], 5, 'f', 1 );
/* Convert it to char * */ /* Convert it to char * */
return strdup( values.toAscii().constData() ); return strdup( values.toAscii().constData() );
...@@ -1070,7 +1070,7 @@ void Equalizer::setCorePreset( int i_preset ) ...@@ -1070,7 +1070,7 @@ void Equalizer::setCorePreset( int i_preset )
return; return;
/* Update pre-amplification in the UI */ /* Update pre-amplification in the UI */
float f_preamp = eqz_preset_10b[i_preset]->f_preamp; float f_preamp = eqz_preset_10b[i_preset].f_preamp;
ui.preampSlider->setValue( (int)( ( f_preamp + 20 ) * 10 ) ); ui.preampSlider->setValue( (int)( ( f_preamp + 20 ) * 10 ) );
ui.preampLabel->setText( qtr( "Preamp\n" ) ui.preampLabel->setText( qtr( "Preamp\n" )
+ QString::number( f_preamp, 'f', 1 ) + qtr( "dB" ) ); + QString::number( f_preamp, 'f', 1 ) + qtr( "dB" ) );
...@@ -1098,13 +1098,13 @@ void Equalizer::setCorePreset( int i_preset ) ...@@ -1098,13 +1098,13 @@ void Equalizer::setCorePreset( int i_preset )
var_SetString( p_aout, "equalizer-bands", psz_values ); var_SetString( p_aout, "equalizer-bands", psz_values );
var_SetFloat( p_aout, "equalizer-preamp", var_SetFloat( p_aout, "equalizer-preamp",
eqz_preset_10b[i_preset]->f_preamp ); eqz_preset_10b[i_preset].f_preamp );
vlc_object_release( p_aout ); vlc_object_release( p_aout );
} }
config_PutPsz( p_intf, "equalizer-bands", psz_values ); config_PutPsz( p_intf, "equalizer-bands", psz_values );
config_PutPsz( p_intf, "equalizer-preset", preset_list[i_preset] ); config_PutPsz( p_intf, "equalizer-preset", preset_list[i_preset] );
config_PutFloat( p_intf, "equalizer-preamp", config_PutFloat( p_intf, "equalizer-preamp",
eqz_preset_10b[i_preset]->f_preamp ); eqz_preset_10b[i_preset].f_preamp );
free( psz_values ); free( psz_values );
} }
......
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