| 1 | <?php |
||
| 7 | class Cent |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Returns the number of cents between two frequencies. |
||
| 11 | * |
||
| 12 | * @param float $lower The lower frequency (in Hz). |
||
| 13 | * @param float $upper The upper frequency (in Hz). |
||
| 14 | * |
||
| 15 | * @return float |
||
| 16 | */ |
||
| 17 | public static function frequenciesToCents(float $lower, float $upper): float |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Converts a frequency to a number of cents above C4. |
||
| 24 | * |
||
| 25 | * @param float $frequency The frequency to convert. |
||
| 26 | * @param float $A4 The reference frequency of A4 (defaults to 440). |
||
| 27 | * |
||
| 28 | * @return float |
||
| 29 | */ |
||
| 30 | public static function frequencyToCents(float $frequency, float $A4 = 440.0): float |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Calculates the frequency of a number of cents above a base frequency. |
||
| 37 | * |
||
| 38 | * @param float $cents A number of cents. |
||
| 39 | * @param float $base The base frequency (in Hz). |
||
| 40 | * |
||
| 41 | * @return float The calculated frequency (in Hz). |
||
| 42 | */ |
||
| 43 | public static function centsToFrequency(float $cents, float $base): float |
||
| 47 | } |
||
| 48 |