AudioEffects.m 24 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*****************************************************************************
 * AudioEffects.m: MacOS X interface module
 *****************************************************************************
 * Copyright (C) 2004-2011 the VideoLAN team
 * $Id$
 *
 * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
 *          Jérôme Decoodt <djc@videolan.org>
 *          
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifdef HAVE_CONFIG_H
# import "config.h"
#endif

#import "intf.h"
31
#import "AudioEffects.h"
32
#import "../../audio_filter/equalizer_presets.h"
33
#import "CompatibilityFixes.h"
34
35

#import <vlc_common.h>
36
#import <vlc_aout_intf.h>
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

#import <math.h>

#pragma mark -
#pragma mark Initialization & Generic code

@implementation VLCAudioEffects
static VLCAudioEffects *_o_sharedInstance = nil;

+ (VLCAudioEffects *)sharedInstance
{
    return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
}

- (id)init
{
    if (_o_sharedInstance) {
        [self dealloc];
    } else {
56
        p_intf = VLCIntf;
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
        _o_sharedInstance = [super init];
    }
    
    return _o_sharedInstance;
}

- (void)awakeFromNib
{
    /* setup the user's language */
    /* Equalizer */
    [o_eq_enable_ckb setTitle:_NS("Enable")];
    [o_eq_twopass_ckb setTitle:_NS("2 Pass")];
    [o_eq_preamp_lbl setStringValue:_NS("Preamp")];
    [o_eq_presets_popup removeAllItems];
    for( int i = 0; i < 18 ; i++ )
        [o_eq_presets_popup insertItemWithTitle: _NS(preset_list_text[i]) atIndex: i];
    
    /* Compressor */
    [o_comp_enable_ckb setTitle:_NS("Enable dynamic range compressor")];
76
    [o_comp_reset_btn setTitle:_NS("Reset")];
77
78
79
80
81
82
83
84
85
86
    [o_comp_band1_lbl setStringValue:_NS("RMS/peak")];;
    [o_comp_band2_lbl setStringValue:_NS("Attack")];
    [o_comp_band3_lbl setStringValue:_NS("Release")];
    [o_comp_band4_lbl setStringValue:_NS("Threshold")];
    [o_comp_band5_lbl setStringValue:_NS("Ratio")];
    [o_comp_band6_lbl setStringValue:_NS("Knee radius")];
    [o_comp_band7_lbl setStringValue:_NS("Makeup gain")];
    
    /* Spatializer */
    [o_spat_enable_ckb setTitle:_NS("Enable Spatializer")];
87
    [o_spat_reset_btn setTitle:_NS("Reset")];
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
    [o_spat_band1_lbl setStringValue:_NS("Size")];
    [o_spat_band2_lbl setStringValue:_NS("Width")];
    [o_spat_band3_lbl setStringValue:_NS("Wet")];
    [o_spat_band4_lbl setStringValue:_NS("Dry")];
    [o_spat_band5_lbl setStringValue:_NS("Dump")];
    
    /* Filter */
    [o_filter_headPhone_ckb setTitle:_NS("Headphone virtualization")];
    [o_filter_normLevel_ckb setTitle:_NS("Volume normalization")];
    [o_filter_normLevel_lbl setStringValue:_NS("Maximum level")];
    
    /* generic */
    [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"equalizer"]] setLabel:_NS("Equalizer")];
    [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"compressor"]] setLabel:_NS("Compressor")];
    [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"spatializer"]] setLabel:_NS("Spatializer")];
    [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"filter"]] setLabel:_NS("Filter")];
    [o_window setTitle:_NS("Audio Effects")];
    [o_window setExcludedFromWindowsMenu:YES];
106
    if (OSX_LION)
107
        [o_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
108
109

    [self setupEqualizer];
110
111
112
    [self resetCompressor];
    [self resetSpatializer];
    [self resetAudioFilters];
113
114
115
116
117
118
119
120
121
122
}

- (IBAction)toggleWindow:(id)sender
{
    if( [o_window isVisible] )
        [o_window orderOut:sender];
    else
        [o_window makeKeyAndOrderFront:sender];
}

123
124
125
- (void)setAudioFilter: (char *)psz_name on:(BOOL)b_on
{
    char *psz_tmp;
126
    audio_output_t * p_aout = getAout();
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
    if( p_aout )
        psz_tmp = var_GetNonEmptyString( p_aout, "audio-filter" );
    else
        psz_tmp = config_GetPsz( p_intf, "audio-filter" );        
    
    if( b_on )
    {
        if(! psz_tmp)
            config_PutPsz( p_intf, "audio-filter", psz_name );
        else if( (NSInteger)strstr( psz_tmp, psz_name ) == NO )
        {
            psz_tmp = (char *)[[NSString stringWithFormat: @"%s:%s", psz_tmp, psz_name] UTF8String];
            config_PutPsz( p_intf, "audio-filter", psz_tmp );
        }
    } else {
        if( psz_tmp )
        {
            psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:[NSString stringWithFormat:@":%s",psz_name]]] UTF8String];
            psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:[NSString stringWithFormat:@"%s:",psz_name]]] UTF8String];
            psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:[NSString stringWithUTF8String:psz_name]]] UTF8String];
            config_PutPsz( p_intf, "audio-filter", psz_tmp );
        }
    }

    if( p_aout ) {
        aout_EnableFilter( pl_Get( p_intf ), psz_name, b_on );
        vlc_object_release( p_aout );
    }
}

157
158
#pragma mark -
#pragma mark Equalizer
159
static bool GetEqualizerStatus( intf_thread_t *p_custom_intf,
160
161
162
163
164
                             char *psz_name )
{
    char *psz_parser, *psz_string = NULL;
    vlc_object_t *p_object = VLC_OBJECT(getAout());
    if( p_object == NULL )
165
        p_object = vlc_object_hold(pl_Get( p_custom_intf ));
166
    
167
    psz_string = config_GetPsz( p_custom_intf, "audio-filter" );
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
    
    if(! psz_string )
        psz_string = var_GetNonEmptyString( p_object, "audio-filter" );
    
    vlc_object_release( p_object );
    
    if( !psz_string ) return false;
    
    psz_parser = strstr( psz_string, psz_name );
    
    free( psz_string );
    
    if ( psz_parser )
        return true;
    else
        return false;
}

- (void)setupEqualizer
{
    int i;
    vlc_object_t *p_object= VLC_OBJECT(getAout());
    if( p_object == NULL )
        p_object = vlc_object_hold(pl_Get( VLCIntf ));
    
    if( p_object )
    {
        char *psz_preset;
        
        var_Create( p_object, "equalizer-preset", VLC_VAR_STRING |
                   VLC_VAR_DOINHERIT );
        psz_preset = var_GetNonEmptyString( p_object, "equalizer-preset" );
        
201
        for( i = 0 ; i < NB_PRESETS ; i++ )
202
203
204
205
206
207
208
        {
            if( strcmp( preset_list[i], psz_preset ) )
                continue;
            
            [o_eq_presets_popup selectItemAtIndex: i];
            
            
Felix Paul Kühne's avatar
Felix Paul Kühne committed
209
            [o_eq_preamp_sld setFloatValue: eqz_preset_10b[i].f_preamp];
210
            [self setBandSlidersValues: (float *)eqz_preset_10b[i].f_amp];
211
212
213
214
215
216
217
218
            
            if( strcmp( psz_preset, "flat" ) )
            {
                char psz_bands[100];
                
                snprintf( psz_bands, sizeof( psz_bands ),
                         "%.1f %.1f %.1f %.1f %.1f %.1f %.1f "
                         "%.1f %.1f %.1f",
219
220
221
222
223
224
225
226
227
228
                         eqz_preset_10b[i].f_amp[0],
                         eqz_preset_10b[i].f_amp[1],
                         eqz_preset_10b[i].f_amp[2],
                         eqz_preset_10b[i].f_amp[3],
                         eqz_preset_10b[i].f_amp[4],
                         eqz_preset_10b[i].f_amp[5],
                         eqz_preset_10b[i].f_amp[6],
                         eqz_preset_10b[i].f_amp[7],
                         eqz_preset_10b[i].f_amp[8],
                         eqz_preset_10b[i].f_amp[9] );
229
230
231
232
233
234
                
                var_Create( p_object, "equalizer-preamp", VLC_VAR_FLOAT |
                           VLC_VAR_DOINHERIT );
                var_Create( p_object, "equalizer-bands", VLC_VAR_STRING |
                           VLC_VAR_DOINHERIT );
                var_SetFloat( p_object, "equalizer-preamp",
235
                             eqz_preset_10b[i].f_preamp );
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
                var_SetString( p_object, "equalizer-bands", psz_bands );
            }
        }
        free( psz_preset );
        vlc_object_release( p_object );
    }
    
    [self equalizerUpdated];
}

- (void)equalizerUpdated
{
    float f_preamp, f_band[10];
    char *psz_bands, *psz_bands_init, *p_next;
    bool b_2p;
    int i;
252
    bool b_enabled = GetEqualizerStatus( p_intf, (char *)"equalizer" );
253
254
255
256
257
258
259
260
261
262
263
264
265
266
    vlc_object_t *p_object = VLC_OBJECT(getAout());
    
    if( p_object == NULL )
        p_object = vlc_object_hold(pl_Get( p_intf ));
    
    var_Create( p_object, "equalizer-preamp", VLC_VAR_FLOAT |
               VLC_VAR_DOINHERIT );
    var_Create( p_object, "equalizer-bands", VLC_VAR_STRING |
               VLC_VAR_DOINHERIT );
    
    psz_bands = var_GetNonEmptyString( p_object, "equalizer-bands" );
    
    if( psz_bands == NULL )
        psz_bands = strdup( "0 0 0 0 0 0 0 0 0 0" );
267
268
269
270

    b_2p = (BOOL)config_GetInt( p_object, "equalizer-2pass" );
    f_preamp = config_GetFloat( p_object, "equalizer-preamp" );

271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
    vlc_object_release( p_object );
    
    /* Set the preamp slider */
    [o_eq_preamp_sld setFloatValue: f_preamp];

    /* Set the bands slider */
    psz_bands_init = psz_bands;
    
    for( i = 0; i < 10; i++ )
    {
        /* Read dB -20/20 */
        f_band[i] = strtof( psz_bands, &p_next );
        if( !p_next || p_next == psz_bands ) break; /* strtof() failed */
        
        if( !*psz_bands ) break; /* end of line */
        psz_bands = p_next+1;
    }
    free( psz_bands_init );
    [self setBandSlidersValues:f_band];
    
    /* Set the the checkboxes */
    [o_eq_enable_ckb setState: b_enabled];
    [o_eq_twopass_ckb setState: b_2p];
}

- (id)sliderByIndex:(int)index
{
    switch(index)
    {
        case 0 : return o_eq_band1_sld;
        case 1 : return o_eq_band2_sld;
        case 2 : return o_eq_band3_sld;
        case 3 : return o_eq_band4_sld;
        case 4 : return o_eq_band5_sld;
        case 5 : return o_eq_band6_sld;
        case 6 : return o_eq_band7_sld;
        case 7 : return o_eq_band8_sld;
        case 8 : return o_eq_band9_sld;
        case 9 : return o_eq_band10_sld;
        default : return nil;
    }
}

- (void)setBandSlidersValues:(float *)values
{
    for (int i = 0 ; i<= 9 ; i++)
        [self setValue:values[i] forSlider:i];
}

- (void)initBandSliders
{
    for (int i = 0 ; i< 9 ; i++)
        [self setValue:0.0 forSlider:i];
}

- (void)setValue:(float)value forSlider:(int)index
{
    id slider = [self sliderByIndex:index];
    
    if (slider != nil)
        [slider setFloatValue:value];
}

- (IBAction)eq_enable:(id)sender
{
336
    [self setAudioFilter: "equalizer" on:[sender state]];
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
}

- (IBAction)eq_bandSliderUpdated:(id)sender
{
    vlc_object_t *p_object = VLC_OBJECT(getAout());
    
    if( p_object == NULL )
        p_object = vlc_object_hold(pl_Get( p_intf ));
    
    const char *psz_values;
    NSString *preset = [NSString stringWithFormat:@"%.1f ", [o_eq_band1_sld floatValue] ];
    preset = [preset stringByAppendingFormat:@"%.1f ", [o_eq_band2_sld floatValue] ];
    preset = [preset stringByAppendingFormat:@"%.1f ", [o_eq_band3_sld floatValue] ];
    preset = [preset stringByAppendingFormat:@"%.1f ", [o_eq_band4_sld floatValue] ];
    preset = [preset stringByAppendingFormat:@"%.1f ", [o_eq_band5_sld floatValue] ];
    preset = [preset stringByAppendingFormat:@"%.1f ", [o_eq_band6_sld floatValue] ];
    preset = [preset stringByAppendingFormat:@"%.1f ", [o_eq_band7_sld floatValue] ];
    preset = [preset stringByAppendingFormat:@"%.1f ", [o_eq_band8_sld floatValue] ];
    preset = [preset stringByAppendingFormat:@"%.1f ", [o_eq_band9_sld floatValue] ];
    preset = [preset stringByAppendingFormat:@"%.1f", [o_eq_band10_sld floatValue] ];

    psz_values = [preset UTF8String];
    var_SetString( p_object, "equalizer-bands", psz_values );
360
361
362
363

    /* save changed to config */
    config_PutPsz( p_intf, "equalizer-bands", psz_values );

364
365
366
367
368
369
370
371
372
373
374
375
    vlc_object_release( p_object );
}
- (IBAction)eq_changePreset:(id)sender
{
    vlc_object_t *p_object= VLC_OBJECT(getAout());
    if( p_object == NULL )
        p_object = vlc_object_hold(pl_Get( p_intf ));
    
    var_SetString( p_object , "equalizer-preset" , preset_list[[sender indexOfSelectedItem]] );
    
    NSString *preset = @"";
    const char *psz_values;
376
    for( int i = 0; i < EQZ_BANDS_MAX; i++ )
377
    {
378
        preset = [preset stringByAppendingFormat:@"%.1f ", eqz_preset_10b[[sender indexOfSelectedItem]].f_amp[i] ];
379
380
381
    }
    psz_values = [preset UTF8String];
    var_SetString( p_object, "equalizer-bands", psz_values );
382
    var_SetFloat( p_object, "equalizer-preamp", eqz_preset_10b[[sender indexOfSelectedItem]].f_preamp);
383
    
384
    [o_eq_preamp_sld setFloatValue: eqz_preset_10b[[sender indexOfSelectedItem]].f_preamp];
385
    
386
    [self setBandSlidersValues:(float *)eqz_preset_10b[[sender indexOfSelectedItem]].f_amp];
387
    
388
389
390
391
392
    /* save changed to config */
    config_PutPsz( p_intf, "equalizer-bands", psz_values );
    config_PutFloat( p_intf, "equalizer-preamp", eqz_preset_10b[[sender indexOfSelectedItem]].f_preamp );
    config_PutPsz( p_intf, "equalizer-preset", preset_list[[sender indexOfSelectedItem]] );

393
394
395
396
397
398
399
400
401
402
403
404
    vlc_object_release( p_object );
}
- (IBAction)eq_preampSliderUpdated:(id)sender
{
    float f_preamp = [sender floatValue] ;

    vlc_object_t *p_object = VLC_OBJECT(getAout());
    if( p_object == NULL )
        p_object = vlc_object_hold(pl_Get( p_intf ));

    var_SetFloat( p_object, "equalizer-preamp", f_preamp );

405
406
    /* save changed to config */
    config_PutFloat( p_intf, "equalizer-preamp", f_preamp );
407
408
409
410
411
412

    vlc_object_release( p_object );
}
- (IBAction)eq_twopass:(id)sender
{
    bool b_2p = [sender state] ? true : false;
413
    audio_output_t *p_aout = getAout();
414
415
416
    vlc_object_t *p_object= VLC_OBJECT(p_aout);
    if( p_object == NULL )
        p_object = vlc_object_hold(pl_Get( p_intf ));
417

418
    var_SetBool( p_object, "equalizer-2pass", b_2p );
419
420
421
422

    /* save changed to config */
    config_PutInt( p_intf, "equalizer-2pass", (int)b_2p );

423
424
425
426
427
    vlc_object_release( p_object );
}

#pragma mark -
#pragma mark Compressor
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
- (void)resetCompressor
{
    char * psz_afilters;
    psz_afilters = config_GetPsz( p_intf, "audio-filter" );
    if( psz_afilters ) {
        [o_comp_enable_ckb setState: (NSInteger)strstr( psz_afilters, "compressor" ) ];
        free( psz_afilters );
    } 
    else
        [o_comp_enable_ckb setState: NSOffState];

    [o_comp_band1_sld setFloatValue: config_GetFloat( p_intf, "compressor-rms-peak" )];
    [o_comp_band1_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [o_comp_band1_sld floatValue]]];
    [o_comp_band2_sld setFloatValue: config_GetFloat( p_intf, "compressor-attack" )];
    [o_comp_band2_fld setStringValue:[NSString localizedStringWithFormat:@"%2.1f ms", [o_comp_band2_sld floatValue]]];
    [o_comp_band3_sld setFloatValue: config_GetFloat( p_intf, "compressor-release" )];
    [o_comp_band3_fld setStringValue:[NSString localizedStringWithFormat:@"%3.1f ms", [o_comp_band3_sld floatValue]]];
    [o_comp_band4_sld setFloatValue: config_GetFloat( p_intf, "compressor-threshold" )];
    [o_comp_band4_fld setStringValue:[NSString localizedStringWithFormat:@"%2.1f dB", [o_comp_band4_sld floatValue]]];
    [o_comp_band5_sld setFloatValue: config_GetFloat( p_intf, "compressor-ratio" )];
    [o_comp_band5_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f:1", [o_comp_band5_sld floatValue]]];
    [o_comp_band6_sld setFloatValue: config_GetFloat( p_intf, "compressor-knee" )];
    [o_comp_band6_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f dB", [o_comp_band6_sld floatValue]]];
    [o_comp_band7_sld setFloatValue: config_GetFloat( p_intf, "compressor-makeup-gain" )];
    [o_comp_band7_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f dB", [o_comp_band7_sld floatValue]]];
}

- (IBAction)resetCompressorValues:(id)sender
{
    config_PutFloat( p_intf, "compressor-rms-peak", 0.000000 );
    config_PutFloat( p_intf, "compressor-attack", 25.000000 );
    config_PutFloat( p_intf, "compressor-release", 100.000000 );
    config_PutFloat( p_intf, "compressor-threshold", -11.000000 );
    config_PutFloat( p_intf, "compressor-ratio", 8.000000 );
    config_PutFloat( p_intf, "compressor-knee", 2.500000 );
    config_PutFloat( p_intf, "compressor-makeup-gain", 7.000000 );

465
    audio_output_t * p_aout = getAout();
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
    if (p_aout) {
        var_SetFloat( p_aout, "compressor-rms-peak", 0.000000 );
        var_SetFloat( p_aout, "compressor-attack", 25.000000 );
        var_SetFloat( p_aout, "compressor-release", 100.000000 );
        var_SetFloat( p_aout, "compressor-threshold", -11.000000 );
        var_SetFloat( p_aout, "compressor-ratio", 8.000000 );
        var_SetFloat( p_aout, "compressor-knee", 2.500000 );
        var_SetFloat( p_aout, "compressor-makeup-gain", 7.000000 );
        vlc_object_release( p_aout );
    }
    [self resetCompressor];
}

- (IBAction)comp_enable:(id)sender
{
    [self setAudioFilter:"compressor" on:[sender state]];
}
483

484
485
- (IBAction)comp_sliderUpdated:(id)sender
{
486
    audio_output_t * p_aout = getAout();
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
    char * value;
    if( sender == o_comp_band1_sld )
        value = "compressor-rms-peak";
    else if( sender == o_comp_band2_sld )
        value = "compressor-attack";
    else if( sender == o_comp_band3_sld )
        value = "compressor-release";
    else if( sender == o_comp_band4_sld )
        value = "compressor-threshold";
    else if( sender == o_comp_band5_sld )
        value = "compressor-ratio";
    else if( sender == o_comp_band6_sld )
        value = "compressor-knee";
    else if( sender == o_comp_band7_sld )
        value = "compressor-makeup-gain";

    if( p_aout ) {
        var_SetFloat( p_aout, value, [sender floatValue] );
        vlc_object_release( p_aout );
    }
    config_PutFloat( p_intf, value, [sender floatValue] );

    if( sender == o_comp_band1_sld )
        [o_comp_band1_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [sender floatValue]]];
    else if( sender == o_comp_band2_sld )
        [o_comp_band2_fld setStringValue:[NSString localizedStringWithFormat:@"%2.1f ms", [sender floatValue]]];
    else if( sender == o_comp_band3_sld )
        [o_comp_band3_fld setStringValue:[NSString localizedStringWithFormat:@"%3.1f ms", [sender floatValue]]];
    else if( sender == o_comp_band4_sld )
        [o_comp_band4_fld setStringValue:[NSString localizedStringWithFormat:@"%2.1f dB", [sender floatValue]]];
    else if( sender == o_comp_band5_sld )
        [o_comp_band5_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f:1", [sender floatValue]]];
    else if( sender == o_comp_band6_sld )
        [o_comp_band6_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f dB", [sender floatValue]]];
    else if( sender == o_comp_band7_sld )
        [o_comp_band7_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f dB", [sender floatValue]]];
}
524
525
526

#pragma mark -
#pragma mark Spatializer
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
- (void)resetSpatializer
{
    char * psz_afilters;
    psz_afilters = config_GetPsz( p_intf, "audio-filter" );
    if( psz_afilters ) {
        [o_spat_enable_ckb setState: (NSInteger)strstr( psz_afilters, "spatializer" ) ];
        free( psz_afilters );
    } 
    else
        [o_spat_enable_ckb setState: NSOffState];
    
    [o_spat_band1_sld setFloatValue: config_GetFloat( p_intf, "spatializer-roomsize" )];
    [o_spat_band1_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [o_spat_band1_sld floatValue]]];
    [o_spat_band2_sld setFloatValue: config_GetFloat( p_intf, "spatializer-width" )];
    [o_spat_band2_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [o_spat_band2_sld floatValue]]];
    [o_spat_band3_sld setFloatValue: config_GetFloat( p_intf, "spatializer-wet" )];
    [o_spat_band3_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [o_spat_band3_sld floatValue]]];
    [o_spat_band4_sld setFloatValue: config_GetFloat( p_intf, "spatializer-dry" )];
    [o_spat_band4_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [o_spat_band4_sld floatValue]]];
    [o_spat_band5_sld setFloatValue: config_GetFloat( p_intf, "spatializer-damp" )];
    [o_spat_band5_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [o_spat_band5_sld floatValue]]];
}

- (IBAction)resetSpatializerValues:(id)sender
{
    config_PutFloat( p_intf, "spatializer-roomsize", 1.050000 );
    config_PutFloat( p_intf, "spatializer-width", 10.000000 );
    config_PutFloat( p_intf, "spatializer-wet", 3.000000 );
    config_PutFloat( p_intf, "spatializer-dry", 2.000000 );
    config_PutFloat( p_intf, "spatializer-damp", 1.000000 );

558
    audio_output_t * p_aout = getAout();
559
560
561
562
563
564
565
566
567
568
    if (p_aout) {
        var_SetFloat( p_aout, "spatializer-roomsize", 1.050000 );
        var_SetFloat( p_aout, "spatializer-width", 10.000000 );
        var_SetFloat( p_aout, "spatializer-wet", 3.000000 );
        var_SetFloat( p_aout, "spatializer-dry", 2.000000 );
        var_SetFloat( p_aout, "spatializer-damp", 1.000000 );
        vlc_object_release( p_aout );
    }
    [self resetSpatializer];
}
569

570
571
572
573
574
575
576
- (IBAction)spat_enable:(id)sender
{
    [self setAudioFilter:"spatializer" on:[sender state]];    
}

- (IBAction)spat_sliderUpdated:(id)sender
{
577
    audio_output_t * p_aout = getAout();
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
    char * value;
    if( sender == o_spat_band1_sld )
        value = "spatializer-roomsize";
    else if( sender == o_spat_band2_sld )
        value = "spatializer-width";
    else if( sender == o_spat_band3_sld )
        value = "spatializer-wet";
    else if( sender == o_spat_band4_sld )
        value = "spatializer-dry";
    else if( sender == o_spat_band5_sld )
        value = "spatializer-damp";
    
    if( p_aout ) {
        var_SetFloat( p_aout, value, [sender floatValue] );
        vlc_object_release( p_aout );
    }
    config_PutFloat( p_intf, value, [sender floatValue] );
    
    if( sender == o_spat_band1_sld )
        [o_spat_band1_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [sender floatValue]]];
    else if( sender == o_spat_band2_sld )
        [o_spat_band2_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [sender floatValue]]];
    else if( sender == o_spat_band3_sld )
        [o_spat_band3_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [sender floatValue]]];
    else if( sender == o_spat_band4_sld )
        [o_spat_band4_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [sender floatValue]]];
    else if( sender == o_spat_band5_sld )
        [o_spat_band5_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [sender floatValue]]];
}
607
608
609

#pragma mark -
#pragma mark Filter
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
- (void)resetAudioFilters
{
    char * psz_afilters;
    psz_afilters = config_GetPsz( p_intf, "audio-filter" );
    if( psz_afilters )
    {
        [o_filter_headPhone_ckb setState: (NSInteger)strstr( psz_afilters, "headphone" ) ];
        [o_filter_normLevel_ckb setState: (NSInteger)strstr( psz_afilters, "normvol" ) ];
        free( psz_afilters );
    } else {
        [o_filter_headPhone_ckb setState: NSOffState];
        [o_filter_normLevel_ckb setState: NSOffState];
    }
    [o_filter_normLevel_sld setFloatValue: config_GetFloat( p_intf, "norm-max-level" )];
}

- (IBAction)filter_enableHeadPhoneVirt:(id)sender
{
    [self setAudioFilter: "headphone" on:[sender state]];
}

- (IBAction)filter_enableVolumeNorm:(id)sender
{
    [self setAudioFilter: "normvol" on:[sender state]];    
}

- (IBAction)filter_volNormSliderUpdated:(id)sender
{
638
    audio_output_t * p_aout= getAout();
639
640
641
642
643
644
645
646
647

    if( p_aout )
    {
        var_SetFloat( p_aout, "norm-max-level", [o_filter_normLevel_sld floatValue] );
        vlc_object_release( p_aout );
    }

    config_PutFloat( p_intf, "norm-max-level", [o_filter_normLevel_sld floatValue] );
}
648
649

@end