Commit a300dcc8 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: Equalizer: rework (fix #7923)

parent a52e23c7
...@@ -917,13 +917,17 @@ void ExtV4l2::ValueChange( int value ) ...@@ -917,13 +917,17 @@ void ExtV4l2::ValueChange( int value )
* Sliders * Sliders
**********************************************************************/ **********************************************************************/
FilterSliderData::FilterSliderData( QObject *parent, QSlider *_slider ) :
QObject( parent ), slider( _slider )
{}
FilterSliderData::FilterSliderData( QObject *parent, FilterSliderData::FilterSliderData( QObject *parent,
intf_thread_t *_p_intf, intf_thread_t *_p_intf,
QSlider *_slider, QSlider *_slider,
QLabel *_label, QLabel *_nameLabel, QLabel *_label, QLabel *_nameLabel,
const slider_data_t *_p_data ): const slider_data_t *_p_data ):
QObject( parent ), slider( _slider ), p_intf( _p_intf ), QObject( parent ), slider( _slider ), valueLabel( _label ),
valueLabel( _label ), nameLabel( _nameLabel ), p_data( _p_data ) nameLabel( _nameLabel ), p_data( _p_data ), p_intf( _p_intf )
{ {
slider->setMinimum( p_data->f_min / p_data->f_resolution ); slider->setMinimum( p_data->f_min / p_data->f_resolution );
slider->setMaximum( p_data->f_max / p_data->f_resolution ); slider->setMaximum( p_data->f_max / p_data->f_resolution );
...@@ -946,7 +950,7 @@ void FilterSliderData::updateText( int i ) ...@@ -946,7 +950,7 @@ void FilterSliderData::updateText( int i )
{ {
float f = ((float) i) * p_data->f_resolution * p_data->f_visual_multiplier; float f = ((float) i) * p_data->f_resolution * p_data->f_visual_multiplier;
valueLabel->setText( QString( p_data->units ) valueLabel->setText( QString( p_data->units )
.prepend( "%1" ) .prepend( "%1 " )
.arg( QString::number( f, 'f', 1 ) ) ); .arg( QString::number( f, 'f', 1 ) ) );
} }
...@@ -976,7 +980,7 @@ float FilterSliderData::initialValue() ...@@ -976,7 +980,7 @@ float FilterSliderData::initialValue()
return f; return f;
} }
void FilterSliderData::onValueChanged( int i ) void FilterSliderData::onValueChanged( int i ) const
{ {
float f = ((float) i) * p_data->f_resolution; float f = ((float) i) * p_data->f_resolution;
vlc_object_t *p_aout = (vlc_object_t *) THEMIM->getAout(); vlc_object_t *p_aout = (vlc_object_t *) THEMIM->getAout();
...@@ -988,7 +992,7 @@ void FilterSliderData::onValueChanged( int i ) ...@@ -988,7 +992,7 @@ void FilterSliderData::onValueChanged( int i )
writeToConfig(); writeToConfig();
} }
void FilterSliderData::writeToConfig() void FilterSliderData::writeToConfig() const
{ {
float f = ((float) slider->value()) * p_data->f_resolution; float f = ((float) slider->value()) * p_data->f_resolution;
config_PutFloat( p_intf, qtu(p_data->name), f ); config_PutFloat( p_intf, qtu(p_data->name), f );
...@@ -1044,7 +1048,7 @@ void AudioFilterControlWidget::build() ...@@ -1044,7 +1048,7 @@ void AudioFilterControlWidget::build()
slidersBox->setChecked( true ); slidersBox->setChecked( true );
else else
slidersBox->setChecked( false ); slidersBox->setChecked( false );
CONNECT( slidersBox, toggled(bool), this, enable() ); CONNECT( slidersBox, toggled(bool), this, enable(bool) );
free( psz_af ); free( psz_af );
} }
...@@ -1054,317 +1058,266 @@ AudioFilterControlWidget::~AudioFilterControlWidget() ...@@ -1054,317 +1058,266 @@ AudioFilterControlWidget::~AudioFilterControlWidget()
} }
void AudioFilterControlWidget::enable() void AudioFilterControlWidget::enable( bool b_enable ) const
{ {
playlist_EnableAudioFilter( THEPL, qtu(name), slidersBox->isChecked() ); playlist_EnableAudioFilter( THEPL, qtu(name), b_enable );
} }
/********************************************************************** /**********************************************************************
* Equalizer * Equalizer
**********************************************************************/ **********************************************************************/
static const QString vlc_band_frequencies[] = EqualizerSliderData::EqualizerSliderData( QObject *parent, intf_thread_t *_p_intf,
{ QSlider *slider, QLabel *_label,
" 60 Hz ", " 170 Hz ", " 310 Hz ", " 600 Hz ", " 1 kHz ", QLabel *_nameLabel, const slider_data_t *_p_data,
" 3 kHz ", " 6 kHz ", " 12 kHz ", " 14 kHz ", " 16 kHz " int _index )
}; : FilterSliderData( parent, slider ), index( _index )
static const QString iso_band_frequencies[] =
{
" 31 Hz ", " 63 Hz ", " 125 Hz ", " 250 Hz ", " 500 Hz ",
" 1 kHz ", " 2 kHz ", " 4 kHz ", " 8 kHz ", " 16 kHz "
};
Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) :
QWidget( _parent ) , p_intf( _p_intf )
{ {
QFont smallFont = QApplication::font(); p_intf = _p_intf;
smallFont.setPointSize( smallFont.pointSize() - 3 ); valueLabel = _label;
nameLabel = _nameLabel;
ui.setupUi( this ); p_data = _p_data;
ui.preampLabel->setFont( smallFont );
/* Setup of presetsComboBox */
presetsComboBox = ui.presetsCombo;
CONNECT( presetsComboBox, activated( int ), this, setCorePreset( int ) );
b_vlcBands = var_InheritBool( p_intf, "equalizer-vlcfreqs" );
/* Add the sliders for the Bands */
QGridLayout *grid = new QGridLayout( ui.slidersPlaceholder );
grid->setMargin( 0 );
for( int i = 0 ; i < BANDS ; i++ )
{
bands[i] = new QSlider( Qt::Vertical );
bands[i]->setMaximum( 400 );
bands[i]->setValue( 200 );
bands[i]->setMinimumWidth(36);
CONNECT( bands[i], valueChanged( int ), this, setCoreBands() );
QString val = QString("%1").arg( 0.0, 5, 'f', 1 ); slider->setMinimum( p_data->f_min / p_data->f_resolution );
band_texts[i] = new QLabel( (b_vlcBands ? vlc_band_frequencies[i] slider->setMaximum( p_data->f_max / p_data->f_resolution );
: iso_band_frequencies[i]) + "\n" + val + "dB" ); nameLabel->setText( p_data->descs );
band_texts[i]->setFont( smallFont ); CONNECT( slider, valueChanged( int ), this, updateText( int ) );
setValue( initialValue() );
grid->addWidget( bands[i], 0, i ); updateText( slider->value() );
grid->addWidget( band_texts[i], 1, i ); CONNECT( slider, valueChanged( int ), this, onValueChanged( int ) );
}
/* Add the listed presets */
for( int i = 0 ; i < NB_PRESETS ; i ++ )
{
presetsComboBox->addItem( qtr( preset_list_text[i] ),
QVariant( preset_list[i] ) );
}
/* Connects */
BUTTONACT( ui.enableCheck, enable() );
BUTTONACT( ui.eq2PassCheck, set2Pass() );
CONNECT( ui.preampSlider, valueChanged( int ), this, setPreamp() );
/* Do the update from the value of the core */
updateUIFromCore();
} }
/* Write down initial values */ QStringList EqualizerSliderData::getBandsFromAout() const
void Equalizer::updateUIFromCore()
{ {
char *psz_af, *psz_pres, *psz_bands; vlc_object_t *p_aout = (vlc_object_t *) THEMIM->getAout();
float f_preamp; QStringList bands;
int i_preset;
vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
if( p_aout ) if( p_aout )
{ {
psz_af = var_GetNonEmptyString( p_aout, "audio-filter" ); if ( var_Type( p_aout, qtu(p_data->name) ) == VLC_VAR_STRING )
vlc_object_release( p_aout );
}
else
{
psz_af = config_GetPsz( p_intf, "audio-filter" );
}
psz_pres = var_InheritString( p_aout, "equalizer-preset" );
if( var_InheritBool( p_aout, "equalizer-2pass" ) )
ui.eq2PassCheck->setChecked( true );
f_preamp = var_InheritFloat( p_aout, "equalizer-preamp" );
psz_bands = var_InheritString( p_aout, "equalizer-bands" );
i_preset = presetsComboBox->findData( QVariant( psz_pres ) );
if( psz_af && strstr( psz_af, "equalizer" ) != NULL )
ui.enableCheck->setChecked( true );
enable( ui.enableCheck->isChecked() );
presetsComboBox->setCurrentIndex( i_preset );
ui.preampSlider->setValue( (int)( ( f_preamp + 20 ) * 10 ) );
if( psz_bands && strlen( psz_bands ) > 1 )
{ {
char *psz_bands_orig = psz_bands; char *psz_bands = var_GetString( p_aout, qtu(p_data->name) );
for( int i = 0; i < BANDS; i++ ) if ( psz_bands )
{ {
const float f = us_strtod(psz_bands, &psz_bands ); bands = QString( psz_bands ).split( " ", QString::SkipEmptyParts );
bands[i]->setValue( (int)( ( f + 20 ) * 10 ) ); free( psz_bands );
if( psz_bands == NULL || *psz_bands == '\0' ) break;
psz_bands++;
if( *psz_bands == '\0' ) break;
} }
free( psz_bands_orig );
} }
else free( psz_bands ); vlc_object_release( p_aout );
}
free( psz_af );
free( psz_pres );
}
void Equalizer::changeFreqLabels( bool b_useVlcBands ) if ( bands.count() ) return bands;
{ /* Or try config then */
b_vlcBands = b_useVlcBands;
const QString *band_frequencies = b_vlcBands if ( ! config_FindConfig( VLC_OBJECT(p_intf), qtu(p_data->name) ) )
? vlc_band_frequencies return bands;
: iso_band_frequencies;
for( int i = 0; i < BANDS; i++ ) char *psz_bands = config_GetPsz( p_intf, qtu(p_data->name) );
if ( psz_bands )
{ {
const float f_val = (float)( bands[i]->value() ) / 10 - 20; bands = QString( psz_bands ).split( " ", QString::SkipEmptyParts );
QString val = QString("%1").arg( f_val, 5, 'f', 1 ); free( psz_bands );
band_texts[i]->setText( band_frequencies[i] + "\n" + val + "dB" );
} }
return bands;
} }
/* Function called when enableButton is toggled */ float EqualizerSliderData::initialValue()
void Equalizer::enable()
{ {
bool en = ui.enableCheck->isChecked(); float f = p_data->f_value;
playlist_EnableAudioFilter( THEPL, "equalizer", en ); QStringList bands = getBandsFromAout();
//playlist_EnableAudioFilter( THEPL, "upmixer", en );
//playlist_EnableAudioFilter( THEPL, "vsurround", en );
enable( en );
if( presetsComboBox->currentIndex() < 0 ) if ( bands.count() > index )
presetsComboBox->setCurrentIndex( 0 ); f = QLocale( QLocale::C ).toFloat( bands[ index ] );
return f;
} }
void Equalizer::enable( bool en ) void EqualizerSliderData::onValueChanged( int i ) const
{ {
ui.eq2PassCheck->setEnabled( en ); QStringList bands = getBandsFromAout();
presetsComboBox->setEnabled( en ); if ( bands.count() > index )
ui.presetLabel->setEnabled( en ); {
ui.preampLabel->setEnabled( en ); float f = ((float) i) * p_data->f_resolution;
ui.preampSlider->setEnabled( en ); bands[ index ] = QLocale( QLocale::C ).toString( f );
for( int i = 0 ; i< BANDS; i++ ) vlc_object_t *p_aout = (vlc_object_t *) THEMIM->getAout();
if ( p_aout )
{ {
bands[i]->setEnabled( en ); band_texts[i]->setEnabled( en ); var_SetString( p_aout, qtu(p_data->name), qtu(bands.join( " " )) );
vlc_object_release( p_aout );
}
writeToConfig();
} }
} }
/* Function called when the set2Pass button is activated */ void EqualizerSliderData::writeToConfig() const
void Equalizer::set2Pass()
{ {
vlc_object_t *p_aout= (vlc_object_t *)THEMIM->getAout(); QStringList bands = getBandsFromAout();
bool b_2p = ui.eq2PassCheck->isChecked(); if ( bands.count() > index )
if( p_aout )
{ {
var_SetBool( p_aout, "equalizer-2pass", b_2p ); float f = (float) slider->value() * p_data->f_resolution;
vlc_object_release( p_aout ); bands[ index ] = QLocale( QLocale::C ).toString( f );
config_PutPsz( p_intf, qtu(p_data->name), qtu(bands.join( " " )) );
} }
config_PutInt( p_intf, "equalizer-2pass", b_2p );
} }
/* Function called when the preamp slider is moved */ Equalizer::Equalizer( intf_thread_t *p_intf, QWidget *parent )
void Equalizer::setPreamp() : AudioFilterControlWidget( p_intf, parent, "equalizer" )
{ {
const float f = ( float )( ui.preampSlider->value() ) /10 - 20; i_smallfont = -3;
vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); bool b_vlcBands = var_InheritBool( p_intf, "equalizer-vlcfreqs" );
const FilterSliderData::slider_data_t vlc_bands[10] =
{
{ "equalizer-bands", qtr("60 Hz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("170 Hz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("310 Hz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("600 Hz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("1 KHz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("3 KHz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("6 KHz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("12 KHz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("14 KHz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("16 KHz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
};
const FilterSliderData::slider_data_t iso_bands[10] =
{
{ "equalizer-bands", qtr("31 Hz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("63 Hz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("125 Hz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("250 Hz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("500 Hz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("1 KHz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("2 KHz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("4 KHz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("8 KHz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
{ "equalizer-bands", qtr("16 KHz"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 },
};
const FilterSliderData::slider_data_t preamp_vals =
{ "equalizer-preamp", qtr("Preamp"), qtr("dB"), -20.0f, 20.0f, 0.0f, 0.1f, 1.0 };
ui.preampLabel->setText( qtr( "Preamp\n" ) + QString::number( f, 'f', 1 ) for( int i=0; i<10 ;i++ ) controls.append( (b_vlcBands) ? vlc_bands[i] : iso_bands[i] );
+ qtr( "dB" ) ); preamp_values = preamp_vals;
if( p_aout ) build();
{
//delCallbacks( p_aout );
var_SetFloat( p_aout, "equalizer-preamp", f );
//addCallbacks( p_aout );
vlc_object_release( p_aout );
}
config_PutFloat( p_intf, "equalizer-preamp", f );
} }
void Equalizer::setCoreBands() void Equalizer::build()
{ {
/**\todo smoothing */ QFont smallFont = QApplication::font();
smallFont.setPointSize( smallFont.pointSize() + i_smallfont );
const QString *band_frequencies = b_vlcBands Ui::EqualizerWidget ui;
? vlc_band_frequencies ui.setupUi( this );
: iso_band_frequencies;
QString values; QGridLayout *ctrlLayout = new QGridLayout( ui.slidersPlaceholder );
for( int i = 0; i < BANDS; i++ )
/* set up preamp control */
ui.preampLabel->setFont( smallFont );
ui.preampValue->setFont( smallFont );
preamp = new FilterSliderData( this, p_intf,
ui.preampSlider, ui.preampValue, ui.preampLabel, & preamp_values );
/* fix sliders spacing accurately */
int i_width = qMax( QFontMetrics( smallFont ).width( "500 Hz" ),
QFontMetrics( smallFont ).width( "-20.0 dB" ) );
int i = 0;
foreach( const FilterSliderData::slider_data_t &data, controls )
{ {
const float f_val = (float)( bands[i]->value() ) / 10 - 20; QSlider *slider = new QSlider( Qt::Vertical );
QString val = QString("%1").arg( f_val, 5, 'f', 1 ); slider->setMinimumWidth( i_width );
QLabel *valueLabel = new QLabel();
valueLabel->setFont( smallFont );
valueLabel->setAlignment( Qt::AlignHCenter );
QLabel *nameLabel = new QLabel();
nameLabel->setFont( smallFont );
nameLabel->setAlignment( Qt::AlignHCenter );
EqualizerSliderData *filter =
new EqualizerSliderData( this, p_intf,
slider, valueLabel, nameLabel, & data, i );
ctrlLayout->addWidget( slider, 0, i, Qt::AlignHCenter );
ctrlLayout->addWidget( valueLabel, 2, i, Qt::AlignHCenter );
ctrlLayout->addWidget( nameLabel, 1, i, Qt::AlignHCenter );
eqSliders << filter; /* keep track for applying presets */
i++;
}
band_texts[i]->setText( band_frequencies[i] + "\n" + val + "dB" ); /* Add the listed presets */
values += " " + val; ui.presetsCombo->addItem( "", QVariant() ); /* 1st entry = custom/modified */
for( i = 0 ; i < NB_PRESETS ; i ++ )
{
ui.presetsCombo->addItem( qtr( preset_list_text[i] ),
QVariant( preset_list[i] ) );
} }
CONNECT( ui.presetsCombo, activated(int), this, setCorePreset(int) );
/* Set enable checkbox */
vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
char *psz_af;
if( p_aout ) if( p_aout )
{ {
//delCallbacks( p_aout ); psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
var_SetString( p_aout, "equalizer-bands", qtu( values ) );
//addCallbacks( p_aout );
vlc_object_release( p_aout ); vlc_object_release( p_aout );
} }
} else
psz_af = config_GetPsz( p_intf, "audio-filter" );
char * Equalizer::createValuesFromPreset( int i_preset ) /* To enable or disable subwidgets */
{ /* If that list grows, better iterate over layout's childs */
QString values; CONNECT( ui.enableCheck, toggled(bool), ui.presetsCombo, setEnabled(bool) );
CONNECT( ui.enableCheck, toggled(bool), ui.presetLabel, setEnabled(bool) );
CONNECT( ui.enableCheck, toggled(bool), ui.eq2PassCheck, setEnabled(bool) );
CONNECT( ui.enableCheck, toggled(bool), ui.slidersPlaceholder, setEnabled(bool) );
CONNECT( ui.enableCheck, toggled(bool), ui.preampSlider, setEnabled(bool) );
CONNECT( ui.enableCheck, toggled(bool), ui.preampValue, setEnabled(bool) );
CONNECT( ui.enableCheck, toggled(bool), ui.preampLabel, setEnabled(bool) );
/* Create the QString in Qt */ if( psz_af && strstr( psz_af, qtu(name) ) != NULL )
for( int i = 0 ; i< BANDS ;i++ ) ui.enableCheck->setChecked( true );
values += QString( " %1" ).arg( eqz_preset_10b[i_preset].f_amp[i], 5, 'f', 1 ); else
ui.enableCheck->setChecked( false );
/* workaround for non emitted toggle() signal */
ui.enableCheck->toggle(); ui.enableCheck->toggle();
/* Convert it to char * */ free( psz_af );
return strdup( values.toAscii().constData() ); CONNECT( ui.enableCheck, toggled(bool), this, enable(bool) );
/* Connect and set 2 Pass checkbox */
ui.eq2PassCheck->setChecked( var_InheritBool( p_aout, "equalizer-2pass" ) );
CONNECT( ui.eq2PassCheck, toggled(bool), this, enable2Pass(bool) );
} }
void Equalizer::setCorePreset( int i_preset ) void Equalizer::setCorePreset( int i_preset )
{ {
if( i_preset < 0 ) if( i_preset < 1 )
return; return;
/* Update pre-amplification in the UI */ i_preset--;/* 1st in index was an empty entry */
float f_preamp = eqz_preset_10b[i_preset].f_preamp;
ui.preampSlider->setValue( (int)( ( f_preamp + 20 ) * 10 ) );
ui.preampLabel->setText( qtr( "Preamp\n" )
+ QString::number( f_preamp, 'f', 1 ) + qtr( "dB" ) );
char *psz_values = createValuesFromPreset( i_preset );
if( !psz_values ) return ;
const QString *band_frequencies = b_vlcBands
? vlc_band_frequencies
: iso_band_frequencies;
char *p = psz_values; preamp->setValue( eqz_preset_10b[i_preset].f_preamp );
for( int i = 0; i < BANDS && *p; i++ ) for ( int i=0; i< qMin( eqz_preset_10b[i_preset].i_band,
{ eqSliders.count() ) ; i++ )
const float f = us_strtod( p, &p ); eqSliders[i]->setValue( eqz_preset_10b[i_preset].f_amp[i] );
bands[i]->setValue( (int)( ( f + 20 ) * 10 ) );
band_texts[i]->setText( band_frequencies[i] + "\n"
+ QString("%1").arg( f, 5, 'f', 1 ) + "dB" );
if( *p )
p++; /* skip separator */
}
/* Apply presets to audio output */
vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
if( p_aout ) if( p_aout )
{ {
var_SetString( p_aout , "equalizer-preset" , preset_list[i_preset] ); var_SetString( p_aout , "equalizer-preset" , preset_list[i_preset] );
var_SetString( p_aout, "equalizer-bands", psz_values );
var_SetFloat( p_aout, "equalizer-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-preset", preset_list[i_preset] ); config_PutPsz( p_intf, "equalizer-preset", preset_list[i_preset] );
config_PutFloat( p_intf, "equalizer-preamp",
eqz_preset_10b[i_preset].f_preamp );
free( psz_values );
}
static int PresetCallback( 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 );
char *psz_preset = newval.psz_string;
Equalizer *eq = ( Equalizer * )p_data;
int i_preset = eq->presetsComboBox->findData( QVariant( psz_preset ) );
eq->presetsComboBox->setCurrentIndex( i_preset );
return VLC_SUCCESS;
} }
void Equalizer::delCallbacks( vlc_object_t *p_aout ) /* Function called when the set2Pass button is activated */
void Equalizer::enable2Pass( bool b_enable ) const
{ {
//var_DelCallback( p_aout, "equalizer-bands", EqzCallback, this ); vlc_object_t *p_aout= (vlc_object_t *)THEMIM->getAout();
//var_DelCallback( p_aout, "equalizer-preamp", EqzCallback, this );
var_DelCallback( p_aout, "equalizer-preset", PresetCallback, this );
}
void Equalizer::addCallbacks( vlc_object_t *p_aout ) if( p_aout )
{ {
//var_AddCallback( p_aout, "equalizer-bands", EqzCallback, this ); var_SetBool( p_aout, "equalizer-2pass", b_enable );
//var_AddCallback( p_aout, "equalizer-preamp", EqzCallback, this ); vlc_object_release( p_aout );
var_AddCallback( p_aout, "equalizer-preset", PresetCallback, this ); }
config_PutInt( p_intf, "equalizer-2pass", b_enable );
} }
/********************************************************************** /**********************************************************************
...@@ -1382,12 +1335,12 @@ Compressor::Compressor( intf_thread_t *p_intf, QWidget *parent ) ...@@ -1382,12 +1335,12 @@ Compressor::Compressor( intf_thread_t *p_intf, QWidget *parent )
const FilterSliderData::slider_data_t a[7] = const FilterSliderData::slider_data_t a[7] =
{ {
{ "compressor-rms-peak", qtr("RMS/peak"), "", 0.0f, 1.0f, 0.00f, 0.001f, 1.0 }, { "compressor-rms-peak", qtr("RMS/peak"), "", 0.0f, 1.0f, 0.00f, 0.001f, 1.0 },
{ "compressor-attack", qtr("Attack"), qtr(" ms"), 1.5f, 400.0f, 25.00f, 0.100f, 1.0 }, { "compressor-attack", qtr("Attack"), qtr("ms"), 1.5f, 400.0f, 25.00f, 0.100f, 1.0 },
{ "compressor-release", qtr("Release"), qtr(" ms"), 2.0f, 800.0f, 100.00f, 0.100f, 1.0 }, { "compressor-release", qtr("Release"), qtr("ms"), 2.0f, 800.0f, 100.00f, 0.100f, 1.0 },
{ "compressor-threshold", qtr("Threshold"), qtr(" dB"), -30.0f, 0.0f, -11.00f, 0.010f, 1.0 }, { "compressor-threshold", qtr("Threshold"), qtr("dB"), -30.0f, 0.0f, -11.00f, 0.010f, 1.0 },
{ "compressor-ratio", qtr("Ratio"), ":1", 1.0f, 20.0f, 8.00f, 0.010f, 1.0 }, { "compressor-ratio", qtr("Ratio"), ":1", 1.0f, 20.0f, 8.00f, 0.010f, 1.0 },
{ "compressor-knee", qtr("Knee\nradius"), qtr(" dB"), 1.0f, 10.0f, 2.50f, 0.010f, 1.0 }, { "compressor-knee", qtr("Knee\nradius"), qtr("dB"), 1.0f, 10.0f, 2.50f, 0.010f, 1.0 },
{ "compressor-makeup-gain", qtr("Makeup\ngain"), qtr(" dB"), 0.0f, 24.0f, 7.00f, 0.010f, 1.0 }, { "compressor-makeup-gain", qtr("Makeup\ngain"), qtr("dB"), 0.0f, 24.0f, 7.00f, 0.010f, 1.0 },
}; };
for( int i=0; i<7 ;i++ ) controls.append( a[i] ); for( int i=0; i<7 ;i++ ) controls.append( a[i] );
build(); build();
......
...@@ -104,19 +104,18 @@ public: ...@@ -104,19 +104,18 @@ public:
void setValue( float f ); void setValue( float f );
protected: protected:
float initialValue(); FilterSliderData( QObject *parent, QSlider *slider );
virtual float initialValue();
public slots:
void onValueChanged( int i );
void updateText( int i );
void writeToConfig();
private:
intf_thread_t *p_intf;
QSlider *slider; QSlider *slider;
QLabel *valueLabel; QLabel *valueLabel;
QLabel *nameLabel; QLabel *nameLabel;
const slider_data_t *p_data; const slider_data_t *p_data;
intf_thread_t *p_intf;
public slots:
virtual void onValueChanged( int i ) const;
virtual void updateText( int i );
virtual void writeToConfig() const;
}; };
class AudioFilterControlWidget : public QWidget class AudioFilterControlWidget : public QWidget
...@@ -136,38 +135,47 @@ protected: ...@@ -136,38 +135,47 @@ protected:
int i_smallfont; int i_smallfont;
protected slots: protected slots:
void enable(); void enable( bool ) const;
}; };
class Equalizer: public QWidget class EqualizerSliderData : public FilterSliderData
{ {
Q_OBJECT Q_OBJECT
friend class ExtendedDialog;
public:
EqualizerSliderData( QObject *parent, intf_thread_t *p_intf,
QSlider *slider,
QLabel *valueLabel, QLabel *nameLabel,
const slider_data_t *p_data, int index );
protected:
virtual float initialValue();
int index;
QStringList getBandsFromAout() const;
public slots:
virtual void onValueChanged( int i ) const;
virtual void writeToConfig() const;
};
class Equalizer: public AudioFilterControlWidget
{
Q_OBJECT
public: public:
Equalizer( intf_thread_t *, QWidget * ); Equalizer( intf_thread_t *, QWidget * );
QComboBox *presetsComboBox;
char * createValuesFromPreset( int i_preset ); protected:
void updateUIFromCore(); virtual void build();
void changeFreqLabels( bool );
private:
Ui::EqualizerWidget ui;
QSlider *bands[BANDS];
QLabel *band_texts[BANDS];
bool b_vlcBands;
void delCallbacks( vlc_object_t * ); private:
void addCallbacks( vlc_object_t * ); QVector<FilterSliderData *> eqSliders;
FilterSliderData *preamp;
FilterSliderData::slider_data_t preamp_values;
intf_thread_t *p_intf;
void clean() { enable(); }
private slots: private slots:
void enable(bool); void setCorePreset( int );
void enable(); void enable2Pass( bool ) const;
void set2Pass();
void setPreamp();
void setCoreBands();
void setCorePreset(int);
}; };
class Compressor: public AudioFilterControlWidget class Compressor: public AudioFilterControlWidget
......
...@@ -136,5 +136,4 @@ void ExtendedDialog::changedItem( int i_status ) ...@@ -136,5 +136,4 @@ void ExtendedDialog::changedItem( int i_status )
if( i_status != END_S ) return; if( i_status != END_S ) return;
syncW->clean(); syncW->clean();
videoEffect->clean(); videoEffect->clean();
equal->clean();
} }
...@@ -19,7 +19,16 @@ ...@@ -19,7 +19,16 @@
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
...@@ -87,7 +96,7 @@ ...@@ -87,7 +96,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="3" column="0" colspan="2">
<widget class="QLabel" name="preampLabel"> <widget class="QLabel" name="preampLabel">
<property name="text"> <property name="text">
<string>Preamp</string> <string>Preamp</string>
...@@ -113,7 +122,7 @@ ...@@ -113,7 +122,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="2" rowspan="2"> <item row="1" column="2" rowspan="4">
<widget class="QWidget" name="slidersPlaceholder" native="true"> <widget class="QWidget" name="slidersPlaceholder" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
...@@ -123,6 +132,13 @@ ...@@ -123,6 +132,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="preampValue">
<property name="text">
<string>0.00 dB</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
......
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