diff --git a/configure.sh b/configure.sh index 0fc5eb6..b8ea25a 100755 --- a/configure.sh +++ b/configure.sh @@ -8,5 +8,5 @@ elif [ "${1}" == "asan" ]; then (cd asan_build && cmake -G Ninja -DCMAKE_C_FLAGS='-fsanitize=address -fPIC' -DCMAKE_CXX_FLAGS='-fsanitize=address -fPIC' -DCMAKE_LINKER_FLAGS_DEBUG='-fsanitize=address' -DCMAKE_BUILD_TYPE=RelWithDebInfo ..) else mkdir -p build - (cd build && cmake -G Ninja -DCMAKE_C_FLAGS='-fPIC' -DCMAKE_CXX_FLAGS='-fPIC' -DCMAKE_BUILD_TYPE=Release ..) + (cd build && cmake -G Ninja -DCMAKE_C_FLAGS='-fPIC -mavx2' -DCMAKE_CXX_FLAGS='-fPIC -mavx2' -DCMAKE_BUILD_TYPE=Release ..) fi diff --git a/cpp/zimt/fourier_bank.cc b/cpp/zimt/fourier_bank.cc index d7b36d3..293c5eb 100644 --- a/cpp/zimt/fourier_bank.cc +++ b/cpp/zimt/fourier_bank.cc @@ -61,7 +61,7 @@ void Rotators::Filter(hwy::Span signal, OccasionallyRenormalize(); for (int64_t i = 0; i < signal.size(); ++i) { for (int k = 0; k < kNumRotators; ++k) { - int64_t delayed_ix = i - advance[k]; + int64_t delayed_ix = i - 7; // advance[k] * 0.2; float sample = 0; if (delayed_ix > 0) { sample = signal[delayed_ix]; @@ -72,14 +72,23 @@ void Rotators::Filter(hwy::Span signal, if (i >= max_delay_) { for (int k = 0; k < kNumRotators; ++k) { float amplitude = - std::sqrt(rot[2][k] * rot[2][k] + rot[3][k] * rot[3][k]); - channels[{out_ix}][k] = HardClip(amplitude); + std::sqrt(channel[0].accu[4][k] * channel[0].accu[4][k] + + channel[0].accu[5][k] * channel[0].accu[5][k]); + const float windowM1 = 1 - window[k]; + amplitude *= std::sqrt(windowM1) * windowM1; + channels[{out_ix}][k] = 2.2 * amplitude; } ++out_ix; } } } +double CalculateBandwidth(double low, double mid, double high) { + const double geo_mean_low = std::sqrt(low * mid); + const double geo_mean_high = std::sqrt(mid * high); + return std::abs(geo_mean_high - mid) + std::abs(mid - geo_mean_low); +} + Rotators::Rotators(int num_channels, std::vector frequency, std::vector filter_gains, const float sample_rate, float global_gain) { @@ -89,7 +98,10 @@ Rotators::Rotators(int num_channels, std::vector frequency, // of triple leaking integrator. float kWindow = 0.9996; float w40Hz = std::pow(kWindow, 128.0 / kNumRotators); // at 40 Hz. - window[i] = pow(w40Hz, std::max(1.0, frequency[i] / 40.0)); + float bw = CalculateBandwidth( + i == 0 ? frequency[1] : frequency[i - 1], frequency[i], + i + 1 == kNumRotators ? frequency[i - 1] : frequency[i + 1]); + window[i] = std::pow(kWindow, bw * 0.5 * 1.4); delay[i] = FindMedian3xLeaker(window[i]); float windowM1 = 1.0f - window[i]; max_delay_ = std::max(max_delay_, delay[i]); diff --git a/cpp/zimt/zimtohrli.h b/cpp/zimt/zimtohrli.h index bb83997..2941a07 100644 --- a/cpp/zimt/zimtohrli.h +++ b/cpp/zimt/zimtohrli.h @@ -283,7 +283,7 @@ struct Zimtohrli { // Sample rate corresponding to the human hearing sensitivity to timing // differences. - float perceptual_sample_rate = 100.0; + float perceptual_sample_rate = 85.0; // The filterbank used to separate the signal in frequency channels. std::optional cam_filterbank; diff --git a/go/data/study.go b/go/data/study.go index 8891bae..84245e4 100644 --- a/go/data/study.go +++ b/go/data/study.go @@ -210,7 +210,7 @@ func (c CorrelationTable) String() string { sort.Sort(scores) for _, score := range scores { if score.ScoreTypeB != MOS { - listResult = append(listResult, Row{string(score.ScoreTypeB), fmt.Sprintf("%.2f", score.Score)}) + listResult = append(listResult, Row{string(score.ScoreTypeB), fmt.Sprintf("%.15f", score.Score)}) } } } diff --git a/go/goohrli/goohrli.a b/go/goohrli/goohrli.a index edc2caa..867a034 100644 Binary files a/go/goohrli/goohrli.a and b/go/goohrli/goohrli.a differ