annotate base/LogRange.h @ 280:daf89d31f45c

* Restore Scale setting which had mistakenly disappeared from spectrum * Some tweaks to spectrum peaks * Make spectrum default to 4096/75%... or is that overdoing it? * Show harmonic cursor even during playback if in measure mode and mouse in relevant pane * Avoid crash when trying to measure a non-layer * Various adjustments to some icons to make them look better in white-on-black schemes
author Chris Cannam
date Fri, 13 Jul 2007 15:54:17 +0000
parents 2268963dabd1
children 1405f4a2caf3
rev   line source
Chris@224 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@224 2
Chris@224 3 /*
Chris@224 4 Sonic Visualiser
Chris@224 5 An audio file viewer and annotation editor.
Chris@224 6 Centre for Digital Music, Queen Mary, University of London.
Chris@224 7 This file copyright 2006 Chris Cannam.
Chris@224 8
Chris@224 9 This program is free software; you can redistribute it and/or
Chris@224 10 modify it under the terms of the GNU General Public License as
Chris@224 11 published by the Free Software Foundation; either version 2 of the
Chris@224 12 License, or (at your option) any later version. See the file
Chris@224 13 COPYING included with this distribution for more information.
Chris@224 14 */
Chris@224 15
Chris@224 16 #ifndef _LOG_RANGE_H_
Chris@224 17 #define _LOG_RANGE_H_
Chris@224 18
Chris@224 19 class LogRange
Chris@224 20 {
Chris@224 21 public:
Chris@224 22 /**
Chris@224 23 * Map a linear range onto a logarithmic range. min and max are
Chris@224 24 * passed as the extents of the linear range and returned as the
Chris@224 25 * extents of the logarithmic range. thresh is the minimum value
Chris@224 26 * for the log range, to be used if the linear range spans zero.
Chris@224 27 */
Chris@224 28 static void mapRange(float &min, float &max, float thresh = -10);
Chris@224 29
Chris@224 30 /**
Chris@224 31 * Map a value onto a logarithmic range. This just means taking
Chris@224 32 * the base-10 log of the absolute value, or using the threshold
Chris@224 33 * value if the absolute value is zero.
Chris@224 34 */
Chris@224 35 static float map(float value, float thresh = -10);
Chris@266 36
Chris@266 37 /**
Chris@266 38 * Map a value from the logarithmic range back again. This just
Chris@266 39 * means taking the value'th power of ten.
Chris@266 40 */
Chris@266 41 static float unmap(float value);
Chris@224 42 };
Chris@224 43
Chris@224 44 #endif