summaryrefslogtreecommitdiffstats
path: root/firmware/sound.c
blob: acf198da2e297693c65cf76492ad109f0ee88d8c (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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
157
158
159
160
161
162
163
164
165
166
167
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
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
524
525
526
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
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
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
607
608
609
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
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2005 by Linus Nielsen Feltzing
 * Copyright (C) 2007 by Christian Gmeiner
 * Copyright (C) 2013 by Michael Sevakis
 *
 * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/
 /* Indicate it's the sound.c file which affects compilation of audiohw.h */
#define AUDIOHW_IS_SOUND_C
#include "config.h"
#include "system.h"
#include "sound.h"

#ifndef BOOTLOADER
#include "settings.h" /* sound_current */
#endif

#ifdef HAVE_SW_VOLUME_CONTROL
#include "pcm_sw_volume.h"
#endif /* HAVE_SW_VOLUME_CONTROL */

/* Define sound_setting_entries table */
#define AUDIOHW_SOUND_SETTINGS_ENTRIES
#include "audiohw_settings.h"

/* Implements sound_val2phys */
#define AUDIOHW_SOUND_SETTINGS_VAL2PHYS
#include "audiohw_settings.h"

/* Returns current sound settings from global_settings */
#define SOUND_CUR_SET(name, var) \
        case SOUND_##name: return var;

extern bool audio_is_initialized;

static const struct sound_setting_entry * get_setting_entry(int setting)
{
    static const struct sound_settings_info default_info =
        { "", 0, 0, 0, 0, 0 };

    static const struct sound_setting_entry default_entry =
        { &default_info, NULL }; 

    if ((unsigned)setting >= ARRAYLEN(sound_setting_entries))
        return &default_entry;

    const struct sound_setting_entry *e = &sound_setting_entries[setting];
    return e->info ? e : &default_entry; /* setting valid but not in table? */
}

static const struct sound_settings_info * get_settings_info(int setting)
{
    return get_setting_entry(setting)->info;
}

const char * sound_unit(int setting)
{
    return get_settings_info(setting)->unit;
}

int sound_numdecimals(int setting)
{
    return get_settings_info(setting)->numdecimals;
}

int sound_steps(int setting)
{
    return get_settings_info(setting)->steps;
}

int sound_min(int setting)
{
    return get_settings_info(setting)->minval;
}

int sound_max(int setting)
{
    return get_settings_info(setting)->maxval;
}

int sound_default(int setting)
{
    return get_settings_info(setting)->defaultval;
}

sound_set_type * sound_get_fn(int setting)
{
    return get_setting_entry(setting)->function;
}

void sound_set(int setting, int value)
{
    sound_set_type *sound_set_val = sound_get_fn(setting);

    if (sound_set_val)
        sound_set_val(value);
}

int sound_current(int setting)
{
    switch(setting)
    {
#ifndef BOOTLOADER 
#ifndef PLATFORM_HAS_VOLUME_CHANGE
        SOUND_CUR_SET(VOLUME,             global_settings.volume)
#endif
#if defined(AUDIOHW_HAVE_BASS)
        SOUND_CUR_SET(BASS,               global_settings.bass)
#endif
#if defined(AUDIOHW_HAVE_TREBLE)
        SOUND_CUR_SET(TREBLE,             global_settings.treble)
#endif
        SOUND_CUR_SET(BALANCE,            global_settings.balance)
        SOUND_CUR_SET(CHANNELS,           global_settings.channel_config)
        SOUND_CUR_SET(STEREO_WIDTH,       global_settings.stereo_width)
#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
        SOUND_CUR_SET(BASS_CUTOFF,        global_settings.bass_cutoff)
#endif
#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
        SOUND_CUR_SET(TREBLE_CUTOFF,      global_settings.treble_cutoff)
#endif
#if defined(AUDIOHW_HAVE_DEPTH_3D)
        SOUND_CUR_SET(DEPTH_3D,           global_settings.depth_3d)
#endif
#if defined(AUDIOHW_HAVE_FILTER_ROLL_OFF)
        SOUND_CUR_SET(FILTER_ROLL_OFF,    global_settings.roll_off)
#endif

#if 0 /*WRONG -- these need to index the hw_eq_bands[AUDIOHW_EQ_BAND_NUM] struct*/
/* Hardware EQ tone controls */
#if defined(AUDIOHW_HAVE_EQ)
        SOUND_CUR_SET(EQ_BAND1_GAIN,      global_settings.hw_eq_band1_gain)
#if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
        SOUND_CUR_SET(EQ_BAND1_FREQUENCY, global_settings.hw_eq_band1_frequency)
#endif
#if defined(AUDIOHW_HAVE_EQ_BAND2)
        SOUND_CUR_SET(EQ_BAND2_GAIN,      global_settings.hw_eq_band2_gain)
#if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
        SOUND_CUR_SET(EQ_BAND2_FREQUENCY, global_settings.hw_eq_band2_frequency)
#endif
#if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
        SOUND_CUR_SET(EQ_BAND2_WIDTH,     global_settings.hw_eq_band2_width)
#endif
#endif /* AUDIOHW_HAVE_EQ_BAND2 */
#if defined(AUDIOHW_HAVE_EQ_BAND3)
        SOUND_CUR_SET(EQ_BAND3_GAIN,      global_settings.hw_eq_band3_gain)
#if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
        SOUND_CUR_SET(EQ_BAND3_FREQUENCY, global_settings.hw_eq_band3_frequency)
#endif
#if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
        SOUND_CUR_SET(EQ_BAND3_WIDTH,     global_settings.hw_eq_band3_width)
#endif
#endif /* AUDIOHW_HAVE_EQ_BAND3 */
#if defined(AUDIOHW_HAVE_EQ_BAND4)
        SOUND_CUR_SET(EQ_BAND4_GAIN,      global_settings.hw_eq_band4_gain)
#if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
        SOUND_CUR_SET(EQ_BAND4_FREQUENCY, global_settings.hw_eq_band4_frequency)
#endif
#if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
        SOUND_CUR_SET(EQ_BAND4_WIDTH,     global_settings.hw_eq_band4_width)
#endif
#endif /* AUDIOHW_HAVE_EQ_BAND4 */
#if defined(AUDIOHW_HAVE_EQ_BAND5)
        SOUND_CUR_SET(EQ_BAND5_GAIN,      global_settings.hw_eq_band5_gain)
#if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
        SOUND_CUR_SET(EQ_BAND5_FREQUENCY, global_settings.hw_eq_band5_frequency)
#endif

#endif /* AUDIOHW_HAVE_EQ_BAND5 */
#endif /* AUDIOHW_HAVE_EQ */
#endif /*IF 0*/

#endif /*ndef BOOTLOADER*/
#ifdef INT_MIN
        default:
            return INT_MIN;
#else
        default:
            return -32768;
#endif


    } /* switch(setting)  */
}/* sound_current */

#if !defined(AUDIOHW_HAVE_CLIPPING)
/*
 * The prescaler compensates for any kind of boosts, to prevent clipping.
 *
 * It's basically just a measure to make sure that audio does not clip during
 * tone controls processing, like if i want to boost bass 12 dB, i can decrease
 * the audio amplitude by -12 dB before processing, then increase master gain
 * by 12 dB after processing.
 */

/* Return the sound value scaled to centibels (tenth-decibels) */
static int sound_value_to_cb(int setting, int value)
{
    int shift = 1 - sound_numdecimals(setting);
    if (shift < 0) do { value /= 10; } while (++shift);
    if (shift > 0) do { value *= 10; } while (--shift);
    return value;
}

static struct
{
    int volume;                       /* tenth dB */
    int balance;                      /* percent  */
#if defined(AUDIOHW_HAVE_BASS)
    int bass;                         /* tenth dB */
#endif
#if defined(AUDIOHW_HAVE_TREBLE)
    int treble;                       /* tenth dB */
#endif
#if defined(AUDIOHW_HAVE_EQ)
    int eq_gain[AUDIOHW_EQ_BAND_NUM]; /* tenth dB */
#endif
} sound_prescaler;

#if defined(AUDIOHW_HAVE_BASS) || defined (AUDIOHW_HAVE_TREBLE) \
        || defined(AUDIOHW_HAVE_EQ)
#define TONE_PRESCALER
#endif

static void set_prescaled_volume(void)
{
#if defined(TONE_PRESCALER) || !defined(AUDIOHW_HAVE_MONO_VOLUME)
    const int minvol = sound_value_to_cb(SOUND_VOLUME, sound_min(SOUND_VOLUME));
#endif
    int volume = sound_prescaler.volume;

#if defined(TONE_PRESCALER)
    int prescale = 0;

    /* Note: Having Tone + EQ isn't prohibited */
#if defined(AUDIOHW_HAVE_BASS) && defined(AUDIOHW_HAVE_TREBLE)
    prescale = MAX(sound_prescaler.bass, sound_prescaler.treble);
#endif

#if defined(AUDIOHW_HAVE_EQ)
    for (int i = 0; i < AUDIOHW_EQ_BAND_NUM; i++)
        prescale = MAX(sound_prescaler.eq_gain[i], prescale);
#endif

    if (prescale < 0)
        prescale = 0;  /* no need to prescale if we don't boost
                          bass, treble or eq band */

    /* Gain up the analog volume to compensate the prescale gain reduction,
     * but if this would push the volume over the top, reduce prescaling
     * instead (might cause clipping). */
    const int maxvol = sound_value_to_cb(SOUND_VOLUME, sound_max(SOUND_VOLUME));

    if (volume + prescale > maxvol)
        prescale = maxvol - volume;

    audiohw_set_prescaler(prescale);

    if (volume <= minvol)
        prescale = 0;  /* Make sure the audio gets muted */

#ifndef AUDIOHW_HAVE_MONO_VOLUME
    /* At the moment, such targets have lousy volume resolution and so minute
       boost won't work how we'd like */
    volume += prescale;
#endif
#endif /* TONE_PRESCALER */

#if defined(AUDIOHW_HAVE_MONO_VOLUME)
    audiohw_set_volume(volume);
#else /* Stereo volume */
    int l = volume, r = volume;

    /* Balance the channels scaled by the current volume and min volume */
    int balance = sound_prescaler.balance; /* percent */

    if (balance > 0)
    {
        l -= (l - minvol) * balance / 100;
    }
    else if (balance < 0)
    {
        r += (r - minvol) * balance / 100;
    }

    audiohw_set_volume(l, r);
#endif /* AUDIOHW_HAVE_MONO_VOLUME */

#if defined(AUDIOHW_HAVE_LINEOUT)
    /* For now, lineout stays at unity */
    audiohw_set_lineout_volume(0, 0);
#endif /* AUDIOHW_HAVE_LINEOUT */
}
#endif /* AUDIOIHW_HAVE_CLIPPING */

void sound_set_volume(int value)
{
    if (!audio_is_initialized)
        return;

#if defined(AUDIOHW_HAVE_CLIPPING)
    audiohw_set_volume(value);
#else
    sound_prescaler.volume = sound_value_to_cb(SOUND_VOLUME, value);
    set_prescaled_volume();
#endif
}

void sound_set_balance(int value)
{
    if (!audio_is_initialized)
        return;

#if defined(AUDIOHW_HAVE_BALANCE)
    audiohw_set_balance(value);
#else
    sound_prescaler.balance = value;
    set_prescaled_volume();
#endif
}

#if defined(AUDIOHW_HAVE_BASS)
void sound_set_bass(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_bass(value);

#if !defined(AUDIOHW_HAVE_CLIPPING)
    sound_prescaler.bass = sound_value_to_cb(SOUND_BASS, value);
    set_prescaled_volume();
#endif
}
#endif /* AUDIOHW_HAVE_BASS */

#if defined(AUDIOHW_HAVE_TREBLE)
void sound_set_treble(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_treble(value);

#if !defined(AUDIOHW_HAVE_CLIPPING)
    sound_prescaler.treble = sound_value_to_cb(SOUND_TREBLE, value);
    set_prescaled_volume();
#endif
}
#endif /* AUDIOHW_HAVE_TREBLE */

#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
void sound_set_bass_cutoff(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_bass_cutoff(value);
}
#endif /* AUDIOHW_HAVE_BASS_CUTOFF */

#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
void sound_set_treble_cutoff(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_treble_cutoff(value);
}
#endif /* AUDIOHW_HAVE_TREBLE_CUTOFF */

void sound_set_channels(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_channel(value);
}

void sound_set_stereo_width(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_stereo_width(value);
}

#if defined(AUDIOHW_HAVE_DEPTH_3D)
void sound_set_depth_3d(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_depth_3d(value);
}
#endif /* AUDIOHW_HAVE_DEPTH_3D */

#if defined(AUDIOHW_HAVE_FILTER_ROLL_OFF)
void sound_set_filter_roll_off(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_filter_roll_off(value);
}
#endif

#if defined(AUDIOHW_HAVE_EQ)
int sound_enum_hw_eq_band_setting(unsigned int band,
                                  unsigned int band_setting)
{
    static const int8_t
    sound_hw_eq_band_setting[AUDIOHW_EQ_SETTING_NUM][AUDIOHW_EQ_BAND_NUM] =
    {
        [AUDIOHW_EQ_GAIN] =
        {
            [0 ... AUDIOHW_EQ_BAND_NUM-1] = -1,
            [AUDIOHW_EQ_BAND1] = SOUND_EQ_BAND1_GAIN,
        #ifdef AUDIOHW_HAVE_EQ_BAND2
            [AUDIOHW_EQ_BAND2] = SOUND_EQ_BAND2_GAIN,
        #endif
        #ifdef AUDIOHW_HAVE_EQ_BAND3
            [AUDIOHW_EQ_BAND3] = SOUND_EQ_BAND3_GAIN,
        #endif
        #ifdef AUDIOHW_HAVE_EQ_BAND4
            [AUDIOHW_EQ_BAND4] = SOUND_EQ_BAND4_GAIN,
        #endif
        #ifdef AUDIOHW_HAVE_EQ_BAND5
            [AUDIOHW_EQ_BAND5] = SOUND_EQ_BAND5_GAIN,
        #endif
        },
#ifdef AUDIOHW_HAVE_EQ_FREQUENCY
        [AUDIOHW_EQ_FREQUENCY] =
        {
            [0 ... AUDIOHW_EQ_BAND_NUM-1] = -1,
        #ifdef AUDIOHW_HAVE_EQ_BAND1_FREQUENCY
            [AUDIOHW_EQ_BAND1] = SOUND_EQ_BAND1_FREQUENCY,
        #endif
        #ifdef AUDIOHW_HAVE_EQ_BAND2_FREQUENCY
            [AUDIOHW_EQ_BAND2] = SOUND_EQ_BAND2_FREQUENCY,
        #endif
        #ifdef AUDIOHW_HAVE_EQ_BAND3_FREQUENCY
            [AUDIOHW_EQ_BAND3] = SOUND_EQ_BAND3_FREQUENCY,
        #endif
        #ifdef AUDIOHW_HAVE_EQ_BAND4_FREQUENCY
            [AUDIOHW_EQ_BAND4] = SOUND_EQ_BAND4_FREQUENCY,
        #endif
        #ifdef AUDIOHW_HAVE_EQ_BAND5_FREQUENCY
            [AUDIOHW_EQ_BAND5] = SOUND_EQ_BAND5_FREQUENCY,
        #endif
        },
#endif /* AUDIOHW_HAVE_EQ_FREQUENCY */
#ifdef AUDIOHW_HAVE_EQ_WIDTH
        [AUDIOHW_EQ_WIDTH] =
        {
            [0 ... AUDIOHW_EQ_BAND_NUM-1] = -1,
        #ifdef AUDIOHW_HAVE_EQ_BAND2_WIDTH
            [AUDIOHW_EQ_BAND2] = SOUND_EQ_BAND2_WIDTH,
        #endif
        #ifdef AUDIOHW_HAVE_EQ_BAND3_WIDTH
            [AUDIOHW_EQ_BAND3] = SOUND_EQ_BAND3_WIDTH,
        #endif
        #ifdef AUDIOHW_HAVE_EQ_BAND4_WIDTH
            [AUDIOHW_EQ_BAND4] = SOUND_EQ_BAND4_WIDTH,
        #endif
        },
#endif /* AUDIOHW_HAVE_EQ_WIDTH */
    };

    if (band < AUDIOHW_EQ_BAND_NUM && band_setting < AUDIOHW_EQ_SETTING_NUM)
        return sound_hw_eq_band_setting[band_setting][band];

    return -1;
}

static void sound_set_hw_eq_band_gain(unsigned int band, int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_eq_band_gain(band, value);

#if !defined (AUDIOHW_HAVE_CLIPPING)
    int setting = sound_enum_hw_eq_band_setting(band, AUDIOHW_EQ_GAIN);
    sound_prescaler.eq_gain[band] = sound_value_to_cb(setting, value);
    set_prescaled_volume();
#endif /* AUDIOHW_HAVE_CLIPPING */
}

void sound_set_hw_eq_band1_gain(int value)
{
    sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND1, value);
}

#if defined(AUDIOHW_HAVE_EQ_BAND2)
void sound_set_hw_eq_band2_gain(int value)
{
    sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND2, value);
}
#endif

#if defined(AUDIOHW_HAVE_EQ_BAND3)
void sound_set_hw_eq_band3_gain(int value)
{
    sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND3, value);
}
#endif

#if defined(AUDIOHW_HAVE_EQ_BAND4)
void sound_set_hw_eq_band4_gain(int value)
{
    sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND4, value);
}
#endif

#if defined(AUDIOHW_HAVE_EQ_BAND5)
void sound_set_hw_eq_band5_gain(int value)
{
    sound_set_hw_eq_band_gain(AUDIOHW_EQ_BAND5, value);
}
#endif

#if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
void sound_set_hw_eq_band1_frequency(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND1, value);
}
#endif

#if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
void sound_set_hw_eq_band2_frequency(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND2, value);
}
#endif

#if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
void sound_set_hw_eq_band3_frequency(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND3, value);
}
#endif

#if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
void sound_set_hw_eq_band4_frequency(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND4, value);
}
#endif

#if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
void sound_set_hw_eq_band5_frequency(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND5, value);
}
#endif

#if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
void sound_set_hw_eq_band2_width(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_eq_band_width(AUDIOHW_EQ_BAND2, value);
}
#endif

#if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
void sound_set_hw_eq_band3_width(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_eq_band_width(AUDIOHW_EQ_BAND3, value);
}
#endif

#if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
void sound_set_hw_eq_band4_width(int value)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_eq_band_width(AUDIOHW_EQ_BAND4, value);
}
#endif
#endif /* AUDIOHW_HAVE_EQ */

#if defined(HAVE_PITCHCONTROL)
void sound_set_pitch(int32_t pitch)
{
    if (!audio_is_initialized)
        return;

    audiohw_set_pitch(pitch);
}

int32_t sound_get_pitch(void)
{
    if (!audio_is_initialized)
        return PITCH_SPEED_100;

    return audiohw_get_pitch();
}
#endif /* HAVE_PITCHCONTROL */