2005-04-01 13:41:03 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 by Linus Nielsen Feltzing
|
2007-05-22 15:56:05 +00:00
|
|
|
* Copyright (C) 2007 by Christian Gmeiner
|
2013-04-13 03:35:47 +00:00
|
|
|
* Copyright (C) 2013 by Michael Sevakis
|
2005-04-01 13:41:03 +00:00
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* 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.
|
2005-04-01 13:41:03 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2013-04-13 03:35:47 +00:00
|
|
|
/* Indicate it's the sound.c file which affects compilation of audiohw.h */
|
|
|
|
#define AUDIOHW_IS_SOUND_C
|
2005-04-01 13:41:03 +00:00
|
|
|
#include "config.h"
|
2009-01-02 11:21:58 +00:00
|
|
|
#include "system.h"
|
2013-04-13 03:35:47 +00:00
|
|
|
#include "sound.h"
|
2019-07-25 13:03:18 +00:00
|
|
|
|
|
|
|
#ifndef BOOTLOADER
|
2019-07-25 05:48:40 +00:00
|
|
|
#include "settings.h" /* sound_current */
|
2019-07-25 13:03:18 +00:00
|
|
|
#endif
|
2019-07-25 05:48:40 +00:00
|
|
|
|
2013-04-05 08:36:05 +00:00
|
|
|
#ifdef HAVE_SW_VOLUME_CONTROL
|
|
|
|
#include "pcm_sw_volume.h"
|
|
|
|
#endif /* HAVE_SW_VOLUME_CONTROL */
|
2005-04-01 13:41:03 +00:00
|
|
|
|
2013-04-13 03:35:47 +00:00
|
|
|
/* 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"
|
2008-04-28 22:15:52 +00:00
|
|
|
|
2019-07-25 05:48:40 +00:00
|
|
|
/* Returns current sound settings from global_settings */
|
|
|
|
#define SOUND_CUR_SET(name, var) \
|
|
|
|
case SOUND_##name: return var;
|
|
|
|
|
2005-04-01 13:41:03 +00:00
|
|
|
extern bool audio_is_initialized;
|
|
|
|
|
2013-04-13 03:35:47 +00:00
|
|
|
static const struct sound_setting_entry * get_setting_entry(int setting)
|
2005-04-01 13:41:03 +00:00
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
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;
|
2005-04-01 13:41:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int sound_numdecimals(int setting)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
return get_settings_info(setting)->numdecimals;
|
2005-04-01 13:41:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int sound_steps(int setting)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
return get_settings_info(setting)->steps;
|
2005-04-01 13:41:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int sound_min(int setting)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
return get_settings_info(setting)->minval;
|
2005-04-01 13:41:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int sound_max(int setting)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
return get_settings_info(setting)->maxval;
|
2005-04-01 13:41:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int sound_default(int setting)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
return get_settings_info(setting)->defaultval;
|
2005-11-06 23:12:11 +00:00
|
|
|
}
|
|
|
|
|
2013-04-13 03:35:47 +00:00
|
|
|
sound_set_type * sound_get_fn(int setting)
|
2005-11-06 23:12:11 +00:00
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
return get_setting_entry(setting)->function;
|
|
|
|
}
|
2007-05-22 15:56:05 +00:00
|
|
|
|
2013-04-13 03:35:47 +00:00
|
|
|
void sound_set(int setting, int value)
|
2009-01-02 11:21:58 +00:00
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
sound_set_type *sound_set_val = sound_get_fn(setting);
|
2005-04-01 13:41:03 +00:00
|
|
|
|
2013-04-13 03:35:47 +00:00
|
|
|
if (sound_set_val)
|
|
|
|
sound_set_val(value);
|
|
|
|
}
|
2007-02-26 00:41:26 +00:00
|
|
|
|
2019-07-25 05:48:40 +00:00
|
|
|
int sound_current(int setting)
|
|
|
|
{
|
|
|
|
switch(setting)
|
|
|
|
{
|
2019-07-25 13:03:18 +00:00
|
|
|
#ifndef BOOTLOADER
|
2019-07-25 05:48:40 +00:00
|
|
|
#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)
|
2019-07-25 13:03:18 +00:00
|
|
|
SOUND_CUR_SET(FILTER_ROLL_OFF, global_settings.roll_off)
|
2019-07-25 05:48:40 +00:00
|
|
|
#endif
|
2019-07-25 13:03:18 +00:00
|
|
|
|
|
|
|
#if 0 /*WRONG -- these need to index the hw_eq_bands[AUDIOHW_EQ_BAND_NUM] struct*/
|
2019-07-25 05:48:40 +00:00
|
|
|
/* 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
|
2019-07-25 13:03:18 +00:00
|
|
|
|
2019-07-25 05:48:40 +00:00
|
|
|
#endif /* AUDIOHW_HAVE_EQ_BAND5 */
|
|
|
|
#endif /* AUDIOHW_HAVE_EQ */
|
2019-07-25 13:03:18 +00:00
|
|
|
#endif /*IF 0*/
|
|
|
|
|
|
|
|
#endif /*ndef BOOTLOADER*/
|
2019-07-25 13:49:11 +00:00
|
|
|
#ifdef INT_MIN
|
2019-07-25 05:48:40 +00:00
|
|
|
default:
|
|
|
|
return INT_MIN;
|
2019-07-25 13:49:11 +00:00
|
|
|
#else
|
|
|
|
default:
|
|
|
|
return -32768;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2019-07-25 05:48:40 +00:00
|
|
|
} /* switch(setting) */
|
|
|
|
}/* sound_current */
|
|
|
|
|
2008-05-13 06:19:16 +00:00
|
|
|
#if !defined(AUDIOHW_HAVE_CLIPPING)
|
2008-04-28 08:37:18 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2005-06-19 23:33:23 +00:00
|
|
|
|
2013-04-15 17:24:29 +00:00
|
|
|
/* Return the sound value scaled to centibels (tenth-decibels) */
|
|
|
|
static int sound_value_to_cb(int setting, int value)
|
|
|
|
{
|
2013-04-15 20:11:28 +00:00
|
|
|
int shift = 1 - sound_numdecimals(setting);
|
|
|
|
if (shift < 0) do { value /= 10; } while (++shift);
|
|
|
|
if (shift > 0) do { value *= 10; } while (--shift);
|
|
|
|
return value;
|
2013-04-15 17:24:29 +00:00
|
|
|
}
|
|
|
|
|
2013-04-20 08:06:13 +00:00
|
|
|
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
|
|
|
|
|
2005-06-19 23:33:23 +00:00
|
|
|
static void set_prescaled_volume(void)
|
2005-06-18 01:25:47 +00:00
|
|
|
{
|
2013-04-20 08:06:13 +00:00
|
|
|
#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;
|
2005-06-18 01:25:47 +00:00
|
|
|
|
2013-04-20 08:06:13 +00:00
|
|
|
#if defined(TONE_PRESCALER)
|
|
|
|
int prescale = 0;
|
2007-03-07 15:00:29 +00:00
|
|
|
|
2013-04-13 03:35:47 +00:00
|
|
|
/* Note: Having Tone + EQ isn't prohibited */
|
2010-05-15 13:09:45 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_BASS) && defined(AUDIOHW_HAVE_TREBLE)
|
2013-04-20 08:06:13 +00:00
|
|
|
prescale = MAX(sound_prescaler.bass, sound_prescaler.treble);
|
2010-05-15 13:09:45 +00:00
|
|
|
#endif
|
2013-04-20 08:06:13 +00:00
|
|
|
|
2010-05-15 13:09:45 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_EQ)
|
2013-04-13 03:35:47 +00:00
|
|
|
for (int i = 0; i < AUDIOHW_EQ_BAND_NUM; i++)
|
2013-04-20 08:06:13 +00:00
|
|
|
prescale = MAX(sound_prescaler.eq_gain[i], prescale);
|
2010-05-15 13:09:45 +00:00
|
|
|
#endif
|
|
|
|
|
2005-06-19 23:33:23 +00:00
|
|
|
if (prescale < 0)
|
|
|
|
prescale = 0; /* no need to prescale if we don't boost
|
2010-05-15 13:09:45 +00:00
|
|
|
bass, treble or eq band */
|
2005-06-19 23:33:23 +00:00
|
|
|
|
2005-12-07 23:07:07 +00:00
|
|
|
/* 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). */
|
2013-04-20 08:06:13 +00:00
|
|
|
const int maxvol = sound_value_to_cb(SOUND_VOLUME, sound_max(SOUND_VOLUME));
|
|
|
|
|
|
|
|
if (volume + prescale > maxvol)
|
|
|
|
prescale = maxvol - volume;
|
2007-03-07 15:00:29 +00:00
|
|
|
|
2008-05-14 21:35:19 +00:00
|
|
|
audiohw_set_prescaler(prescale);
|
2005-12-07 23:07:07 +00:00
|
|
|
|
2013-04-20 08:06:13 +00:00
|
|
|
if (volume <= minvol)
|
2013-04-13 03:35:47 +00:00
|
|
|
prescale = 0; /* Make sure the audio gets muted */
|
2013-04-20 08:06:13 +00:00
|
|
|
|
|
|
|
#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 */
|
2005-12-07 23:07:07 +00:00
|
|
|
|
2013-04-13 03:35:47 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_MONO_VOLUME)
|
2013-04-20 08:06:13 +00:00
|
|
|
audiohw_set_volume(volume);
|
2013-04-13 03:35:47 +00:00
|
|
|
#else /* Stereo volume */
|
2013-04-20 08:06:13 +00:00
|
|
|
int l = volume, r = volume;
|
2005-06-18 01:25:47 +00:00
|
|
|
|
2013-04-20 08:06:13 +00:00
|
|
|
/* Balance the channels scaled by the current volume and min volume */
|
|
|
|
int balance = sound_prescaler.balance; /* percent */
|
2013-04-13 03:35:47 +00:00
|
|
|
|
2013-04-20 08:06:13 +00:00
|
|
|
if (balance > 0)
|
2005-06-18 01:25:47 +00:00
|
|
|
{
|
2013-04-20 08:06:13 +00:00
|
|
|
l -= (l - minvol) * balance / 100;
|
2005-06-18 01:25:47 +00:00
|
|
|
}
|
2013-04-20 08:06:13 +00:00
|
|
|
else if (balance < 0)
|
2005-06-18 01:25:47 +00:00
|
|
|
{
|
2013-04-20 08:06:13 +00:00
|
|
|
r += (r - minvol) * balance / 100;
|
2005-06-18 01:25:47 +00:00
|
|
|
}
|
|
|
|
|
2013-04-13 03:35:47 +00:00
|
|
|
audiohw_set_volume(l, r);
|
|
|
|
#endif /* AUDIOHW_HAVE_MONO_VOLUME */
|
2006-03-22 13:04:49 +00:00
|
|
|
|
2013-04-13 03:35:47 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_LINEOUT)
|
|
|
|
/* For now, lineout stays at unity */
|
|
|
|
audiohw_set_lineout_volume(0, 0);
|
|
|
|
#endif /* AUDIOHW_HAVE_LINEOUT */
|
2005-06-19 23:33:23 +00:00
|
|
|
}
|
2013-04-13 03:35:47 +00:00
|
|
|
#endif /* AUDIOIHW_HAVE_CLIPPING */
|
2005-04-01 13:41:03 +00:00
|
|
|
|
2005-11-06 03:18:34 +00:00
|
|
|
void sound_set_volume(int value)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2005-04-01 13:41:03 +00:00
|
|
|
return;
|
2008-05-13 06:19:16 +00:00
|
|
|
|
|
|
|
#if defined(AUDIOHW_HAVE_CLIPPING)
|
|
|
|
audiohw_set_volume(value);
|
|
|
|
#else
|
2013-04-20 08:06:13 +00:00
|
|
|
sound_prescaler.volume = sound_value_to_cb(SOUND_VOLUME, value);
|
2008-05-13 06:19:16 +00:00
|
|
|
set_prescaled_volume();
|
2005-12-07 23:07:07 +00:00
|
|
|
#endif
|
2005-11-06 03:18:34 +00:00
|
|
|
}
|
2005-04-01 13:41:03 +00:00
|
|
|
|
2005-11-06 03:18:34 +00:00
|
|
|
void sound_set_balance(int value)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2005-11-06 03:18:34 +00:00
|
|
|
return;
|
2008-05-13 06:19:16 +00:00
|
|
|
|
2013-04-13 03:35:47 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_BALANCE)
|
2008-05-13 06:19:16 +00:00
|
|
|
audiohw_set_balance(value);
|
|
|
|
#else
|
2013-04-20 08:06:13 +00:00
|
|
|
sound_prescaler.balance = value;
|
2005-11-06 03:18:34 +00:00
|
|
|
set_prescaled_volume();
|
2005-12-07 23:07:07 +00:00
|
|
|
#endif
|
2005-11-06 03:18:34 +00:00
|
|
|
}
|
2005-04-01 13:41:03 +00:00
|
|
|
|
2013-04-20 08:06:13 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_BASS)
|
2005-11-06 03:18:34 +00:00
|
|
|
void sound_set_bass(int value)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2005-11-06 03:18:34 +00:00
|
|
|
return;
|
2008-04-28 08:37:18 +00:00
|
|
|
|
2010-05-15 13:09:45 +00:00
|
|
|
audiohw_set_bass(value);
|
2008-04-28 08:37:18 +00:00
|
|
|
|
2008-05-13 06:19:16 +00:00
|
|
|
#if !defined(AUDIOHW_HAVE_CLIPPING)
|
2013-04-20 08:06:13 +00:00
|
|
|
sound_prescaler.bass = sound_value_to_cb(SOUND_BASS, value);
|
2006-01-30 21:12:31 +00:00
|
|
|
set_prescaled_volume();
|
2008-04-28 08:37:18 +00:00
|
|
|
#endif
|
2005-11-06 03:18:34 +00:00
|
|
|
}
|
2010-05-15 13:09:45 +00:00
|
|
|
#endif /* AUDIOHW_HAVE_BASS */
|
2005-04-01 13:41:03 +00:00
|
|
|
|
2013-04-20 08:06:13 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_TREBLE)
|
2005-11-06 03:18:34 +00:00
|
|
|
void sound_set_treble(int value)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2005-11-06 03:18:34 +00:00
|
|
|
return;
|
2008-04-28 08:37:18 +00:00
|
|
|
|
2010-05-15 13:09:45 +00:00
|
|
|
audiohw_set_treble(value);
|
2008-04-28 08:37:18 +00:00
|
|
|
|
2008-05-13 06:19:16 +00:00
|
|
|
#if !defined(AUDIOHW_HAVE_CLIPPING)
|
2013-04-20 08:06:13 +00:00
|
|
|
sound_prescaler.treble = sound_value_to_cb(SOUND_TREBLE, value);
|
2006-01-30 21:12:31 +00:00
|
|
|
set_prescaled_volume();
|
2008-04-15 14:44:32 +00:00
|
|
|
#endif
|
2005-11-06 23:12:11 +00:00
|
|
|
}
|
2010-05-15 13:09:45 +00:00
|
|
|
#endif /* AUDIOHW_HAVE_TREBLE */
|
|
|
|
|
|
|
|
#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
|
|
|
|
void sound_set_bass_cutoff(int value)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2010-05-15 13:09:45 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
audiohw_set_bass_cutoff(value);
|
|
|
|
}
|
2013-04-20 08:06:13 +00:00
|
|
|
#endif /* AUDIOHW_HAVE_BASS_CUTOFF */
|
2010-05-15 13:09:45 +00:00
|
|
|
|
|
|
|
#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
|
|
|
|
void sound_set_treble_cutoff(int value)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2010-05-15 13:09:45 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
audiohw_set_treble_cutoff(value);
|
|
|
|
}
|
2013-04-20 08:06:13 +00:00
|
|
|
#endif /* AUDIOHW_HAVE_TREBLE_CUTOFF */
|
2005-11-06 23:12:11 +00:00
|
|
|
|
|
|
|
void sound_set_channels(int value)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2008-04-22 13:43:01 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
audiohw_set_channel(value);
|
2005-11-06 23:12:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void sound_set_stereo_width(int value)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2008-04-22 13:43:01 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
audiohw_set_stereo_width(value);
|
2005-11-06 03:18:34 +00:00
|
|
|
}
|
|
|
|
|
2010-05-15 13:09:45 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_DEPTH_3D)
|
|
|
|
void sound_set_depth_3d(int value)
|
2007-11-24 07:51:00 +00:00
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2007-11-24 07:51:00 +00:00
|
|
|
return;
|
|
|
|
|
2010-05-15 13:09:45 +00:00
|
|
|
audiohw_set_depth_3d(value);
|
2007-11-24 07:51:00 +00:00
|
|
|
}
|
2013-04-20 08:06:13 +00:00
|
|
|
#endif /* AUDIOHW_HAVE_DEPTH_3D */
|
2007-11-24 07:51:00 +00:00
|
|
|
|
2013-05-12 19:23:45 +00:00
|
|
|
#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
|
|
|
|
|
2010-05-15 13:09:45 +00:00
|
|
|
#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)
|
2007-11-24 07:51:00 +00:00
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2007-11-24 07:51:00 +00:00
|
|
|
return;
|
|
|
|
|
2010-05-15 13:09:45 +00:00
|
|
|
audiohw_set_eq_band_gain(band, value);
|
2013-04-20 08:06:13 +00:00
|
|
|
|
|
|
|
#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);
|
2010-05-15 13:09:45 +00:00
|
|
|
set_prescaled_volume();
|
2013-04-20 08:06:13 +00:00
|
|
|
#endif /* AUDIOHW_HAVE_CLIPPING */
|
2010-05-15 13:09:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2007-11-24 07:51:00 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-05-15 13:09:45 +00:00
|
|
|
#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)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2010-05-15 13:09:45 +00:00
|
|
|
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)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2010-05-15 13:09:45 +00:00
|
|
|
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)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2010-05-15 13:09:45 +00:00
|
|
|
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)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2010-05-15 13:09:45 +00:00
|
|
|
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)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2010-05-15 13:09:45 +00:00
|
|
|
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)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2010-05-15 13:09:45 +00:00
|
|
|
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)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2010-05-15 13:09:45 +00:00
|
|
|
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)
|
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
2010-05-15 13:09:45 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
audiohw_set_eq_band_width(AUDIOHW_EQ_BAND4, value);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* AUDIOHW_HAVE_EQ */
|
|
|
|
|
2013-04-20 08:06:13 +00:00
|
|
|
#if defined(HAVE_PITCHCONTROL)
|
2009-07-11 16:46:19 +00:00
|
|
|
void sound_set_pitch(int32_t pitch)
|
2005-04-01 13:41:03 +00:00
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
|
|
|
return;
|
2005-11-06 03:18:34 +00:00
|
|
|
|
2013-04-13 03:35:47 +00:00
|
|
|
audiohw_set_pitch(pitch);
|
2005-05-22 12:45:35 +00:00
|
|
|
}
|
|
|
|
|
2009-07-11 16:46:19 +00:00
|
|
|
int32_t sound_get_pitch(void)
|
2005-05-22 12:45:35 +00:00
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
if (!audio_is_initialized)
|
|
|
|
return PITCH_SPEED_100;
|
|
|
|
|
|
|
|
return audiohw_get_pitch();
|
2005-04-01 13:41:03 +00:00
|
|
|
}
|
2013-04-13 03:35:47 +00:00
|
|
|
#endif /* HAVE_PITCHCONTROL */
|