Hello everyone, I haven't been on the forum for quite a while due to work reasons. Time is always running short here, but it's a pleasure to meet you all again.
For a few months now, I have been working hard on developing an iOS app for piano tuning.
Those of you who have had the chance to test various tuning software will have realized that they are all fantastic in the octave division F3-F4, but as you proceed to bring the octaves back to the bass and treble, the situation gets progressively worse.
In fact, there is a serious problem... Moving towards the treble, the mathematical model f(n)=nf1 ⢠sqrt(1+Bn^2) assumes that it can reliably measure at least the first 7/8 partials of a note to perform a robust numerical fit of the inharmonicity coefficient. In the central zone, this works well because the partials are present, they are well-separated in frequency, they have sufficient energy, and the analysis window can be quite long. In the treble, the model collapses mainly for two reasons, one of which is a corollary of the other. The envelope is extremely fast, therefore the spectral analysis must be very short, which worsens the frequency resolution. The fact that the envelope is so fast does not even allow for the development of many higher partials. Furthermore, many higher partials fall beyond 15/20kHz where the microphone, especially if it's the device's internal one, already has a degraded response and where the energy is anyway extremely low compared to the noise. The fundamental itself at C7 has few measurable cycles within the useful window. For all these reasons, we conclude that the measurement of the inharmonicity coefficient will be imprecise. In the bass, the problem is the opposite but equally limiting because it is the fundamental that is extremely weak, sometimes even virtually absent (in small pianos) and is psychoacoustically reconstructed by the brain through the higher partials; and the partials useful for calculating inharmonicity are so numerous that they fall into crowded spectral zones, overlapping with other resonances and with false beats that pollute the measurement.
I won't even start telling you about the mathematics and physics behind all this to try to limit the damage from the already debated physical implications: I have tried using combinations of Fletcher's Law, Hilbert Transform, DFT with sub-bin quadratic interpolation, linear regressions via Rauhala linearization, robust regression, median absolute deviation, Rigaud curve, Bayesian inference, Gavin covariance, Jacobian propagation of measurement uncertainty, and so on and so forth... Tune the piano, the middle octave is perfect, the lower you go, the more it sucks. Beats between octaves, and in the bass, you only notice them when listening to tenths or at a distance of two octaves. A disaster.
Tonight, while thinking, an idea came to me that could be the solution. In reality, the problem would remain but much more limited and only in the treble.
Do I need to develop software that tunes the piano? Why not try to emulate what the tuner does.
I mean... All these software programs already out there start from a mathematical approach that is highly debated between the scientific community and tuners. Estimating the inharmonicity curve gives you the advantage of tuning one note at a time starting from wherever you want because the deviations of the fundamentals are already compensated for by the curve itself. But where does it say that I must necessarily reason this way...
What if I reasoned by dyads and developed software that acts like a human tuner's ear?
Let me explain better... In the octave division, first of all, I tune A4 to 440 Hz with a tuning fork. For the software, this is easy. FFT -> I intercept the fundamental and compare it with the frequency 440 Hz. Even the most idiotic software can do that. But then what do I do? I go to tune A3 by playing the dyad A3-A4 as a tuner would, counting the beats between the first partial of A3 and the fundamental of A4. In essence, I could perform a High Resolution FFT concentrated on the frequencies around 440Hz. At that point, I should find one centered on 440 which would be the fundamental of A4, and one presumably falling around 440 (the first partial of A3). If the first partial of A3 were, for example, 439, the software should show me a beat per second and guide me by asking me to raise the frequency of A3 until the partial coincides with the fundamental of A4. And I can apply this same concept to all intervals for the octave division: from A3, proceed by fifth to C4 at 0.7 falling beats.
With this approach, I wouldn't even need to measure the inharmonicity curve because it is already intrinsically contained within the alignment of the beats in the octave division.
Once finished tuning F3-F4"}
we proceed with E3-E4 (with E4 already tuned in the octave split). Here, in the same way, I must make the octaves stable but I would use a different approach: instead of telling the software beforehand which partials to consider when zeroing out the beats, I would let it find them itself, and this works in my favor especially in the bass. Because in the bass, the tuner has to accept compromises, namely trying to stop the beats between the most evident partials; in fact, to do so, they often rely on references two octaves away. For example, C1-C3. The idea would therefore be to analyze the spectrum of the bichord, searching for which are the closest high-energy peaks that generate audible beating, and I would go to zero out that beat.
Naturally, this approach was not possible with hardware from 20 years ago (the age of all these apps on the market), but it is possible to do it now.
I am especially interested in the opinion of Enrico, who is a physicist, and Paolo, who is a tuner. Do you think that if I can automatically isolate the closest energy peaks, this approach could work? After all, it is what the tuner's ear does automatically and analogically.
Good evening to everyone.