In Eqypt of old music was part of their philosophy and linked to their knowledge of math and colors.
In ancient China and India music was concidered as something very sacred and came close to be a kind of religion - or expression of the spiritual.
In Native American cultures the drumming and dance steps were a way to communicate with the great Spirit in nature.
Classical music was the expression of the awe of nature (as interpreted by the few who had ears to hear it and put it into musical form) - however times had changed by then and so they had to stop performing classic music in the areas of the city were "common folk" might hear it - for when they did perform the papers reported it cause "maddness in the streets" and that the classic music was stirring up primitive and animalistic emotions in people causing them to go insane).
Carl Jung also wrote about the trance like maddness of teenagers dancing to rock and roll music in the 1950s. One preacher got famious demonizing rock and roll music saying it was the devils music. He warned it would lead to kids towards pre-marrage sex and drugs (as it turned out he was right about that). But was becoming clear that music could be used to create a state of altered conscousness simular to the effects of mild drugs. Is an altered consciousness the same as insanity or maddness? Not sure.
Needless to say most religions quickly saw the advantages of music as a way to enfluence the minds and moods of people. So we got all kinds of religious music from more stemulating gospels to stress relaxing meditational music. Music seems to help humans embody the spirit - which is a feeling of some kind (logically).
The universe has a rythem - it is a song. They say a baby can hear that music inside the mother with the drumming of the heart beat - and that if it crys after brith you can calm it (him or her) down by singing a song.