17.01.2013 Views

musicdsp.org source code archive - WSInf

musicdsp.org source code archive - WSInf

musicdsp.org source code archive - WSInf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

end;<br />

// converts from MIDI note to pitch class notation<br />

// the integer part of the number is the octave number, where<br />

// 8 is the octave starting with middle C. The<br />

fractional part<br />

// is the note within the octave, where a 0.01 increment is a<br />

// semitone.<br />

// example: NoteToPch(57)=7.09<br />

function NoteToPch(i:integer):double;<br />

begin<br />

result:=3+(i div 12)+(i mod 12)*0.01;<br />

end;<br />

from : kaleja@estarcion.com<br />

comment : I thought most <strong>source</strong>s gave A-440Hz = MIDI note 69. MIDI 60 = middle C = ~262Hz, A-440 = "A above middle C". Not so?<br />

from : DFL<br />

comment : Kaleja is correct. Here is some C <strong>code</strong>:<br />

double MIDItoFreq( char keynum ) {<br />

return 440.0 * pow( 2.0, ((double)keynum - 69.0) / 12.0 );<br />

}<br />

you can double-check the table here:<br />

http://tomscarff.tripod.com/midi_analyser/midi_note_frequency.htm

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!