Skip to content

Instantly share code, notes, and snippets.

@Joehoel
Created November 26, 2025 07:53
Show Gist options
  • Select an option

  • Save Joehoel/7bfdd2c8f2d7908d464fa91f6b052ded to your computer and use it in GitHub Desktop.

Select an option

Save Joehoel/7bfdd2c8f2d7908d464fa91f6b052ded to your computer and use it in GitHub Desktop.
Afschatting configuratie
<?php
public function config(): array
{
// Frequencies mirror the original Pascal implementation:
// 0.5, 1, 2, and 4 kHz.
$frequencies = [0.5, 1.0, 2.0, 4.0];
// Base levels (in dB HL) follow the original
// Loss array: (30, 40, 50, 60).
$baseLevels = [
HearingLossSize::Light->value => 30,
HearingLossSize::LightModerate->value => 40,
HearingLossSize::Moderate->value => 50,
HearingLossSize::ModerateSevere->value => 60,
];
// Shape offsets (in dB) approximate the original profiles
// ("Oplopend", "Vlak", "Aflopend", "Komvormig") for 0.5, 1, 2, 4 kHz:
//
// - Ascending (Oplopend): loss increases towards higher frequencies.
// - Flat (Vlak): same loss at all frequencies.
// - Descending (Aflopend): loss decreases towards higher frequencies.
// - Bowl-shaped (Komvormig): mid / high frequencies differ from low.
//
// The actual thresholds per frequency are obtained on the front end as
// baseLevels[size] + shapeOffsets[shape][index], and then clamped to
// the chart's Y-axis domain.
$shapeOffsets = [
HearingLossShape::Flat->value => [0, 0, 0, 0],
HearingLossShape::Ascending->value => [-10, 0, 10, 20],
HearingLossShape::Descending->value => [10, 0, -10, -20],
HearingLossShape::BowlShaped->value => [-10, 0, -10, -20],
];
return [
'frequencies' => $frequencies,
'baseLevels' => $baseLevels,
'shapeOffsets' => $shapeOffsets,
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment