|
From: Yoda-JM <yo...@us...> - 2011-01-13 11:02:55
|
Module: editor
Branch: master
Commit: 8ab8ee5e6e7e214bd5f9d325ad7894c86ddd7b76
Author: Vincent Le Ligeour <yo...@us...>
Date: Thu Jan 13 12:02:34 2011 +0100
Hacked some visualization stuff
---
pitchvis.cc | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/pitchvis.cc b/pitchvis.cc
index 2124fb4..441db92 100644
--- a/pitchvis.cc
+++ b/pitchvis.cc
@@ -38,6 +38,7 @@ PitchVis::PitchVis(std::string const& filename): height(1024) {
analyzer.input(data.begin() + x * step, data.begin() + (x + 1) * step);
analyzer.process();
+ /*
Analyzer::Peaks peaks = analyzer.getPeaks();
for (unsigned i = 0; i < peaks.size(); ++i) {
unsigned y = height - static_cast<unsigned>(16.0 * scale.getNote(peaks[i].freq));
@@ -52,19 +53,33 @@ PitchVis::PitchVis(std::string const& filename): height(1024) {
(*this)(x, y + 1) += p;
(*this)(x, y - 1) += p;
}
+ */
Analyzer::Tones tones = analyzer.getTones();
- for (Analyzer::Tones::const_iterator it = tones.begin(), itend = tones.end(); it != itend; ++it) {
- unsigned y = height - static_cast<unsigned>(16.0 * scale.getNote(it->freq));
+ unsigned int i = 0;
+ for (Analyzer::Tones::const_iterator it = tones.begin(), itend = tones.end(); it != itend && i < 3; ++it) {
+ unsigned y = height - static_cast<unsigned>(16.0 * scale.getNoteId(it->freq));
if (y == 0 || y >= height - 1) continue;
float value = 0.003 * (it->db + 80.0);
if (value <= 0.0) continue;
Pixel p(value, value, value);
+ switch(i) {
+ case 0:
+ p.r = 0.0; p.g = 1.0; p.b = 0.0;
+ break;
+ case 1:
+ p.r = 0.0; p.g = 0.5; p.b = 0.0;
+ break;
+ case 2:
+ p.r = 0.0; p.g = 0.3; p.b = 0.0;
+ break;
+ }
(*this)(x, y) += p;
p.r *= 0.5;
p.g *= 0.5;
p.b *= 0.5;
(*this)(x, y + 1) += p;
(*this)(x, y - 1) += p;
+ ++i;
}
}
progress.setValue(width);
|