Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Bruse committed May 27, 2024
1 parent 872b1cb commit daf4cb9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 16 additions & 4 deletions cpp/zimt/fourier_bank.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void Rotators::Filter(hwy::Span<const float> 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];
Expand All @@ -72,14 +72,23 @@ void Rotators::Filter(hwy::Span<const float> 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<float> frequency,
std::vector<float> filter_gains, const float sample_rate,
float global_gain) {
Expand All @@ -89,7 +98,10 @@ Rotators::Rotators(int num_channels, std::vector<float> 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]);
Expand Down
2 changes: 1 addition & 1 deletion cpp/zimt/zimtohrli.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<CamFilterbank> cam_filterbank;
Expand Down
2 changes: 1 addition & 1 deletion go/data/study.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)})
}
}
}
Expand Down
Binary file modified go/goohrli/goohrli.a
Binary file not shown.

0 comments on commit daf4cb9

Please sign in to comment.