ForHosting KIT · Developer Utilities

Frequency to MIDI note number calculator

This frequency to MIDI note number calculator converts a positive frequency in hertz into the nearest integer MIDI note number.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

It uses twelve-tone equal temperament with concert A fixed at 440 hertz, so A4 becomes MIDI 69 and each octave changes the result by twelve notes. Alongside the rounded number, the result shows the continuous MIDI value, the exact equal-temperament frequency of the selected note, and the cents difference. The calculation is deterministic, needs no network access, and rejects values outside the conventional MIDI range from 0 through 127.

Understand the frequency-to-MIDI relationship

MIDI note numbers place chromatic pitches on a simple integer scale. Middle C is MIDI 60, A4 is MIDI 69, and moving one octave upward adds twelve. Frequency does not rise by a fixed number of hertz between notes, however; it rises geometrically. Twelve-tone equal temperament divides an octave into twelve equal frequency ratios, with every semitone multiplying frequency by the twelfth root of two. This calculator reverses that relationship. It divides the supplied frequency by 440, takes the base-two logarithm, multiplies by twelve, and adds 69. The resulting continuous value describes exactly where the input lies on the MIDI pitch scale. Rounding that value to the nearest integer produces the nearest MIDI note number. For example, 440 hertz produces exactly 69, while 880 hertz produces 81 because it is one octave higher. The response preserves both the rounded integer and a ten-decimal continuous value, making it useful when a caller needs a discrete keyboard key as well as information about how the measured pitch lies between keys. The reference is deliberately fixed at concert A equals 440 hertz, matching the stated purpose of this capability and ensuring that every caller receives the same answer without an optional tuning reference changing the interpretation.

Read the nearest note and pitch difference

Enter one positive, finite frequency in hertz using the frequency field. The aliases frequency_hz and hz are also accepted for convenient integration with measurement data. The primary result is midi_note_number, an integer from 0 through 127. The exact_midi_note_number field is the value before rounding, and nearest_frequency_hz is the equal-temperament frequency represented by the selected MIDI integer at the 440-hertz reference. The cents_difference field describes the remaining pitch distance: a positive value means the input frequency is sharper than the selected MIDI note, while a negative value means it is flatter. One hundred cents equals one equal-tempered semitone, so a nearest-note result normally has a difference between approximately minus fifty and plus fifty cents. At an exact midpoint, JavaScript rounding selects the integer according to its standard rounding rule, keeping execution reproducible. The response also repeats reference_frequency_hz as 440 and identifies the temperament, which prevents downstream software from mistaking the result for a historical tuning or just-intonation calculation. Missing values, zero, negative values, infinities, nonnumeric text, and frequencies whose rounded note would fall beyond the conventional MIDI range are rejected as invalid input. Rejection is preferable to clamping because silently turning an extreme frequency into note 0 or 127 would misrepresent the measurement and could conceal an upstream unit error.

Use the conversion in audio and measurement workflows

The calculator fits wherever a system measures or stores frequency but another component expects MIDI note numbers. An audio analysis script can convert a detected spectral peak into a keyboard index before displaying it in a tuner interface. A synthesizer test can confirm that an oscillator configured for 440 hertz maps to note 69, then repeat the check across octaves to catch tuning-table mistakes. Laboratory and classroom exercises can connect logarithms, frequency ratios, and the MIDI numbering convention without relying on a lookup chart. Sample librarians can derive a consistent root-note candidate from a measured fundamental, while still retaining cents_difference to decide whether a recording needs retuning before it is mapped across a keyboard. The calculation should be applied to a fundamental frequency rather than blindly to any spectrum peak, because strong harmonics can correspond to different MIDI notes even when the perceived pitch is lower. Likewise, this tool does not detect pitch from audio, identify note spelling, or choose between enharmonic names; it accepts an already measured frequency and returns a number. Interactive use in the browser is free, while an automated API request is priced at $0.002. Both paths use the same deterministic arithmetic, so a value tested manually can be moved into a production workflow without changing formulas. No input is sent to a third-party service, and no random or time-dependent state influences the result, which makes the output appropriate for repeatable fixtures, teaching examples, batch metadata preparation, and validation pipelines.

Pitch detector output

Turn a measured fundamental frequency into the nearest MIDI note number for a tuner, visualizer, or music application.

Sampler metadata

Estimate a sample's MIDI root-note number and inspect its cents difference before assigning keyboard mapping metadata.

Oscillator testing

Create repeatable assertions that known equal-temperament frequencies map to the intended MIDI note integers.

What formula converts frequency to a MIDI note number?

The continuous value is 69 + 12 × log2(frequency / 440). The nearest MIDI note number is that value rounded to the nearest integer.

What MIDI note number is 440 Hz?

440 Hz is MIDI note 69 exactly because it is the A4 reference used by this calculator.

Does the calculator support a reference other than 440 Hz?

No. This capability is intentionally fixed to 440 Hz concert pitch so its results have one stable interpretation.

Why does the response include cents difference?

It shows how far the input lies above or below the nearest equal-temperament MIDI note; positive is sharp and negative is flat.

What does the API calculation cost?

Each API request uses the published base price of $0.002. Interactive browser execution is free.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/optics/frequency-to-midi-note

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/optics/frequency-to-midi-note \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"frequency":440}'
{
  "frequency": 440
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "optics.frequency_to_midi_note",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →