An important emotional structure of a melody, is that parts of it ascend or descend linearly or waving in other words the pitch order of notes but without particular reference to how much. In other words the qualitative dynamics of up and down and oscillations and not of what interval or scale. In mathematical geometry the structure of shapes which is not its metric properties bu rather the order of points is called Affine geometry and Affine structure. Which is also under the more general abstraction of the order-topology of an entity.
So let a melody as a sequence of notes a(1),a(2),a(3),a(4),a(5) ...a(n)
If we are not interested in what scale it is and what are the intervals a(n)-a(n+1)
but only to that as far as pitch is concerned that a(n)>a(n+1) or a(n)=a(n+1) or a(n)<a(n+1).
An transformation f of the melody such that this pitch-order structure is preserved id a(n)<a(n+1) then f(a(n))<f(a(n+1) and similarly for = and > is said to preserve the affine structure of the melody.
The order-topological structure of the melody is highly responsible for the emotional impact of joy or sadness, but the details of the harmony is not included in the order-topological structure.
(This post has not been written completely yet)