comparison src/Analyser.cpp @ 145:cdc9d5f7978c

Optional spectrogram (off by default)
author Chris Cannam
date Fri, 10 Jan 2014 16:06:07 +0000
parents e7f2da26c9ac
children e1a2c175a0e0
comparison
equal deleted inserted replaced
144:c21b87a62ce6 145:cdc9d5f7978c
26 #include "layer/TimeValueLayer.h" 26 #include "layer/TimeValueLayer.h"
27 #include "layer/NoteLayer.h" 27 #include "layer/NoteLayer.h"
28 #include "layer/FlexiNoteLayer.h" 28 #include "layer/FlexiNoteLayer.h"
29 #include "layer/WaveformLayer.h" 29 #include "layer/WaveformLayer.h"
30 #include "layer/ColourDatabase.h" 30 #include "layer/ColourDatabase.h"
31 #include "layer/ColourMapper.h"
31 #include "layer/LayerFactory.h" 32 #include "layer/LayerFactory.h"
33 #include "layer/SpectrogramLayer.h"
32 34
33 #include <QSettings> 35 #include <QSettings>
34 36
35 Analyser::Analyser() : 37 Analyser::Analyser() :
36 m_document(0), 38 m_document(0),
42 settings.beginGroup("LayerDefaults"); 44 settings.beginGroup("LayerDefaults");
43 settings.setValue 45 settings.setValue
44 ("timevalues", 46 ("timevalues",
45 QString("<layer verticalScale=\"%1\" plotStyle=\"%2\" " 47 QString("<layer verticalScale=\"%1\" plotStyle=\"%2\" "
46 "scaleMinimum=\"%3\" scaleMaximum=\"%4\"/>") 48 "scaleMinimum=\"%3\" scaleMaximum=\"%4\"/>")
47 .arg(int(TimeValueLayer::LogScale)) 49 .arg(int(TimeValueLayer::AutoAlignScale))
48 .arg(int(TimeValueLayer::PlotDiscreteCurves)) 50 .arg(int(TimeValueLayer::PlotDiscreteCurves))
49 .arg(27.5f).arg(880.f)); // temporary values: better get the real extents of the data from the model 51 .arg(27.5f).arg(880.f)); // temporary values: better get the real extents of the data from the model
50 settings.setValue 52 settings.setValue
51 ("flexinotes", 53 ("flexinotes",
52 QString("<layer verticalScale=\"%1\"/>") 54 QString("<layer verticalScale=\"%1\"/>")
73 QString noteout = "notes"; 75 QString noteout = "notes";
74 76
75 // We need at least one main-model layer (time ruler, waveform or 77 // We need at least one main-model layer (time ruler, waveform or
76 // what have you). It could be hidden if we don't want to see it 78 // what have you). It could be hidden if we don't want to see it
77 // but it must exist. 79 // but it must exist.
80
81 // A spectrogram, off by default. Must go at the back because it's
82 // opaque
83
84 SpectrogramLayer *spectrogram = qobject_cast<SpectrogramLayer *>
85 (m_document->createMainModelLayer(LayerFactory::MelodicRangeSpectrogram));
86 spectrogram->setColourMap((int)ColourMapper::BlackOnWhite);
87 m_document->addLayerToView(m_pane, spectrogram);
88 spectrogram->setLayerDormant(m_pane, true);
89
90 m_layers[Spectrogram] = spectrogram;
78 91
79 // Our waveform layer is just a shadow, light grey and taking up 92 // Our waveform layer is just a shadow, light grey and taking up
80 // little space at the bottom 93 // little space at the bottom
81 94
82 WaveformLayer *waveform = qobject_cast<WaveformLayer *> 95 WaveformLayer *waveform = qobject_cast<WaveformLayer *>
164 } 177 }
165 178
166 loadState(Audio); 179 loadState(Audio);
167 loadState(PitchTrack); 180 loadState(PitchTrack);
168 loadState(Notes); 181 loadState(Notes);
182 loadState(Spectrogram);
169 183
170 emit layersChanged(); 184 emit layersChanged();
171 185
172 return ""; 186 return "";
173 } 187 }
198 { 212 {
199 bool v = isVisible(c); 213 bool v = isVisible(c);
200 bool a = isAudible(c); 214 bool a = isAudible(c);
201 QSettings settings; 215 QSettings settings;
202 settings.beginGroup("Analyser"); 216 settings.beginGroup("Analyser");
203 settings.setValue(QString("Visibility %1").arg(int(c)), v); 217 settings.setValue(QString("visible-%1").arg(int(c)), v);
204 settings.setValue(QString("Audibility %1").arg(int(c)), a); 218 settings.setValue(QString("audible-%1").arg(int(c)), a);
205 settings.endGroup(); 219 settings.endGroup();
206 } 220 }
207 221
208 void 222 void
209 Analyser::loadState(Component c) 223 Analyser::loadState(Component c)
210 { 224 {
211 QSettings settings; 225 QSettings settings;
212 settings.beginGroup("Analyser"); 226 settings.beginGroup("Analyser");
213 bool v = settings.value(QString("Visibility %1").arg(int(c)), true).toBool(); 227 bool deflt = (c == Spectrogram ? false : true);
214 bool a = settings.value(QString("Audibility %1").arg(int(c)), true).toBool(); 228 bool v = settings.value(QString("visible-%1").arg(int(c)), deflt).toBool();
229 bool a = settings.value(QString("audible-%1").arg(int(c)), true).toBool();
215 settings.endGroup(); 230 settings.endGroup();
216 setVisible(c, v); 231 setVisible(c, v);
217 setAudible(c, a); 232 setAudible(c, a);
218 } 233 }
219 234