aqua-feel: review fixes (attack on low tones, disarmed guards, bounded waivers, drift test)

- attack: peak-hold envelope and a 150 ms window; a 261 Hz tone no longer reads its
  first half-cycle as the attack (warm-bell 0.67 ms -> 3.8 ms, declared 4 ms).
- gate: a rule whose id matches no item fails a full run; waivers carry a bound and
  cover only up to it; a missing metric fails its rule; silent items fail once;
  --only runs gate as partial; silent threshold is -70 dBFS.
- DingCatalogTests: lowered Dings fed to the meter must match the catalog.
- README states NTR window/Q dependence, short-buffer loudness padding and the assumed
  Ding command gain; faust-toolchain-boundary notes the v5 manifest predates the mix change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Aqua 2026-11-05 15:42:13 +00:00
commit 1bf99e5c3f
9 changed files with 173 additions and 59 deletions

View file

@ -1,3 +1,4 @@
using System.Text.Json;
using AquaSynth.Dings;
namespace AquaSynth.Dsl.Tests;
@ -32,4 +33,37 @@ public sealed class DingCatalogTests
foreach (var pair in dingEvent.Notes.Zip(dingEvent.Notes.Skip(1)))
Assert.InRange(pair.Second.DelayMilliseconds - pair.First.DelayMilliseconds, 180, 320);
}
// tools/aqua-feel measures the lowered files in tools/aqua-feel/lowered-dings; regenerate them with
// `dotnet run --project tools/AquaLower -- --dings tools/aqua-feel/lowered-dings` when the catalog changes.
[Fact]
public void LoweredDingsFedToTheFeelMeterMatchTheCatalog()
{
var dir = Path.Combine(RepositoryRoot(), "tools", "aqua-feel", "lowered-dings");
foreach (var instrument in DingCatalog.Instruments.Values)
{
var expected = FaustEmitter.EmitScript(instrument.Script, new FaustExportOptions("dings_" + instrument.Id.Replace('-', '_'))).Source;
Assert.Equal(expected, File.ReadAllText(Path.Combine(dir, instrument.Id + ".dsp")));
}
using var doc = JsonDocument.Parse(File.ReadAllText(Path.Combine(dir, "dings.json")));
var instruments = doc.RootElement.GetProperty("instruments").EnumerateArray().ToDictionary(e => e.GetProperty("id").GetString()!);
Assert.Equal(DingCatalog.Instruments.Keys.Order(), instruments.Keys.Order());
foreach (var instrument in DingCatalog.Instruments.Values)
Assert.Equal(instrument.RootFrequency, instruments[instrument.Id].GetProperty("rootFrequency").GetSingle());
var events = doc.RootElement.GetProperty("events").EnumerateArray().ToDictionary(e => e.GetProperty("id").GetString()!);
Assert.Equal(DingCatalog.Events.Keys.Order(), events.Keys.Order());
foreach (var ev in DingCatalog.Events.Values)
{
var notes = events[ev.Id].GetProperty("notes").EnumerateArray().Select(n => (n.GetProperty("semitones").GetDouble(), n.GetProperty("delayMilliseconds").GetInt32(), n.GetProperty("gain").GetSingle())).ToArray();
Assert.Equal(ev.Notes.Select(n => (n.Semitones, n.DelayMilliseconds, n.Gain)).ToArray(), notes);
}
}
private static string RepositoryRoot()
{
var dir = new DirectoryInfo(AppContext.BaseDirectory);
while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "AquaSynth.sln"))) dir = dir.Parent;
return dir?.FullName ?? throw new InvalidOperationException("AquaSynth.sln not found above the test binaries.");
}
}