Basic Music Theory in ~200 Lines of Python
Notation wise and officially it is a loop. But the tuning is a compromise.  Hence some sounds are not harmonised that way using the current scale.  There is a reason why well-tempered clavier tuning is still a bit of debate.  You may have to tune fir some songs differently in those days.  Hence assume all flat and sharp are equal is a bit too pure that might not exist n the real world.