2007-04-26 16:54:31 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2000-2007 Paul Davis
|
|
|
|
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#ifndef __ardour_gtk_log_meter_h__
|
|
|
|
#define __ardour_gtk_log_meter_h__
|
|
|
|
|
2006-12-16 00:14:34 -05:00
|
|
|
#if 1
|
2009-02-25 18:21:49 -05:00
|
|
|
static inline float
|
2005-09-25 14:42:24 -04:00
|
|
|
_log_meter (float power, double lower_db, double upper_db, double non_linearity)
|
|
|
|
{
|
|
|
|
return (power < lower_db ? 0.0 : pow((power-lower_db)/(upper_db-lower_db), non_linearity));
|
|
|
|
}
|
|
|
|
|
2009-02-25 18:21:49 -05:00
|
|
|
static inline float
|
2006-12-16 00:14:34 -05:00
|
|
|
alt_log_meter (float power)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
return _log_meter (power, -192.0, 0.0, 8.0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
inline float
|
|
|
|
log_meter (float db)
|
|
|
|
{
|
|
|
|
gfloat def = 0.0f; /* Meter deflection %age */
|
|
|
|
|
|
|
|
if (db < -70.0f) {
|
|
|
|
def = 0.0f;
|
|
|
|
} else if (db < -60.0f) {
|
|
|
|
def = (db + 70.0f) * 0.25f;
|
|
|
|
} else if (db < -50.0f) {
|
|
|
|
def = (db + 60.0f) * 0.5f + 2.5f;
|
|
|
|
} else if (db < -40.0f) {
|
|
|
|
def = (db + 50.0f) * 0.75f + 7.5f;
|
|
|
|
} else if (db < -30.0f) {
|
|
|
|
def = (db + 40.0f) * 1.5f + 15.0f;
|
|
|
|
} else if (db < -20.0f) {
|
|
|
|
def = (db + 30.0f) * 2.0f + 30.0f;
|
|
|
|
} else if (db < 6.0f) {
|
|
|
|
def = (db + 20.0f) * 2.5f + 50.0f;
|
|
|
|
} else {
|
|
|
|
def = 115.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 115 is the deflection %age that would be
|
|
|
|
when db=6.0. this is an arbitrary
|
|
|
|
endpoint for our scaling.
|
|
|
|
*/
|
|
|
|
|
|
|
|
return def/115.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __ardour_gtk_log_meter_h__ */
|