comparison layer/ColourScale.cpp @ 1129:371320c9f8d9 spectrogram-minor-refactor

A threshold fix
author Chris Cannam
date Tue, 02 Aug 2016 09:09:58 +0100
parents 9fb8dfd7ce4c
children 4e7ed3252d80
comparison
equal deleted inserted replaced
1128:4e022a3e567b 1129:371320c9f8d9
17 17
18 #include "base/AudioLevel.h" 18 #include "base/AudioLevel.h"
19 #include "base/LogRange.h" 19 #include "base/LogRange.h"
20 20
21 #include <cmath> 21 #include <cmath>
22 #include <iostream>
23
24 using namespace std;
22 25
23 int ColourScale::m_maxPixel = 255; 26 int ColourScale::m_maxPixel = 255;
24 27
25 ColourScale::ColourScale(Parameters parameters) : 28 ColourScale::ColourScale(Parameters parameters) :
26 m_params(parameters), 29 m_params(parameters),
27 m_mapper(m_params.colourMap, 1.f, double(m_maxPixel)) 30 m_mapper(m_params.colourMap, 1.f, double(m_maxPixel))
28 { 31 {
29 if (m_params.minValue >= m_params.maxValue) { 32 if (m_params.minValue >= m_params.maxValue) {
33 cerr << "ERROR: ColourScale::ColourScale: minValue = "
34 << m_params.minValue << ", maxValue = " << m_params.maxValue << endl;
30 throw std::logic_error("maxValue must be greater than minValue"); 35 throw std::logic_error("maxValue must be greater than minValue");
31 } 36 }
32 37
33 m_mappedMin = m_params.minValue; 38 m_mappedMin = m_params.minValue;
34 m_mappedMax = m_params.maxValue; 39 m_mappedMax = m_params.maxValue;
54 std::swap(m_mappedMin, m_mappedMax); 59 std::swap(m_mappedMin, m_mappedMax);
55 } 60 }
56 } 61 }
57 62
58 if (m_mappedMin >= m_mappedMax) { 63 if (m_mappedMin >= m_mappedMax) {
64 cerr << "ERROR: ColourScale::ColourScale: minValue = " << m_params.minValue
65 << ", maxValue = " << m_params.maxValue
66 << ", threshold = " << m_params.threshold
67 << ", scale = " << int(m_params.scale)
68 << " resulting in mapped minValue = " << m_mappedMin
69 << ", mapped maxValue = " << m_mappedMax << endl;
59 throw std::logic_error("maxValue must be greater than minValue [after mapping]"); 70 throw std::logic_error("maxValue must be greater than minValue [after mapping]");
60 } 71 }
61 } 72 }
62 73
63 ColourScale::~ColourScale() 74 ColourScale::~ColourScale()