Perspective came first: geometry was put to work in the service of painting. Examining his codices, we find that he also used mathematics to devise architectural projects. Inspired by Vitruvius, he was fascinated by the proportions of the human body and conceived the "Vitruvian Man," set within a circle and a square.
Leonardo the musician is less well known. He enjoyed playing the lira da braccio, but also painting while listening to music: for him, music went hand in hand with painting. Always on the lookout for analogies between disciplines, he sought to define an "acoustic perspective" or, as Paul Valéry put it so aptly, tried "to establish relationships between things whose law of continuity eludes us."
Unfortunately, little remains of his work in music, apart from a few sketches of revolutionary musical instruments that were never built.
Leonardo da Vinci's profusion of ideas was simply the expression, across many fields, of his quest for the underlying harmony of the world, with mathematics holding the key to understanding it.

Stained-glass window "The Reign of Francis Ist," Sèvres Manufactory, 1847

(Leonardo da Vinci dying in the arms of Francis Ist).