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@1581
|
16 #ifndef SV_LOG_RANGE_H
|
Chris@1581
|
17 #define SV_LOG_RANGE_H
|
Chris@224
|
18
|
Chris@478
|
19 #include <vector>
|
Chris@687
|
20 #include "Debug.h"
|
Chris@478
|
21
|
Chris@224
|
22 class LogRange
|
Chris@224
|
23 {
|
Chris@224
|
24 public:
|
Chris@224
|
25 /**
|
Chris@224
|
26 * Map a value onto a logarithmic range. This just means taking
|
Chris@224
|
27 * the base-10 log of the absolute value, or using the threshold
|
Chris@224
|
28 * value if the absolute value is zero.
|
Chris@224
|
29 */
|
Chris@1044
|
30 static double map(double value, double thresh = -10);
|
Chris@266
|
31
|
Chris@266
|
32 /**
|
Chris@266
|
33 * Map a value from the logarithmic range back again. This just
|
Chris@266
|
34 * means taking the value'th power of ten.
|
Chris@266
|
35 */
|
Chris@1044
|
36 static double unmap(double value);
|
Chris@478
|
37
|
Chris@478
|
38 /**
|
Chris@1392
|
39 * Map a linear range onto a logarithmic range. min and max are
|
Chris@1392
|
40 * passed as the extents of the linear range and returned as the
|
Chris@1392
|
41 * extents of the logarithmic range. thresh is the minimum value
|
Chris@1392
|
42 * for the log range, to be used if the linear range spans zero.
|
Chris@1392
|
43 */
|
Chris@1392
|
44 static void mapRange(double &min, double &max, double thresh = -10);
|
Chris@1392
|
45
|
Chris@1392
|
46 /**
|
Chris@478
|
47 * Estimate whether a set of values would be more properly shown
|
Chris@478
|
48 * using a logarithmic than a linear scale. This is only ever
|
Chris@478
|
49 * going to be a rough guess.
|
Chris@478
|
50 */
|
Chris@1392
|
51 static bool shouldUseLogScale(std::vector<double> values);
|
Chris@478
|
52
|
Chris@224
|
53 };
|
Chris@224
|
54
|
Chris@224
|
55 #endif
|