summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-04-10 17:54:34 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2021-04-11 18:02:46 +0200
commita10ed70b7b71b7c72e8885da52065d959af3505b (patch)
tree8dca70d0b71a0be2f167c8edba403ad84f67dc29
parentfcfaa7affa0ac8afeaf38346226beb30fca09733 (diff)
Amortize the perceived sample power of normalized vs non-normalized samples.
-rw-r--r--src/Makefile.am2
-rw-r--r--src/inputprocessor.cc5
2 files changed, 5 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index b656f48..6278ecb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -36,7 +36,7 @@ libdg_la_CPPFLAGS = \
$(SNDFILE_CFLAGS) $(PTHREAD_CFLAGS)
libdg_la_LIBADD = \
- $(SNDFILE_LIBS) $(PTHREAD_LIBS) libzr.la libpugi.la
+ $(SNDFILE_LIBS) $(PTHREAD_LIBS) libzr.la libpugi.la -lm
libdg_la_SOURCES = \
audiocachefile.cc \
diff --git a/src/inputprocessor.cc b/src/inputprocessor.cc
index 4bafb1d..19e76a5 100644
--- a/src/inputprocessor.cc
+++ b/src/inputprocessor.cc
@@ -27,6 +27,7 @@
#include "inputprocessor.h"
#include <list>
+#include <cmath>
#include <hugin.hpp>
@@ -285,7 +286,9 @@ bool InputProcessor::processOnset(event_t& event, std::size_t pos,
event_sample.offset = (event.offset + pos) * resample_ratio;
if(settings.normalized_samples.load() && sample->getNormalized())
{
- event_sample.scale *= event.velocity;
+ // To amortize with the non-normalized perceived sample power
+ // the velocity is square-rooted.
+ event_sample.scale *= std::sqrt(event.velocity);
}
}
}