The goal of this project is to create realistically sounding piano synthesizer; it should not use any prerecorded sound samples, but should be based on a mathematical and physical modelling as much as possible. At the same time, creating complete mathematical model is not a goal, so if there is a way to make it sound better based on the method that is not necessarily physical in its foundations, that is fine.
At this point I have an implementation that sound reasonably good, but it contains some code that can not be published as is. If from description below you feel like you understand what I'm talking about and can provide some help, please do so.
Sounds presented below were produced from a corresponding MIDI files. They represent direct model output without any post-processing. I don't own copyright for any of the MIDI files, they are the property of their respective authors.
|J. S. Bach - Air||[midi, 23 kB] [mp3, 4.1 MB] [short mp3, 471.8 kB]|
|J. Brahms - Hungarian Dance No. 2||[midi, 39 kB] [mp3, 3.2 MB] [short mp3, 512.2 kB]|
|F. Chopin - Fantaisie Impromptu||[midi, 22 kB] [mp3, 4.4 MB] [short mp3, 608.2 kB]|
|W. A. Mozart - Fantasy in D minor (kv397)||[midi, 16 kB] [mp3, 5.1 MB] [short mp3, 555.9 kB]|
If you have a MIDI file that you'd like to hear synthesized, ask me and I'll gladly do it.
Basic mathematical model
Piano sound exhibits very complex behavior and it is almost impossible to produce realistic piano sound based solely on the mathematical modelling. Presented model tries to replicate the result without starting from the basic mathematical and physical principles.
Piano note sound can be decomposed into set of partials. Here is a simple equation showing such decomposition:
Here ai is an initial amplitude, gi is a decay rate, fi is a partial frequency and pi is a phase.
Two of the most prominent characteristics of the piano sound are beating and two-stage decay. Those effects result in a fast decay of the amplitude after the strike and a slowly decaying aftersound. During the slow decay phase there is audible beating in the sound. Nature of those effects is not really known to the science, there are few viable theories described in the literature.
Equation above does not reproduce this behavior, so it can not produce realistic piano sound. One way of replicating beating and two-stage decay is replacing each partial by multiple independent sine waves:
In this equation M represents the number of strings per key for the current key (normally 2 in a low register and 3 in a high register). j=1 corresponds to the initial sound; j=2 and j=3 (if exists) correspond to the aftersound. Previous research shows that the initial fast decay in a piano note sound should be a measurably flatter than the aftersound. General relationship between parameters values is defined in a following way:
- ai,1 >> ai,2; ai,1 >> ai,3; ai,2 ≈ ai,3
- gi,1 >> gi,2; gi,1 >> gi,3; gi,2 ≈ gi,3
- fi,1 < fi,2; fi,1 < fi,3; fi,2 ≈ fi,3
- pi,1 = pi,2 = pi,3
In this case difference between fi,2 and fi,3 is a beating frequency.
ai,j, gi,j, fi,j and pi,j will also depend on the key press dynamics. Adjustment for the press dynamics is done by modifying precalculated base values, so run-time computational complexity of this algorithm is very low.
Now I'm looking for a way to calculate parameters of the model based only on a physical values, like string length, piano body size, etc.
Less ambitious plan is to replace existing proprietary algorithm with an open source implementation and publish complete source code.