Link's ocarina uses just three notes: D, F and A. On the Nintendo 64 controller they map to the C buttons like this:
Every song in the game is a sequence of those three notes, so once you have the mapping down, the rest is memorising patterns.