1 | <?php |
||
7 | class Harmonic |
||
8 | { |
||
9 | private $halfStop; |
||
10 | private $baseStop; |
||
11 | private $vibratingString; |
||
12 | private $soundingFrequency; |
||
13 | |||
14 | /** |
||
15 | * Harmonic constructor. |
||
16 | * |
||
17 | * @param float $halfStop |
||
18 | * The string length of the harmonic-pressure stop. |
||
19 | * @param float $baseStop |
||
20 | * The string length of the base stop (defaults to 1.0, the open string). |
||
21 | * @param VibratingString $vibratingString |
||
22 | * The string. |
||
23 | */ |
||
24 | public function __construct(float $halfStop, float $baseStop = 1.0, VibratingString $vibratingString) |
||
36 | |||
37 | /** |
||
38 | * Returns the sounding frequency of the harmonic (in Hz). |
||
39 | * |
||
40 | * @return float |
||
41 | */ |
||
42 | public function getSoundingFrequency(): float |
||
54 | |||
55 | /** |
||
56 | * Returns the string lengths that produce a given harmonic number. |
||
57 | * |
||
58 | * @param int $number The harmonic number. |
||
59 | * @param bool $exclusive When enabled, equivalent lengths will only be |
||
60 | * returned for the lowest harmonic number, e.g. the |
||
61 | * string length 0.5 will only be returned for |
||
62 | * harmonic 2 (not for harmonics 4, 6, 8, etc.). |
||
63 | * |
||
64 | * @return float[] |
||
65 | */ |
||
66 | public static function getStringLengthsFromNumber(int $number, bool $exclusive = false): array |
||
77 | |||
78 | /** |
||
79 | * Returns the harmonic series. |
||
80 | * |
||
81 | * @param int $limit |
||
82 | * |
||
83 | * @return float[] |
||
84 | */ |
||
85 | public static function getSeries(int $limit): array |
||
95 | |||
96 | /** |
||
97 | * Returns the harmonic-pressure stop, as a string length. |
||
98 | * |
||
99 | * @return float |
||
100 | */ |
||
101 | public function getHalfStop(): float |
||
105 | |||
106 | /** |
||
107 | * Returns the base stop, as a string length. |
||
108 | * |
||
109 | * @return float |
||
110 | */ |
||
111 | public function getBaseStop(): float |
||
115 | |||
116 | /** |
||
117 | * Returns the string. |
||
118 | * |
||
119 | * @return VibratingString |
||
120 | */ |
||
121 | public function getString(): VibratingString |
||
125 | |||
126 | /** |
||
127 | * Returns whether this is a natural harmonic. |
||
128 | * |
||
129 | * @return bool |
||
130 | */ |
||
131 | public function isNatural(): bool |
||
135 | |||
136 | /** |
||
137 | * Returns whether this is an open string. |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | public function isOpenString(): bool |
||
145 | } |
||
146 |