summaryrefslogtreecommitdiff
path: root/src/specgram.cpp
diff options
context:
space:
mode:
authorVasile Vilvoiu <vasi@vilvoiu.ro>2021-07-16 21:00:28 +0300
committerVasile Vilvoiu <vasi@vilvoiu.ro>2021-07-16 21:00:28 +0300
commit68e6ebe24cb476997b2ddfc21a5b13fb6f332fa7 (patch)
tree646db708a2db1b61904003c81a05b01358cdb4cc /src/specgram.cpp
parentb13609afcdf66d781db70fb75f6869a052a49079 (diff)
Render texture onto window on each iteration.
Keep colormap in renderer so we don't pass the colormapped windows like animals. Pre-render empty window. Fixes #15.
Diffstat (limited to 'src/specgram.cpp')
-rw-r--r--src/specgram.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/specgram.cpp b/src/specgram.cpp
index cb646fc..d70126f 100644
--- a/src/specgram.cpp
+++ b/src/specgram.cpp
@@ -165,6 +165,7 @@ main(int argc, char** argv)
std::unique_ptr<LiveOutput> live = nullptr;
if (conf.IsLive()) {
live = std::make_unique<LiveOutput>(conf, *color_map, *value_map);
+ live->Render(); /* render empty window */
}
/* create input parser */
@@ -218,7 +219,7 @@ main(int argc, char** argv)
/* main loop */
while (main_loop_running && !reader->ReachedEOF()) {
- /* check for window events (if necessary) */
+ /* check for window events (if necessary) and redraw */
if (live != nullptr) {
if (!live->HandleEvents()) {
/* exited by closing window */
@@ -226,6 +227,7 @@ main(int argc, char** argv)
/* uninstall signal so that reader thread can exit successfully */
std::signal(SIGINT, nullptr);
}
+ live->Render();
}
/* check for a complete block */
@@ -282,7 +284,7 @@ main(int argc, char** argv)
assert(window_sum.size() == normalized_magnitude.size());
assert(conf.GetAverageCount() > 0);
for (std::size_t i = 0; i < window_sum.size(); i++) {
- window_sum[i] += normalized_magnitude[i] / conf.GetAverageCount();
+ window_sum[i] += normalized_magnitude[i] / (double)conf.GetAverageCount();
}
window_sum_count++;
@@ -291,17 +293,14 @@ main(int argc, char** argv)
continue;
}
- /* colorize FFT */
- auto colorized = color_map->Map(window_sum);
-
/* add to live */
if (live != nullptr) {
- live->AddWindow(colorized, window_sum);
- }
-
- /* add to history */
- if (have_output) {
- history.push_back(colorized);
+ auto colorized = live->AddWindow(window_sum);
+ if (have_output) {
+ history.push_back(colorized);
+ }
+ } else if (have_output) {
+ history.push_back(color_map->Map(window_sum));
}
/* reset */