php-crossover-calculator/bin/app.php

36 lines
889 B
PHP
Raw Permalink Normal View History

2021-04-29 21:58:02 +02:00
<?php
// http://enjoythemusic.com/diy/0311/crossover.htm
use Scientific\Frequency;
use Scientific\Impedance;
require_once __DIR__ . '/../vendor/autoload.php';
$frequency = new Frequency(unit(9000));
$tweeter = new Driver(new Impedance(unit(8)));
$woofer = new Driver(new Impedance(unit(4)));
$crossover = new FirstOrderTwoWayCrossover($frequency);
$capacitor = $crossover->getTweeterCapacitor($tweeter);
$inductor = $crossover->getWooferInductor($woofer);
printf(
'First order 2-way crossover @ %s (slope = %s):%s',
$crossover->getFrequency(),
$crossover->getSlope(),
PHP_EOL
);
printf(
' - %s capacitor in series with %s tweeter%s',
$capacitor->getCapacitance(),
$tweeter->getImpedance(),
PHP_EOL
);
printf(
' - %s inductor in series with %s woofer%s',
$inductor->getInductance()->format('milli'),
$woofer->getImpedance(),
PHP_EOL
);