Skip to content

Commit

Permalink
Merge pull request #120 from jyrkialakuijala/tabuli
Browse files Browse the repository at this point in the history
7-8 % improvement
  • Loading branch information
jyrkialakuijala authored Jul 8, 2024
2 parents b9fbd50 + d67c2cc commit a3dbc16
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
43 changes: 28 additions & 15 deletions cpp/zimt/fourier_bank.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@ float Loudness(int k, float val) {
{ 0.354, -3.5, 12.3, }, // 12500
};
const float *vals = &pars[k / 5][0];
static float constant1 = 33.10987678814273;
static float constant2 = 27.720606627666342;
static float constant1 = 48.70343225300608;
static float constant2 = 40.43827165462807;
static const float kMul = -2.7207126528654677;
val += kMul * vals[2];
val *= (constant1 + vals[1]) * (1.0 / constant2);
return val;
}

float SimpleDb(float energy) {
// ideally 78.3 db
static const float full_scale_sine_db = 77.47500423191678;
static const float full_scale_sine_db = 77.39771094914877;
static const float exp_full_scale_sine_db = exp(full_scale_sine_db);
// epsilon, but the biggest one you saw (~4.95e23)
static const float epsilon = 1.0033294789821357e-09 * exp_full_scale_sine_db;
Expand All @@ -75,23 +77,34 @@ void FinalizeDb(hwy::AlignedNDArray<float, 2>& channels, float mul,
static const double octaves_in_20_to_20000 = log(20000/20.)/log(2);
static const double octaves_per_rot =
octaves_in_20_to_20000 / float(kNumRotators - 1);
static const double masker_step_per_octave_up_0 = 16.495427054351488;
static const double masker_step_per_octave_up_1 = 22.552019717473833;
static const double masker_step_per_octave_up_2 = 20.082159717473832;
static const double masker_step_per_octave_up_0 = 19.53945781131615;
static const double masker_step_per_octave_up_1 = 24.714118008386887;
static const double masker_step_per_octave_up_2 = 6.449301354309956;
static const double masker_step_per_rot_up_0 = octaves_per_rot * masker_step_per_octave_up_0;
static const double masker_step_per_rot_up_1 = octaves_per_rot * masker_step_per_octave_up_1;
static const double masker_step_per_rot_up_2 = octaves_per_rot * masker_step_per_octave_up_2;
static const double masker_gap_up = 19.140338374861235;
static const float maskingStrengthUp = 0.1252262923615547;
static const float up_blur = 0.8738593591692092;
static const double masker_gap_up = 21.309406898722074;
static const float maskingStrengthUp = 0.2056434702527141;
static const float up_blur = 0.9442717063037425;
static const float fraction_up = 1.1657467617827404;

static const double masker_step_per_octave_down = 42.41172783112732;
static const double masker_step_per_octave_down = 53.40273959309446;
static const double masker_step_per_rot_down = octaves_per_rot * masker_step_per_octave_down;
static const double masker_gap_down = 19.59079250393617;
static const float maskingStrengthDown = 0.19329999999999992;
static const float down_blur = 0.714425315233319;
static const double masker_gap_down = 19.08401096304284;
static const float maskingStrengthDown = 0.18030917038808858;
static const float down_blur = 0.7148792180987857;

static const float min_limit = -11.3968870989223;
static const float fraction_down = 1.0197608300379997;

static const float temporal0 = 0.09979167061501665;
static const float temporal1 = 0.14429505133534495;
static const float temporal2 = 0.009228598592129168;
static float weightp = 0.1792443302507868;
static float weightm = 0.7954490998745948;

static float mask_k = 0.08709005149742773;

static const float min_limit = -11.397341001787765;
// Scan frequencies from bottom to top, let lower frequencies to mask higher frequencies.
// 'masker' maintains the masking envelope from one bin to next.
static const float temporal_masker0 = 0.13104546362447728;
Expand Down Expand Up @@ -226,7 +239,7 @@ Rotators::Rotators(int num_channels, std::vector<float> frequency,
window[i] = std::pow(kWindow, bw * kBandwidthMagic);
float windowM1 = 1.0f - window[i];
float f = frequency[i] * 2.0f * M_PI / sample_rate;
static const float full_scale_sine_db = exp(75.27901963526045);
static const float full_scale_sine_db = exp(75.27858635739499);
const float gainer = 2.0f * sqrt(full_scale_sine_db);
gain[i] = gainer * filter_gains[i] * pow(windowM1, 3.0);
rot[0][i] = float(std::cos(f));
Expand Down
4 changes: 2 additions & 2 deletions cpp/zimt/nsim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ float HwyNSIM(const hwy::AlignedNDArray<float, 2>& a,
return Mul(delta_a, delta_b);
});
const Vec two = Set(d, 2.0);
const Vec C1 = Set(d, 0.1);
const Vec C3 = Set(d, 0.1);
const Vec C1 = Set(d, 0.17973327786546683);
const Vec C3 = Set(d, 0.18526360286546675);
float nsim_sum = 0.0;
const Vec num_channels_vec = Set(d, num_channels);
const Vec zero = Zero(d);
Expand Down
2 changes: 1 addition & 1 deletion cpp/zimt/zimtohrli.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ struct Zimtohrli {
size_t nsim_step_window = 16;

// The window in channels when computing the NSIM.
size_t nsim_channel_window = 32;
size_t nsim_channel_window = 30;

// The window of the dynamic time warp that matches audio signals.
//
Expand Down

0 comments on commit a3dbc16

Please sign in to comment.