* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
+#define __STDC_FORMAT_MACROS 1
+
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_intf_strings.h>
#include <vlc_vout.h>
#include <vlc_osd.h>
+#include <vlc_modules.h>
#include <vlc_charset.h> /* us_strtod */
else if( lineedit )
{
char str[30];
- snprintf( str, sizeof(str), "%06X", val.i_int );
+ snprintf( str, sizeof(str), "%06"PRIX64, val.i_int );
lineedit->setText( str );
}
else if( combobox ) combobox->setCurrentIndex(
- combobox->findData( val.i_int ) );
+ combobox->findData( qlonglong(val.i_int) ) );
else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
}
else if( i_type == VLC_VAR_FLOAT )
const char *psz_var = text.p_list->p_values[i].psz_string;
var_Change( p_obj, psz_var, VLC_VAR_GETTEXT, &name, NULL );
const char *psz_label = name.psz_string;
- msg_Dbg( p_intf, "v4l2 control \"%x\": %s (%s)",
+ msg_Dbg( p_intf, "v4l2 control \"%"PRIx64"\": %s (%s)",
val.p_list->p_values[i].i_int, psz_var, name.psz_string );
int i_type = var_Type( p_obj, psz_var );
{
combobox->addItem(
text2.p_list->p_values[j].psz_string,
- val2.p_list->p_values[j].i_int );
+ qlonglong( val2.p_list->p_values[j].i_int) );
if( i_val == val2.p_list->p_values[j].i_int )
combobox->setCurrentIndex( j );
}
Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) :
QWidget( _parent ) , p_intf( _p_intf )
{
- QFont smallFont = QApplication::font( static_cast<QWidget*>( 0 ) );
+ QFont smallFont = QApplication::font();
smallFont.setPointSize( smallFont.pointSize() - 3 );
ui.setupUi( this );
updateUIFromCore();
}
-Equalizer::~Equalizer()
-{
-}
-
-void Equalizer::clean()
-{
- enable();
-}
/* Write down initial values */
void Equalizer::updateUIFromCore()
{
if( psz_bands && strlen( psz_bands ) > 1 )
{
- char *psz_bands_orig = psz_bands;
+ char *psz_bands_orig = psz_bands;
for( int i = 0; i < BANDS; i++ )
{
const float f = us_strtod(psz_bands, &psz_bands );
* Audio filters
**********************************************************************/
+/**********************************************************************
+ * Dynamic range compressor
+ **********************************************************************/
+
+typedef struct
+{
+ const char *psz_name;
+ const char *psz_descs;
+ const char *psz_units;
+ const float f_min; // min
+ const float f_max; // max
+ const float f_value; // value
+ const float f_resolution; // resolution
+} comp_controls_t;
+
+static const comp_controls_t comp_controls[] =
+{
+ { "compressor-rms-peak", _("RMS/peak"), "", 0.0f, 1.0f, 0.00f, 0.001f },
+ { "compressor-attack", _("Attack"), _(" ms"), 1.5f, 400.0f, 25.00f, 0.100f },
+ { "compressor-release", _("Release"), _(" ms"), 2.0f, 800.0f, 100.00f, 0.100f },
+ { "compressor-threshold", _("Threshold"), _(" dB"), -30.0f, 0.0f, -11.00f, 0.010f },
+ { "compressor-ratio", _("Ratio"), ":1", 1.0f, 20.0f, 8.00f, 0.010f },
+ { "compressor-knee", _("Knee\nradius"), _(" dB"), 1.0f, 10.0f, 2.50f, 0.010f },
+ { "compressor-makeup-gain", _("Makeup\ngain"), _(" dB"), 0.0f, 24.0f, 7.00f, 0.010f },
+};
+
+Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent )
+ : QWidget( _parent ) , p_intf( _p_intf )
+{
+ QFont smallFont = QApplication::font();
+ smallFont.setPointSize( smallFont.pointSize() - 3 );
+
+ QGridLayout *layout = new QGridLayout( this );
+ layout->setMargin( 0 );
+
+ enableCheck = new QCheckBox( qtr( "Enable dynamic range compressor" ) );
+ layout->addWidget( enableCheck, 0, 0, 1, NUM_CP_CTRL );
+
+ for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
+ {
+ const int i_min = (int)( comp_controls[i].f_min
+ / comp_controls[i].f_resolution );
+ const int i_max = (int)( comp_controls[i].f_max
+ / comp_controls[i].f_resolution );
+ const int i_val = (int)( comp_controls[i].f_value
+ / comp_controls[i].f_resolution );
+
+ compCtrl[i] = new QSlider( Qt::Vertical );
+ compCtrl[i]->setMinimum( i_min );
+ compCtrl[i]->setMaximum( i_max );
+ compCtrl[i]->setValue( i_val );
+
+ oldControlVars[i] = comp_controls[i].f_value;
+
+ CONNECT( compCtrl[i], valueChanged( int ), this, setInitValues() );
+
+ ctrl_texts[i] = new QLabel( qtr( comp_controls[i].psz_descs ) + "\n" );
+ ctrl_texts[i]->setFont( smallFont );
+ ctrl_texts[i]->setAlignment( Qt::AlignHCenter );
+
+ ctrl_readout[i] = new QLabel;
+ ctrl_readout[i]->setFont( smallFont );
+ ctrl_readout[i]->setAlignment( Qt::AlignHCenter );
+
+ layout->addWidget( compCtrl[i], 1, i, Qt::AlignHCenter );
+ layout->addWidget( ctrl_readout[i], 2, i, Qt::AlignHCenter );
+ layout->addWidget( ctrl_texts[i], 3, i, Qt::AlignHCenter );
+ }
+
+ BUTTONACT( enableCheck, enable() );
+
+ /* Write down initial values */
+ aout_instance_t *p_aout = THEMIM->getAout();
+ char *psz_af;
+
+ if( p_aout )
+ {
+ psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
+ for( int i = 0; i < NUM_CP_CTRL; i++ )
+ {
+ controlVars[i] = var_GetFloat( p_aout,
+ comp_controls[i].psz_name );
+ }
+ vlc_object_release( p_aout );
+ }
+ else
+ {
+ psz_af = config_GetPsz( p_intf, "audio-filter" );
+ for( int i = 0; i < NUM_CP_CTRL; i++ )
+ {
+ controlVars[i] = config_GetFloat( p_intf,
+ comp_controls[i].psz_name );
+ }
+ }
+ if( psz_af && strstr( psz_af, "compressor" ) != NULL )
+ {
+ enableCheck->setChecked( true );
+ }
+ free( psz_af );
+ enable( enableCheck->isChecked() );
+ updateSliders( controlVars );
+ setValues( controlVars );
+}
+
+void Compressor::enable()
+{
+ bool en = enableCheck->isChecked();
+ aout_EnableFilter( THEPL, "compressor", en );
+ enable( en );
+}
+
+void Compressor::enable( bool en )
+{
+ for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
+ {
+ compCtrl[i]->setEnabled( en );
+ ctrl_texts[i]->setEnabled( en );
+ ctrl_readout[i]->setEnabled( en );
+ }
+}
+
+void Compressor::updateSliders( float * controlVars )
+{
+ for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
+ {
+ if( oldControlVars[i] != controlVars[i] )
+ {
+ compCtrl[i]->setValue(
+ (int)( controlVars[i] / comp_controls[i].f_resolution ) );
+ }
+ }
+}
+
+void Compressor::setInitValues()
+{
+ setValues( controlVars );
+}
+
+void Compressor::setValues( float * controlVars )
+{
+ aout_instance_t *p_aout = THEMIM->getAout();
+
+ for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
+ {
+ float f = (float)( compCtrl[i]->value() ) * ( comp_controls[i].f_resolution );
+ ctrl_readout[i]->setText( QString::number( f, 'f', 1 )
+ + qtr( comp_controls[i].psz_units ) );
+ if( oldControlVars[i] != f )
+ {
+ if( p_aout )
+ {
+ var_SetFloat( p_aout, comp_controls[i].psz_name, f );
+ }
+ config_PutFloat( p_intf, comp_controls[i].psz_name, f );
+ oldControlVars[i] = f;
+ }
+ }
+ if( p_aout )
+ {
+ vlc_object_release( p_aout );
+ }
+}
+
/**********************************************************************
* Spatializer
**********************************************************************/
-static const char *psz_control_names[] =
+typedef struct
{
- "spatializer-roomsize", "spatializer-width",
- "spatializer-wet", "spatializer-dry", "spatializer-damp"
+ const char *psz_name;
+ const char *psz_desc;
+} spat_controls_t;
+
+static const spat_controls_t spat_controls[] =
+{
+ { "spatializer-roomsize", _("Size") },
+ { "spatializer-width", _("Width") },
+ { "spatializer-wet", _("Wet") },
+ { "spatializer-dry", _("Dry") },
+ { "spatializer-damp", _("Damp") },
};
-Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent ) :
- QWidget( _parent ) , p_intf( _p_intf )
+Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent )
+ : QWidget( _parent ) , p_intf( _p_intf )
{
- QFont smallFont = QApplication::font( static_cast<QWidget*>( 0 ) );
+ QFont smallFont = QApplication::font();
smallFont.setPointSize( smallFont.pointSize() - 3 );
QGridLayout *layout = new QGridLayout( this );
spatCtrl[i]->setValue( 0 );
spatCtrl[i]->setMinimum( -10 );
}
+
oldControlVars[i] = spatCtrl[i]->value();
+
CONNECT( spatCtrl[i], valueChanged( int ), this, setInitValues() );
- ctrl_texts[i] = new QLabel( qfu( psz_control_names[i] ) + "\n" );
+
+ ctrl_texts[i] = new QLabel( qtr( spat_controls[i].psz_desc ) + "\n" );
ctrl_texts[i]->setFont( smallFont );
- ctrl_readout[i] = new QLabel( "" );
+
+ ctrl_readout[i] = new QLabel;
ctrl_readout[i]->setFont( smallFont );
- layout->addWidget( spatCtrl[i], 1, i );
- layout->addWidget( ctrl_readout[i], 2, i );
- layout->addWidget( ctrl_texts[i], 3, i );
+
+ layout->addWidget( spatCtrl[i], 1, i, Qt::AlignHCenter );
+ layout->addWidget( ctrl_readout[i], 2, i, Qt::AlignHCenter );
+ layout->addWidget( ctrl_texts[i], 3, i, Qt::AlignHCenter );
}
BUTTONACT( enableCheck, enable() );
psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
for( int i = 0; i < NUM_SP_CTRL ; i++ )
{
- controlVars[i] = var_GetFloat( p_aout, psz_control_names[i] );
+ controlVars[i] = var_GetFloat( p_aout, spat_controls[i].psz_name );
}
vlc_object_release( p_aout );
}
psz_af = config_GetPsz( p_intf, "audio-filter" );
for( int i = 0; i < NUM_SP_CTRL ; i++ )
{
- controlVars[i] = config_GetFloat( p_intf, psz_control_names[i] );
+ controlVars[i] = config_GetFloat( p_intf, spat_controls[i].psz_name );
}
}
if( psz_af && strstr( psz_af, "spatializer" ) != NULL )
setValues( controlVars );
}
-Spatializer::~Spatializer()
-{
-}
-
void Spatializer::enable()
{
bool en = enableCheck->isChecked();
- aout_EnableFilter( VLC_OBJECT( p_intf ), "spatializer",
- en ? true : false );
+ aout_EnableFilter( THEPL, "spatializer", en );
enable( en );
}
{
if( oldControlVars[i] != spatCtrl[i]->value() )
{
- var_SetFloat( p_aout, psz_control_names[i],
+ var_SetFloat( p_aout, spat_controls[i].psz_name,
( float )spatCtrl[i]->value() );
- config_PutFloat( p_intf, psz_control_names[i],
+ config_PutFloat( p_intf, spat_controls[i].psz_name,
( float ) spatCtrl[i]->value() );
oldControlVars[i] = ( float ) spatCtrl[i]->value();
}