Originally posted by Daniel Prene:
If I do it that way it rounds... I solved that by avoiding ints at all and doing
public double getFrequency(int midiNote) {
double aNote = 440;
double note = (double)midiNote;
return (aNote / 32) * java.lang.Math.pow(2, (note - 9) / 12);
}
thanks again for the help
I would like to point out that you haven't completly avoided using ints here. Notice that 440, 32, 9, and 12 are all ints. If you want to ensure that these are doubles, you need to add a decimal place: 440.0, 32.0, 9.0, and 12.0.
HTH
Layne
[ September 15, 2005: Message edited by: Layne Lund ]