What's the right frequency for midi note 69?

When I play middle A on my full scale midi piano (using its own sound source) I hear a tone at the same pitch as the one from my tuning fork marked 440Hz.
When I connect the piano to juce synth demo and press the same A-key, the synth demo sounds an octave lower.

A cause for this diskrepancy might be the function

const double MidiMessage::getMidiNoteInHertz (int noteNumber, const double frequencyOfA) noexcept
noteNumber -= 12 * 6 + 9; // now 0 = A
return frequencyOfA * pow (2.0, noteNumber / 12.0);

Shouldn’t it return 440 for noteNumber 69?

(Source gitted a few hours ago)

I haven’t looked at the code in question, but Midi Note 69 is A4, which would generally be 440 Hz.

I’m not sure how to express it in text, but you typically get piano notes by multiplying A4 (440Hz) by 12th-root-of-2’s. That appears to be what the second line in the function is effectively doing, but it is shifting from A5 (81), not A4. This might be intentional. I don’t know the context. But if you pass in 880 as the frequency of A (A5), it seems to me it should work.

69 - 81 = -12, -12 / 12 = -1, pow (2.0, -1) = 0.5, 0.5 x 880 = 440.

Without digging into the code, it’s not clear to me if A5 was intentional or not.

It’s hardly intentional, while the parameter frequencyOfA acc to the spec is optional and means the freq of normal-A, usually 440-442Hz. The first (second) line of the function ought to read

noteNumber -= 12 * 5 + 9;

to give the proper frequency.

Hmm. Good question.

I remember researching the correct conversion formula when I wrote that, but looking again, it does seem to be wrong, and yes, 69 should equal 440. Odd. Maybe I got my info from a dodgy source…

Well, I guess I should change it, but am slightly afraid that it might mess up people’s synths. Grrr…

I think their owners will praise the Lord their synths finally have reached the stage of perfect pitch…

Well, I guess I should change it, but am slightly afraid that it might mess up people’s synths. Grrr…[/quote]

That’s why I suggested oxxyyd simply tune it with the optional param. Once some bugs have been around long enough, they become features…

Thanks a lot Jules, now all my female backup singers sound like drag queens.