A large part of it hasn't been researched very mathematically, to my knowledge. If you google music+grammar you can get some stuff with a linguistic approach, which may be less empirically grounded but certainly a richer theory than the alternatives. And don't get me wrong, science is good but as musician mathematician a richer theory that overreaches reality is much more fun, and besides most of this stuff is cultural not immutable so a wrong theory may become correct if is influential.

A few stray ideas that may or not be correct:

- Grammar of common-practice harmony is probably largely left-branching (see https://en.wikipedia.org/wiki/Branching_(linguistics)). This is why so such music makes a surprising transition, then resolves it, and it's orthodox overall. Music is about where it's going.

- For a first approximation rhythm models the rational numbers, because all durations exist in a ratio to other duration.

- Now the rational numbers are infinitely dense and clearly humans can't do that. So there is a minimum resolution which has been wonderfully termed the tatum. Whoever did this however may or may not have realized that there may be a few minima whose join (as in lattices, I'm sure it's a lattice but I never leaned which one) isn't realized. E.g. you might have 8th notes and triplet 8ths but never triplet 16ths (the join).

- Form has all these stupid names when clearly it's a tree and similar structure repeated on every level.

- People sometimes try do do harmony wit a markov model. This sucks because how the chords transition depends on the form, which I believe must largely (needed to be orthodox/fluent) have a fair regular rhythm (avoid those 5-bar phrases). I think something like a ruler function (https://en.wikipedia.org/wiki/Thomae%27s_function) based on time + transitions would be a much better and relatively cheap model. If all the fancy grammar stuff is legit, then this too would be woefully inadequate.

- That said, the "meaning" is definitely in the transitions not the states (production rules in grammar case). A chord with no context has very little meaning (in equal temperament everything can be transposed with 0 informational change except for timbre). Given a key, a chord still has relatively little meaning (also 1 and only 1 key is a reduction, look up "tonicization", there is probably a stack of broad-specific key-like things forming a context). now given a trace of chords, the meaning comes out---tension and release as they say.

- For form and rhythm, 2 branching factor is the default. Everything else is extra work. Probably even in West Africa and other places where the polyrhythms are mad good.

- Emotional relationship definitely changes over time within a culture. Up to the 18th century major=happy minor=happy was far from universal. This is probably why even in popular culture old music is stereotypically all dark and serious.

- The big 5 components of (at least Western) music are (in no particular order) Melody, Harmony, Rhythm, Form, Timbre. Timbre has become more important over time, even before recorded music. Call me a cranky old cultural conservative, but you could say that Western Society is loosing it's collective understanding-of/ear-for Western music, and Timbre is the easiest to appreciate due to its lack of rich structure (as far as I can tell). And of course recorded and synthesized music means we can timbregasm all day.