php-crossover-calculator/src/FirstOrderTwoWayCrossover.php

45 lines
1.0 KiB
PHP

<?php
use Components\Capacitor;
use Components\Inductor;
use Scientific\CrossoverSlope;
use Scientific\Frequency;
class FirstOrderTwoWayCrossover
{
private const PI = 3.1415926535;
private const TWO_PI = 2. * self::PI;
public function __construct(
private Frequency $frequency
)
{
}
public function getFrequency(): Frequency
{
return clone $this->frequency;
}
public function getSlope(): CrossoverSlope
{
return CrossoverSlope::fromDecibelPerOctave(6.);
}
public function getTweeterCapacitor(Driver $driver): Capacitor
{
$f = $this->getFrequency()->getValue()->unit();
$z = $driver->getImpedance()->getValue()->unit();
return new Capacitor(1. / (self::TWO_PI * $f * $z));
}
public function getWooferInductor(Driver $driver): Inductor
{
$f = $this->getFrequency()->getValue()->unit();
$z = $driver->getImpedance()->getValue()->unit();
return new Inductor($z / (self::TWO_PI * $f));
}
}