13
0

Adjust interpretation of swing amount

Previously,

0 -> no swing (1:1, 50%)
50 -> triplet swing (2:1, 66%)
75 -> hard swing (3:1, 75%)
100 -> sextuplet swing (5:1, 83%) (default!)
150 -> absolute maximum (inf:1, 100%)

This is rather confusing...

One common interpretation uses percentages of the beat, where triplet
swing is 66%. However, that causes precision issues since it's really
66.666...

Since we already default to 100 and take "no swing" as zero, let's make
that reference point triplet swing. Then the scale becomes:

0 -> no swing (1:1)
100 -> triplet swing (2:1)
150 -> hard swing (3:1)
200 -> sextuplet swing (5:1)
300 -> absolute maximum (inf:1)

300 doesn't make any sense, so let's change the range to -250 .. 250
which covers all useful values.

Also remove the division through 100 and back, to avoid rounding issues.

Signed-off-by: Asahi Lina <lina@asahilina.net>
This commit is contained in:
Asahi Lina 2023-09-09 19:48:43 +09:00
parent f1004a445e
commit d1cc71150f
2 changed files with 3 additions and 3 deletions

View File

@ -77,7 +77,7 @@ QuantizeDialog::QuantizeDialog (PublicEditor& e)
, strength_adjustment (100.0, 0.0, 100.0, 1.0, 10.0)
, strength_spinner (strength_adjustment)
, strength_label (_("Strength"))
, swing_adjustment (100.0, -130.0, 130.0, 1.0, 10.0)
, swing_adjustment (100.0, -250.0, 250.0, 1.0, 10.0)
, swing_spinner (swing_adjustment)
, swing_button (_("Swing"))
, threshold_adjustment (0.0, -Temporal::ticks_per_beat, Temporal::ticks_per_beat, 1.0, 10.0)

View File

@ -47,7 +47,7 @@ Quantize::Quantize (bool snap_start, bool snap_end,
, _start_grid(start_grid)
, _end_grid(end_grid)
, _strength (strength/100.0)
, _swing (swing/100.0)
, _swing (swing)
, _threshold (threshold)
{
}
@ -95,7 +95,7 @@ swing_position (Temporal::Beats pos, Temporal::Beats grid, double swing_strength
swung_previous_grid_position = Beats();
}
const ratio_t r (200 * swing_strength, 300);
const ratio_t r (swing_strength, 300);
if (swing_previous_grid_position) {
swung_previous_grid_position = swung_previous_grid_position + (grid * r);