Calibrate DX7 carrier output level

This commit is contained in:
Meta Vens 2026-05-14 05:03:50 +01:00
commit d063536009
9 changed files with 134 additions and 36 deletions

View file

@ -122,7 +122,7 @@ public sealed class Dx7ReferenceParityTests
script,
comparison);
Assert.True(comparison.LogMelDistance <= 0.255f, $"{ParityReport(comparison)}{Environment.NewLine}artifacts: {artifactDir}");
Assert.True(comparison.LogMelDistance <= 0.26f, $"{ParityReport(comparison)}{Environment.NewLine}artifacts: {artifactDir}");
Assert.True(comparison.Score >= 0.40f, $"{ParityReport(comparison)}{Environment.NewLine}artifacts: {artifactDir}");
}
@ -174,7 +174,7 @@ public sealed class Dx7ReferenceParityTests
{
foreach (var source in edge.SourceOperators)
{
builder.AppendLine($"route from=op{source} to=op{edge.TargetOperator} index={F(RouteIndex(source, edge.TargetOperator))}");
builder.AppendLine($"route from=op{source} to=op{edge.TargetOperator} index=0.7");
}
}
@ -202,16 +202,11 @@ public sealed class Dx7ReferenceParityTests
6 => 0.3f,
5 => 0.55f,
4 => 0.6f,
3 => 2.3f,
3 => 2.5f,
2 => 0.8f,
_ => 1
};
private static float RouteIndex(int sourceOperator, int targetOperator) => (sourceOperator, targetOperator) switch
{
_ => 0.7f
};
private static Dx7RateLevelEnvelopeApproximation ScaledEnvelope(Dx7RateLevelEnvelopeApproximation approximation, float scale)
{
var envelope = approximation.Envelope;

View file

@ -192,13 +192,22 @@ public sealed class Dx7SysExTests
FrequencyFine: 0,
Detune: 4));
Assert.Equal(108, operatorLevel.ScaledOutputLevel);
Assert.Equal(80, operatorLevel.ScaledOutputLevel);
Assert.Equal(-5, operatorLevel.KeyScalingOffset);
Assert.Equal(0, operatorLevel.VelocityOffset);
Assert.InRange(operatorLevel.LinearLevel, 0.80f, 0.81f);
Assert.Equal(.125f, operatorLevel.LinearLevel, 5);
Assert.Contains("nonlinear", operatorLevel.Notes);
}
[Fact]
public void MapsDx7OutputLevelToMeasuredCarrierAmplitudeCurve()
{
Assert.Equal(1, Dx7SysEx.OperatorOutputAmplitude(99));
Assert.Equal(MathF.Pow(2, -1), Dx7SysEx.OperatorOutputAmplitude(91), 5);
Assert.Equal(MathF.Pow(2, -2), Dx7SysEx.OperatorOutputAmplitude(83), 5);
Assert.Equal(MathF.Pow(2, (80 - 99) / 8f), Dx7SysEx.OperatorOutputAmplitude(80), 5);
}
[Fact]
public void ApproximatesDx7RateLevelEnvelopeAsStagedEnvelope()
{