# Rhythm-Based Attention Analysis: A Comprehensive Model for Music Hierarchy
## 3 Proposed Methods
### Recursive Detection Module
#### 3.3.2 Model Architecture  
In this section, the architectural design of a recursive music structure detection model proposed by us is presented. The model realizes an in-depth understanding and analysis of musical works by recursively analyzing the rhythmic patterns and overall information of musical sequences, and then organizes the symbolic music data into a tree data structure.  
The architecture of our proposed model for a recursive musical structure detection is illustrated in Figure 7. This hierarchical design processes musical input through mul  
Figure 6: Illustration of the tree structure for recursive detection.  
tiple stages to identify and refine structural elements, with several key refinements and specifications noted.  
**Input and Initial Processing:** The model ingests a music score as symbolic music input, the notes of input are extracted, and the initial length of the sequence is \(L\). These data undergo two parallel initial processing steps:  
* Embedding: This transforms each note's pitch, length, and position of raw musical input into a dense vector representation (\(10\times L\) dimension).
* Rhythmic Grouping Convolution Module: This is a convolutional module (Figure 5) that extracts rhythmic patterns, outputting a \(5\times L\) dimensional representation. Additionally, the rhythmic attention value (\(1\times L\)) is also attached to the output; thus, the output dimension is \(6\times L\).  
**Mamba2 Block:** The outputs from the embedding (\(10\times L\)) and rhythmic grouping convolution module (\(6\times L\)) are concatenated to form a \(16\times L\) input to the Mamba2 block. This block, based on the Mamba architecture, efficiently processes sequential data to capture long-range dependencies in the musical structure.  
**Feature Projection and Combination:** The Mamba2 Block output undergoes two projection operations:  
* One projection results in a \(1\times H\) dimensional output. This projection is then combined with the initial music score through addition, allowing for enhancing the ability to perceive and grasp the whole music piece.  
Figure 7: Architecture of our proposed recursive music structure detection model.  
* Another projection receives the prior combined information and produces a \(8\times L\) dimensional output. **Combinatorial Operator:*
* The combined projected features (with an \(8\times L\) dimension) are processed by a combinatorial operator, which maps these features to potential combinations for each note, including five basic rhythmic grouping types and a no-operation option. A softmax function is then applied to determine the group type. If any basic rhythmic grouping type is detected, the operator produces a node that contains all grouped nodes; if no operation is detected, the node is returned unchanged. This component identifies and combines the structural elements of the music. **Recursive Processing and Structure Building:*
* The architecture incorporates a recursive element through the \"Root Node\" judging point:
* If the output is not the root node, it passes through a \"Node Summarizer\", where a note is selected as a representative from each node containing multiple notes using a sampling method, akin to a pooling operation. This is followed by a \"Sum and Norm\" operation applied to the rhythmic quantized scores. The resulting features (with an \(L^{\prime}\to L\) dimension) are then fed back into the rhythmic grouping convolution layer for further processing.
* If the root node is reached, the final output yields the structure tree.
* Non-root outputs are added as upper layers to the structure tree, building the hierarchical representation iteratively. This recursive design enables the model to construct a multi-level representation of the musical structure, refining its analysis at each iteration. The resulting structure tree provides a comprehensive and detailed overview of the music's rhythmic organization, facilitating further analysis and interpretation.