1 | <?php |
||
7 | class HarmonicCalculator |
||
8 | { |
||
9 | private $minDistance = 1.0; |
||
10 | private $maxDistance = 120.0; |
||
11 | |||
12 | /** |
||
13 | * Returns a list of possible harmonics that produce a given sounding note. |
||
14 | * |
||
15 | * @param Note $soundingNote The desired sounding note of |
||
16 | * the harmonic. |
||
17 | * @param InstrumentInterface $instrument The instrument. |
||
18 | * @param float $tolerance The maximum deviation (cents) |
||
19 | * between the desired sounding |
||
20 | * note and a natural harmonic. |
||
21 | * |
||
22 | * @return Harmonic[] |
||
23 | */ |
||
24 | public function findHarmonics(Note $soundingNote, InstrumentInterface $instrument, float $tolerance = 50.0): array |
||
41 | |||
42 | /** |
||
43 | * Set the minimum and maximum distance between harmonic stops (in mm). |
||
44 | * |
||
45 | * @param float $minDistance |
||
46 | * @param float $maxDistance |
||
47 | */ |
||
48 | public function setDistanceConstraints(float $minDistance, float $maxDistance) |
||
53 | |||
54 | /** |
||
55 | * Check that the harmonic is within the configured distance constraints. |
||
56 | * |
||
57 | * @see HarmonicCalculator::setDistanceConstraints() |
||
58 | * |
||
59 | * @param \ExtendedStrings\Strings\Harmonic $harmonic |
||
60 | * |
||
61 | * @return bool |
||
62 | */ |
||
63 | private function validateDistance(Harmonic $harmonic): bool |
||
78 | |||
79 | /** |
||
80 | * Find the artificial harmonics that produce the given sounding note. |
||
81 | * |
||
82 | * @param \ExtendedStrings\Strings\Note $soundingNote |
||
83 | * @param \ExtendedStrings\Strings\VibratingStringInterface $string |
||
84 | * |
||
85 | * @return Harmonic[] |
||
86 | */ |
||
87 | private function findArtificialHarmonics(Note $soundingNote, VibratingStringInterface $string): array |
||
105 | |||
106 | /** |
||
107 | * Find the natural harmonics that produce the given sounding note. |
||
108 | * |
||
109 | * @param \ExtendedStrings\Strings\Note $soundingNote |
||
110 | * @param \ExtendedStrings\Strings\InstrumentStringInterface $string |
||
111 | * @param float $tolerance |
||
112 | * |
||
113 | * @return Harmonic[] |
||
114 | */ |
||
115 | private function findNaturalHarmonics(Note $soundingNote, InstrumentStringInterface $string, float $tolerance = 50.0): array |
||
137 | } |
||
138 |