summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorandreas128 <Andreas>2017-04-01 10:17:06 +0100
committerandreas128 <Andreas>2017-04-01 10:17:06 +0100
commit6243a4fac50a9c8690e13c2df65c058e69fdcae5 (patch)
tree8e562b11f06a782974bd4d34b2f58005a3903fda /src
parentfce4eab342a5e4bfad01c5f7e704ece35bd718bc (diff)
parent8a5b4f23dec7d22e4f2e38cb7ef7223438461df8 (diff)
downloaddabmod-6243a4fac50a9c8690e13c2df65c058e69fdcae5.tar.gz
dabmod-6243a4fac50a9c8690e13c2df65c058e69fdcae5.tar.bz2
dabmod-6243a4fac50a9c8690e13c2df65c058e69fdcae5.zip
Merge branch 'next' into next_memless
Diffstat (limited to 'src')
-rw-r--r--src/DabMod.cpp14
-rw-r--r--src/Resampler.cpp4
2 files changed, 16 insertions, 2 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index 301b078..4e4cdab 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -81,6 +81,11 @@
*/
static const float normalise_factor = 50000.0f;
+//Empirical normalisation factors used to normalise the samples to amplitude 1.
+static const float normalise_factor_file_fix = 81000.0f;
+static const float normalise_factor_file_var = 46000.0f;
+static const float normalise_factor_file_max = 46000.0f;
+
typedef std::complex<float> complexf;
using namespace std;
@@ -183,6 +188,15 @@ static shared_ptr<ModOutput> prepare_output(
if (s.fileOutputFormat == "complexf") {
output = make_shared<OutputFile>(s.outputName);
}
+ if (s.fileOutputFormat == "complexf_normalised") {
+ if (s.gainMode == GainMode::GAIN_FIX)
+ s.normalise = 1.0 / normalise_factor_file_fix;
+ else if (s.gainMode == GainMode::GAIN_MAX)
+ s.normalise = 1.0 / normalise_factor_file_max;
+ else if (s.gainMode == GainMode::GAIN_VAR)
+ s.normalise = 1.0 / normalise_factor_file_var;
+ output = make_shared<OutputFile>(s.outputName);
+ }
else if (s.fileOutputFormat == "s8") {
// We must normalise the samples to the interval [-127.0; 127.0]
s.normalise = 127.0f / normalise_factor;
diff --git a/src/Resampler.cpp b/src/Resampler.cpp
index ee2b865..8786e91 100644
--- a/src/Resampler.cpp
+++ b/src/Resampler.cpp
@@ -76,9 +76,9 @@ Resampler::Resampler(size_t inputRate, size_t outputRate, size_t resolution) :
PDEBUG(" FFT size in: %zu, FFT size out: %zu\n", myFftSizeIn, myFftSizeOut);
if (myFftSizeIn > myFftSizeOut) {
- myFactor = 1.0f / myFftSizeIn;
+ myFactor = 1.0f / myFftSizeIn * outputRate / inputRate;
} else {
- myFactor = 1.0f / myFftSizeOut;
+ myFactor = 1.0f / myFftSizeOut * outputRate / inputRate;
}
myWindow = (float*)memalign(16, myFftSizeIn * sizeof(float));