I noticed that the OEIS allows you to listen to a sequence. It converts a sequence of integers to sounds somehow, but I can't find any information on which numbers correspond to which sounds. The OEIS wiki page doesn't contain any further information.

Could anybody explain how sounds are associated to integers? Presumably higher numbers always have a higher pitch. Is there some function $f$ such that a sound of frequency $f(n)$ is played when $n$ appears in the sequence? If so, what is $f$?

  • $\begingroup$ If you would like a quick understanding of the number to note method, check out oeis.org/A123456 and oeis.org/A144488 These are Fur Elise as a sequence. $\endgroup$
    – Terra Hyde
    Jul 17, 2015 at 2:36

1 Answer 1


Before transpositions and such, it works, effectively, like this:

$$P(n)=\begin{cases}A&n\equiv9\mod12\\A\sharp&n\equiv10\mod12\\B&n\equiv11\mod12\\C&n\equiv0\mod12\\C\sharp&n\equiv1\mod12\\D&n\equiv2\mod12\\D\sharp&n\equiv3\mod12\\E&n\equiv4\mod12\\F&n\equiv5\mod12\\F\sharp&n\equiv6\mod12\\G&n\equiv7\mod12\\G\sharp&n\equiv8\mod12\end{cases}$$ $$O(n)=\left\lfloor\frac{n}{12}\right\rfloor$$

Where $P$ is the note name and $O$ is the octave number.


In western music, there are 8 "notes" per octave (though there are 12 actual tones). The notes in one octave are obtained from the previous octave by doubling the frequency. For example, $A4$ has a frequency of $440$ Hz, so $A3$ is $220$ Hz and $A5$ is $880$ Hz. The notes in a single octave are related by specific ratios of frequencies that are dependent on a few factors which can be read about here.

Transposition, in music, is the act of moving the notes of a song up or down based on the needs of key, instrument, and a number of other factors. For example, if you wanted to transpose $A4$ up 6 tones, you would get $D\sharp5$ (since the octave starts, traditionally, at $C$ and has period $12$).

So, the method by which OEIS does its "Listen to this Sequence" stuff works, more finely, like this:

  1. Add to the terms of the sequence the amount being transposed.
  2. Store the adjusted terms as hexadecimal values suitable for MIDI
  3. Write the notes (with start and stop instructions and other relevant data) as hexadecimal values to a MIDI file.
  4. (USER) Open MIDI file in appropriate player.
  5. (Player) Interpret hexadecimal values for terms from sequence as $P(n)$ and $O(n)$ from above.
  6. (Player) Use instrument base tone (varies by MIDI device) as a starting point.
  7. (Player) Adjust base tone to octave by doubling (or halving).
  8. (Player) Adjust octave tone to pitch by appropriate ratio.

For a list of Western music note frequencies, see here. Of course, it is cheaper on memory to just store the base frequency of $A4\rightarrow440$ and adjust from there.

  • $\begingroup$ +1 I really wanted more details (what does 'transpositions and such' mean? I know nothing about music) but this is still very helpful and I am accepting it. $\endgroup$
    – Flounderer
    Aug 10, 2015 at 1:22
  • 1
    $\begingroup$ When I get back to my computer, I will update the answer with more info. I am glad to see that you have an interest in it. $\endgroup$
    – Terra Hyde
    Aug 10, 2015 at 4:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .