EXE problems
When I ran your exe on my Windows XP computer it said "ORGStudioTestTools.exe is not a valid Win32 application." I tried to install Visual Studio Express 2012 to compile it myself, but the installer failed part of the way through with a similar error message that something was "not a valid Win32 application." I looked at your source code and saw there were only a handful of calculation functions, so I copied them (with small changes) into JavaScript in an HTML file and checked the calculation results in my browser. Later, I was able to successfully install Visual C# 2010 Express. When I opened your project it offered to convert from .NET Framework 4.5 to .NET Framework 4. I accepted that, compiled the code, and finally saw your intended program.
You can see I am very interested in this! But if other people have problems with your exe, you might want to figure out if it's possible to make it compatible with Windows XP, or figure out if a certain framework or other kind of library is needed to make the exe run properly.
Calculation comments
Your calculations seem correct to me. Here are some thoughts.
1. You may be doing some redundant calculations. For example, you start with an octave number and pitch class number, calculate a key number, then use the key number to re-calculate an octave number.
The formula below calculates the same final frequencies as your program, but might be simpler to understand.
C is the pitch class (pitch letter) from 0 to 11 (C to B).
O is the OrgMaker octave from 0 to 7. (middle C is OrgMaker C3, A440 is OrgMaker A3)
F is the OrgMaker Freq value from 100 to 1900.
The frequency of a pitch in hertz is
128 × 440 × 2 ( C – 9 ) / 12 + (F – 1000)
2 ( 10 –
O )
2. You are calculating the base pitch frequency precisely (the part highlighted in red above). When I
investigated OrgMaker with a debugger, I found it ends up using an integer number of hertz for the octave with middle C and A440 (OrgMaker octave 3).
Code:
/*
pitch precise OrgMaker difference
(Hz) (Hz) (Hz) (cents)
============= ======= ======== ==============
(middle C) C 261.63 261.00 –0.63 –4
C# 277.18 278.00 +0.82 +5
D 293.66 294.00 +0.34 +2
D# 311.13 311.00 –0.13 –1
E 329.63 329.00 –0.63 –3
F 349.23 349.00 –0.23 –1
F# 369.99 371.00 +1.01 +5
G 392.00 391.00 –1.00 –4
G# 415.30 414.00 –1.30 –5
(A440) A 440.00 440.00
A# 466.16 466.00 –0.16 –1
B 493.88 494.00 +0.12 +0
Each higher octave is double the frequency. Each lower octave is half the frequency. The cents values are the same for every octave.
Note that the OrgMaker frequencies above are
not the same as rounded versions of the precise values. I guess OrgMaker calculates its base pitch values via some estimation method, but I don't know exactly how.
When I
measured actual OrgMaker audio with a tuner, I got values very close to the OrgMaker column above for most audio performance settings.
These base frequencies affect the pitch slightly. In case you want to emulate the OrgMaker pitch more exactly, you could use the following formula instead:
B is an array B0 to B11 containing the values from the OrgMaker column above.
The frequency of a pitch in hertz is
128 × BC + (F – 1000)
2 ( 10 –
O )