Calculation Algorithm

The heart of The Whistle Calculator is the algorithm that calculates the placement of the tone holes.  All the rest is just there to make it easy for the user to access and control the calculation.
Historically there have been two main free sources of this calculation.  Flutomat, by Pete Kosel, and TWCalc by Daniel Bingamon.  Both of these authors were kind enough to allow me to copy their algorithms for use in this program.  Without this generosity The Whistle Calculator would not exist, because I know almost nothing about the physics of whistle music making.  I do not think that it is any secret that these algorithms are approximations.  That is, there is sometimes a discrepancy between the hole positions suggested by the Whistle Calculator and the positions that are actually needed.  For some combinations of whistle size and key they work very well, but for other sizes, or keys they may not work nearly as well.  One goal of The Whistle Calculator is to allow the user to select the most appropriate version of the algorithm for the whistle being designed.

I have replicated the algorithms of both Flutomat and TWCalc as separate pieces of code, and these can be selected on the GUI of The Whistle Calculator.

I have found a minor flaw in the 'live' flutomat code on Pete Kosel's website.  The flaw does not lead to significant differences in the hole placements until the holes get large relative to the tube bore, or the tube wall thickness gets large.  Even then the differences are small.  The correct algorithm is, however, easier to implement so you will see a 'corrected flutomat' calculator in the list.

Hans Bracker at Soft Flute has been working on the fine tuning of the alorithm and I have created a version of the calculator with his modifications to the algorithm.

As a further development I have now created one calculator that implements all the others as sub-classes.  This is because much of the mechanism is common between them, with the differences between then expressed in seven functions.

As a specialised subclass of this 'Unified' calculator I have created a calculator that allows the user to express the contents of these functions in JavaScript.  The user can then alter the behavious of the calculator in an attempt to find an algorithm that better matches reality.  The JavaScript calculator has defined for it seven functions:
The base version of these functions are functionally equivalent to the "Corrected Flutomat" algorithm.

There are two other sets of functions, Those defined by Hans Bracker, and those that were part of TWCalc.  These extra two sets each only replace part of the set of functions.  Where a function replaces one in the set, the replacement function is used wherever needed.  So TWCalc redefines effectiveThickness for example.  So wherever effectiveThickness is called when using TWCalc set of functions, the version supplied by the TWCalc set is used.  We say that the TWCalc version of this function 'overrides' the base version.