A method for detecting repetition of symbolic music data and generating long-time structure

CN122738422APending Publication Date: 2026-09-11INNOVATION CENTER OF YANGTZE RIVER DELTA ZHEJIANG UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610844837.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-11
Publication Date
2026-09-11

AI Technical Summary

Technical Problem

[0003]现有符号音乐相似度检测方法与长时结构生成方法之间存在相互关联的系统性缺陷:一方面,现有重复检测方法局限于单声部旋律且忽视演奏力度维度,无法为复音钢琴数据提供有效的结构标注;另一方面,现有结构化生成方法因缺乏通用的复音结构数据来源,只能依赖人工标注或单声部数据集,导致复调音乐的长时结构化生成技术受到严重制约

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122738422A_ABST
    Figure CN122738422A_ABST
Patent Text Reader

Abstract

This invention relates to the field of AI music analysis and generation, and discloses a method for repetition detection and long-term structure generation of symbolic music data. The method first converts symbolic music data into binary piano roll images and dynamic piano roll images, and adapts the structural similarity index SSIM from the field of image processing to the field of symbolic music, calculating compositional similarity SSIMuse-B and performance similarity SSIMuse-V respectively. Specifically, for the binary piano roll image, a note density consistency measure and a note event synchronicity measure based on the Jaccard index are redefined, which can accurately identify repetition patterns that transpose across octaves in textures with interwoven polyphony and rich chords. The method automatically annotates the musical phrase-level structure of the music based on similarity and constructs structural conditions. It trains a structure generation network to autoregressively predict the starting beat and similarity score of the reference musical phrase, and then a diffusion completion model generates and splices the music phrase by phrase under the guidance of structural conditions, realizing the controllable generation of symbolic music with explicit long-term repetition structures.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of AI music analysis and generation, and in particular to a method for detecting repetitions in symbolic music data and generating long-term structures. Background Technology

[0002] Currently, AI music generation is mainly divided into two major technical directions: the symbolic domain and the audio domain. The symbolic domain, which processes symbolic data such as MIDI, has advantages such as small data volume, high editability, and ease of subsequent modification by human musicians, making it valuable for applications in automatic composition and intelligent arrangement. In the field of symbolic music processing, symbolic music similarity and repetition detection, and long-term music generation based on structural annotation are two closely related core technologies: the former provides structural analysis tools for music data, while the latter relies on the structural information output by the former to guide the generation model in constructing complete musical pieces with long-term repetitive structures.

[0003] There are interconnected systemic defects between existing symbolic music similarity detection methods and long-term structure generation methods: on the one hand, existing repetition detection methods are limited to monophonic melodies and ignore the dynamic dimension of performance, and cannot provide effective structural annotations for polyphonic piano data; on the other hand, existing structure generation methods lack universal polyphonic structure data sources and can only rely on manual annotation or monophonic datasets, which severely restricts the long-term structure generation technology of polyphonic music. Summary of the Invention

[0004] To address the shortcomings of existing technologies, this invention provides a method for detecting repetition in symbolic music data and generating long-term structures, thus solving the above problems.

[0005] To achieve the above objectives, the present invention provides the following technical solution: a method for detecting repetition in symbolic music data and generating long-term structures, comprising the following steps: S1. Convert the symbolic music data to be processed into a piano roll diagram representation. The piano roll diagram includes a binary piano roll diagram and a velocity piano roll diagram. The binary piano roll diagram is marked with 1 at the beginning position of the note and 0 at the rest. The velocity piano roll diagram is assigned a MIDI velocity value at the beginning position of the note and 0 at the rest. S2. Based on the binary piano roll-up image and the dynamic piano roll-up image respectively, the similarity between the symbolic music segments is calculated using the adapted image structure similarity index SSIM, resulting in composition similarity SSIMuse-B and performance similarity SSIMuse-V. S3. Based on the similarity, the music is automatically labeled at the phrase level, a phrase adjacency matrix is ​​constructed, and the historical phrase with the highest similarity to each current phrase and its similarity score are extracted as structural condition labels. S4. Based on the structural conditions, train the structure generation network and use the historical structural conditions as input to autoregressively predict the starting beat and similarity score of the reference musical phrase for the next musical phrase. S5. Using the previous musical phrase and the aforementioned structural conditions as input, generate the current musical phrase phrase by phrase through the diffusion completion model; S6. Repeat steps S4-S5 until the target number of musical phrases is reached, and then splice the generated musical phrases to form the target symbolic music with a long-term repetitive structure.

[0006] Preferably, step S2, which involves calculating the compositional similarity SSIMuse-B based on a binary piano roll image, includes: The brightness comparison function l(x,y) of SSIM is reinterpreted as a measure of note density consistency. The SSIM structural comparison function s(x,y) is reinterpreted as a measure of the synchronicity of note events and calculated using the Jaccard similarity index; The structure comparison function incorporates pitch-class folding, sliding window weighted averaging, and cyclic shift search with time penalty mechanisms.

[0007] Preferably, the pitch class folding maps all MIDI pitches to 12 pitch classes within a single octave; the sliding window weighted average uses a power function of similarity as the window weight; the cyclic shift search performs a full cyclic shift on the time axis and pitch axis, and reduces the weight of larger time offsets with a linear penalty term.

[0008] Preferably, the calculation of performance similarity SSIMuse-V based on the dynamic piano roll diagram in step S2 includes: The SSIM brightness comparison function l(x,y) is reinterpreted as an overall dynamic consistency measure, and the mean is calculated only at the note playback position; The contrast comparison function c(x,y) of SSIM is reinterpreted as a measure of dynamic dispersion consistency, and the standard deviation is calculated only at the note playback position; The SSIM structure comparison function s(x,y) is reinterpreted as a measure of consistency of temporal change of force. The maximum force value of each time step is extracted to form a one-dimensional sequence. After time alignment using dynamic time warping (DTW), the structure similarity is calculated.

[0009] Preferably, the automatic annotation of musical phrase-level structures in step S3 includes: S31. Represent each piece of music as a dynamic piano roll diagram, with a fixed number of measures as a musical phrase; S32. For each current musical phrase, calculate its similarity to all historical musical phrases and construct a two-dimensional adjacency matrix, where the starting position of the historical musical phrases is not limited to an integer multiple of the phrase length; S33. Extract the historical phrase with the highest similarity to each current phrase from the adjacency matrix as a reference phrase, and together with the similarity score, form the structural condition label (o,v) of the phrase.

[0010] Preferably, the structure generation network in step S4 is an autoregressive structure prediction network based on the Transformer decoder, employing a two-stage prediction strategy: first predicting the starting beat of the reference phrase for the next musical phrase. Then, based on the starting beat of the reference musical phrase, a similarity score is predicted. .

[0011] Preferably, the diffusion completion model in step S5 includes: The conditional encoding module uses an encoder-only Transformer to encode the reference musical phrase to obtain the latent vector of the reference musical phrase. The similarity scores are mapped through a linear layer and repeated to the same sequence length to obtain the latent similarity vector. Concatenate them into a condition vector ; The conditional phrase completion module uses a denoising network combining U-Net with convolutional and Transformer blocks to concatenate the previous phrase and the current phrase to be generated as input. The conditional vector is injected through cross-attention. The self-attention module processes the contextual relationship between the two phrases, and the cross-attention module introduces a reference phrase to guide structural similarity.

[0012] Preferably, the training strategy for the diffusion completion model includes: Only the noise in the current occluded musical phrase region is predicted, while the noise estimation of the previous musical phrase region is ignored; Introducing SSIM structure regularization loss, the SSIMuse similarity between the generated musical phrase and the reference musical phrase is calculated. Based on its similarity score with a given target The mean squared error between them is used as an additional constraint term.

[0013] Preferably, the diffusion completion model employs a classifier-free training and inference strategy: during training, conditions are randomly discarded with a preset probability; during inference, mixed noise is used for estimation. ,in To guide the weights.

[0014] Preferably, the phrase-level autoregressive extension inference in step S6 includes: S61. First, the structure is used to generate a network autoregressive prediction of the structural condition sequence for the entire music segment. ; S62. Then, the last musical phrase of the currently generated music is taken as the previous musical phrase. The reference musical phrase is generated by the structure-generating network. Using the similarity score v as a structural condition, the current musical phrase is obtained through diffusion completion sampling. Then it is spliced ​​into the generated sequence, and the loop continues until the target number of musical phrases is reached.

[0015] Beneficial effects This invention provides a method for detecting repetitions and generating long-term structures in symbolic music data. Compared with existing technologies, it has the following advantages: 1. In this invention, the structural similarity index SSIM from the field of image processing is adapted to the field of symbolic music. For binary piano roll images, a note density consistency measure and a note event synchronicity measure based on the Jaccard index are redefined. Pitch class folding, sliding window weighted averaging, and cyclic shift search and time penalty mechanisms are introduced to accurately identify the repeating pattern of transposition across octaves in piano textures with polyphony and rich chords. At the same time, for dynamic piano roll images, the mean and standard deviation are calculated only at the note playback position, and dynamic time warping (DTW) is combined to align the dynamic timing. For the first time, the performance dynamic dimension is included in the similarity evaluation system. Since SSIMuse does not require any model training and is based entirely on mathematical metric calculation, there is no out-of-domain generalization problem, and it can be directly applied to any polyphonic piano dataset. 2. In this invention, a phrase adjacency matrix is ​​automatically constructed based on SSIMuse. By extracting reference phrase-similarity pairs to form structural condition annotations, phrase-level structural annotations can be obtained for any polyphonic dataset, completely breaking the constraint of data source. On this basis, the Structure Generation Network (SGN) plans the global structural framework for the entire music segment through two-stage autoregressive prediction. The MusicExtender diffusion completion model ensures that structural conditions only apply to the currently generated phrases without interfering with known regions through a region-specific diffusion completion training strategy. At the same time, SSIM structure regularization loss is introduced, using the mean squared error of the SSIMuse similarity and target similarity scores between the generated phrases and the reference phrases as an additional constraint, forcing the model to truly learn and control the structural relationships between phrases during noise estimation. 3. In this invention, a phrase-level autoregressive extension inference paradigm is adopted. The structure generation network first autoregressively predicts the structure condition sequence of the target length. Then, MusicExtender performs diffusion completion sampling phrase by phrase, using the previous phrase and structure conditions as input. The generation of each phrase strictly depends on the last phrase of the generated sequence and the reference phrase and similarity score specified by SGN. This process is repeated until the preset target number of phrases is reached. This paradigm formalizes music generation into a two-stage process of structure planning first and content completion later. It not only supports the generation of long-duration polyphonic piano music with any number of phrases, but also ensures that the structural relationships such as repetition and variation between each phrase and historical phrases are explicitly constrained by the similarity score. This satisfies the precise needs for music of specific duration and specific structural patterns in real-world scenarios such as film and television scores, game background music, and short video scores. Attached Figure Description

[0016] Figure 1 This is a flowchart illustrating a method for detecting repetitions in symbolic music data and generating long-term structures proposed in this invention. Detailed Implementation

[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0018] Please see Figure 1 The present invention provides two technical solutions, specifically including the following embodiments: Example 1: A method for detecting repetitions and generating long-term structures in symbolic music data includes the following steps: S1. Convert the symbolic music data to be processed into a piano roll diagram representation. The piano roll diagram includes a binary piano roll diagram and a velocity piano roll diagram. The binary piano roll diagram is marked with 1 at the beginning position of the note and 0 at the rest. The velocity piano roll diagram is assigned a MIDI velocity value at the beginning position of the note and 0 at the rest. Specifically, a two-dimensional piano roll-up diagram ,in For time steps, (MIDI pitch category number). Using the sixteenth note as the smallest time unit, and each quarter note quantized into 4 time steps, a measure in 4 / 4 time corresponds to 16 time steps. Two representation formats are defined depending on whether dynamics are considered: Binary Piano Rollup Diagram (BPR): The starting position of a note is marked as 1, and the rest are marked as 0. It is used to describe the pitch-rhythm structure at the compositional level.

[0019] Velocity-based Piano Rollup: The starting position of a note is assigned a MIDI velocity value (1-127), and the remaining positions are 0. It is used to describe the dynamic characteristics at the performance level.

[0020] S2. Based on the binary piano roll-up image and the dynamic piano roll-up image respectively, the similarity between the musical segments is calculated using the adapted image structure similarity index SSIM, resulting in compositional similarity SSIMuse-B and performance similarity SSIMuse-V. Step S2, calculating compositional similarity SSIMuse-B based on the binary piano roll-up image, includes: The brightness comparison function l(x,y) of SSIM is reinterpreted as a measure of note density consistency. The SSIM structural comparison function s(x,y) is reinterpreted as a measure of the synchronicity of note events and calculated using the Jaccard similarity index; Specifically, SSIM was originally defined as:

[0021] For the binary piano roll diagram, the three comparison functions are reinterpreted using the following musical semantics: —Note density consistency: The mean of the binary PR reflects the note density. It measures the degree of consistency in the overall note density between two pieces of music.

[0022] —This term is omitted because it is invalid in binary PR: For binary signals, if the mean is the same, the standard deviation must be the same. The standard deviation consistency function loses its discriminative ability, so this term is removed in SSIMuse-B.

[0023] —Note event synchronicity (improved to Jaccard index): Calculated only at the time-pitch position of notes appearing in at least one of the two musical pieces, eliminating the mean subtraction (to avoid density bias), simplified to: The Jaccard similarity index is a direct measure of the overlap rate of musical note events.

[0024] The structural comparison function introduces pitch class folding, sliding window weighted averaging, and cyclic shift search with time penalty mechanism. Pitch class folding maps all MIDI pitches to 12 pitch classes in a single octave; sliding window weighted averaging uses a power function of similarity as the window weight; cyclic shift search performs full cyclic shift on the time axis and pitch axis, and reduces the weight of larger time offsets with a linear penalty term; Step S2, which calculates the performance similarity SSIMuse-V based on the dynamic piano roll diagram, includes: The SSIM brightness comparison function l(x,y) is reinterpreted as an overall dynamic consistency measure, and the mean is calculated only at the note playback position; The contrast comparison function c(x,y) of SSIM is reinterpreted as a measure of dynamic dispersion consistency, and the standard deviation is calculated only at the note playback position; The SSIM structural comparison function s(x,y) is reinterpreted as a measure of consistency in temporal changes in force. The maximum force value at each time step is extracted to form a one-dimensional sequence. After time alignment using Dynamic Time Warping (DTW), structural similarity is calculated. Three key improvements have been introduced: Pitch-class Folding: Maps all 128 MIDI pitches to 12 pitch classes in a single octave (modulo 12 summation), so that the same melody can still be identified as highly similar even when transposed in different octaves.

[0025] Sliding window weighted average: Local similarity is calculated using a sliding window on the time axis, with the power function of similarity as the window weight, amplifying the contribution of highly overlapping segments and suppressing the interference of low-similar segments.

[0026] Cyclic Shift Search + Time Penalty: Perform a full cyclic shift on both the time and pitch axes for a segment of PR, take the maximum weighted similarity under all shifts as the final result, and apply a linear penalty term. Larger time offsets are weighted less to prevent overly loose matching.

[0027] S3. Automatically annotate the musical phrase-level structure based on similarity, construct a phrase adjacency matrix, and extract the historical phrase with the highest similarity to each current phrase and its similarity score as structural condition annotation. Step S3, automatic phrase-level structure annotation, includes: S31. Represent each piece of music as a dynamic piano roll diagram, with a fixed number of measures as a musical phrase; S32. For each current musical phrase, calculate its similarity to all historical musical phrases and construct a two-dimensional adjacency matrix, where the starting position of the historical musical phrases is not limited to an integer multiple of the phrase length; S33. Extract the historical phrase with the highest similarity to each current phrase from the adjacency matrix as a reference phrase, and together with the similarity score, form the structural condition label (o,v) of the phrase. Specifically, each piece of music is represented as a dynamic piano roll diagram ( Indicates the initial dynamic range of the note. 0 indicates a continuous state, and 0 indicates silence. A musical phrase consists of 4 measures (64 time steps).

[0028] For each current musical phrase (starting beat) in the piece Using SSIMuse, it calculates its relationship with all historical phrases (starting beat). The similarity between ) is used to construct a two-dimensional adjacency matrix M, where The starting position of a historical musical phrase is not limited to an integer multiple of 16; similar patterns with varying starting positions can be captured.

[0029] Extract the historical phrase with the highest similarity to each current musical phrase from the adjacency matrix as a reference phrase, along with the similarity score. Together, they constitute the structural condition annotation of this musical phrase. This forms a complete dataset structure annotation.

[0030] S4. Train a structure generation network based on structural condition annotations. Using historical structural conditions as input, use autoregressive prediction to forecast the starting beat and similarity score of the reference phrase for the next musical phrase. In step S4, the structure generation network is an autoregressive structure prediction network based on a Transformer decoder, employing a two-stage prediction strategy: first, predict the starting beat of the reference phrase for the next musical phrase. Then, the similarity score is predicted based on the starting beat of the reference musical phrase. ; Specifically, an autoregressive structure prediction network based on a Transformer decoder is trained on labeled data. This is based on the historical structure conditions of musical phrase sequences. As input, the reference phrase's starting beat is used to progressively predict the next musical phrase. and similarity This continues until the target number of musical phrases is reached. A two-stage prediction strategy is employed: first predicting... Based on predict The first musical phrase has no reference phrase, so... , As the start of sequence marker (BOS).

[0031] S5. Using the previous musical phrase and structural conditions as input, generate the current musical phrase phrase by phrase through the diffusion completion model. The diffusion completion model in step S5 includes: The conditional encoding module uses an encoder-only Transformer to encode the reference musical phrase to obtain the latent vector of the reference musical phrase. The similarity scores are mapped through a linear layer and repeated to the same sequence length to obtain the latent similarity vector. Concatenate them into a condition vector ; The conditional phrase completion module uses a denoising network combining U-Net with convolutional and Transformer blocks. It concatenates the previous phrase and the current phrase to be generated as input. The conditional vector is injected through cross-attention. The self-attention module processes the contextual relationship between the two phrases. The cross-attention module introduces reference phrases to guide structural similarity. Training strategies for diffusion completion models include: Only the noise in the current occluded musical phrase region is predicted, while the noise estimation of the previous musical phrase region is ignored; Introducing SSIM structure regularization loss, the SSIMuse similarity between the generated musical phrase and the reference musical phrase is calculated. Based on its similarity score with a given target The mean squared error between them is used as an additional constraint term.

[0032] The diffusion completion model employs a classifier-free training and inference strategy: during training, conditions are randomly discarded with preset probabilities, and during inference, mixed noise is used for estimation. ,in To guide the weights.

[0033] Specifically, two key modifications were made to the standard diffusion loss: (1) Only predict the noise in the masked area (current phrase) and ignore the noise estimation of the previous phrase area, so that the influence of the structural conditions only applies to the target phrase and avoids the conditions from misleading the known area; (2) Introduce SSIM structure regularization loss: calculate the generated musical phrases With reference musical phrase SSIMuse similarity between Based on its similarity to a given target The mean squared error between them is used as an additional constraint term: This enables the model to truly learn and control the similarity relationships between musical phrases during generation.

[0034] Classifier-Free Guidance (CFG): During training, conditions are randomly dropped with a 10% probability; during inference, mixed noise is used for estimation. Guided sampling, .

[0035] S6. Repeat steps S4-S5 until the target number of musical phrases is reached. Then, combine the generated musical phrases to form target symbolic music with a long-term repetitive structure. Step S6 includes phrase-level autoregressive extension inference: S61. First, the structure condition sequence of the entire music is predicted by an autoregressive structure generation network. ; S62. Then, the last musical phrase of the currently generated music is taken as the previous musical phrase. The reference musical phrase is generated by the structure-generating network. Using the similarity score v as a structural condition, the current musical phrase is obtained through diffusion completion sampling. Then it is spliced ​​into the generated sequence, and the loop continues until the target number of musical phrases is reached.

[0036] Specifically, the structure-generating network (SGN) first uses autoregressive prediction to forecast the structural condition sequence of the entire music piece. MusicExtender then expands progressively in units of musical phrases: starting with the last phrase of the currently generated music. Using the reference phrases specified by SGN (Taken from the generated sequence) and similarity v as structural conditions, the current musical phrase is obtained through diffusion completion sampling. , splice into the generated sequence, and loop until the target number of musical phrases is reached.

[0037] Example 2: Based on Example 1, in order to verify the effectiveness of the method described in Example 1, this example conducted systematic experimental verification on multiple public datasets, covering two aspects: verification of repetition detection accuracy and verification of long-term music generation quality. I. Experimental Environment and Dataset: The experiments were conducted on a computing platform equipped with an NVIDIA A100 GPU, using the PyTorch deep learning framework. The following three publicly available symbolic music datasets were selected: (1) Pop1K7 dataset: contains 1747 popular piano cover songs, which are polyphonic piano music and do not contain independent melody tracks. It is suitable for verifying the ability to detect and generate duplicates under polyphonic textures. (2) POP909 dataset: contains 899 professional piano arrangements, which are also polyphonic piano music, used to supplement and verify the universality of structural annotation; (3) EMOPIA dataset: a subjective evaluation comparison experiment for long-duration music generation.

[0038] II. Verification of SSIMuse's repeatability detection capability: 1. Randomly select a 16-bar diatonic piano excerpt from the reference set as the base excerpt. Then, randomly copy the contents of bar 1, bar 2, bar 4, and bar 8 (which account for 6.25%, 12.5%, 25%, and 50% of the 16-bar excerpt, respectively) and insert them into different positions in the mixed set to form a synthetic sample.

[0039] 2. Set up 4 replication levels, generate 4000 synthetic samples for each level, and calculate similarity scores using SSIMuse-B, SSIMuse-V and existing baseline methods (CLAP audio embedding method and MERT audio embedding method).

[0040] 3. The Kruskal-Wallis nonparametric test was used to test the significance of the similarity distribution at each duplication level. Experimental results show that SSIMuse-B and SSIMuse-V passed the significance test (p<<0.05) at all four duplication levels in all datasets, proving that they can effectively distinguish between different degrees of duplicate content.

[0041] 4. Further analysis of the detection granularity limit: When the copied content accounts for only 6.25% of 16 measures (i.e., 1 measure), SSIMuse-B and SSIMuse-V can still reliably detect the repetition pattern; while the CLAP method only provides global similarity at the audio level and is not sensitive to local symbolic structure repetition; the MERT method is insufficient in detecting fine-grained phrase-level repetition. Therefore, SSIMuse can reliably detect precise repetitions at a minimum granularity of 1 measure, which is significantly better than existing audio and symbolic domain baseline methods.

[0042] III. Quality Verification of MusicExtender Output: On the Pop1K7 dataset, MusicExtender was compared with existing baseline models, including CP-Word Transformer (CPW) and Polyffusion. The overlap area (OA) metric was used to evaluate the consistency of structural repetition between the generated and reference music: experimental results show that MusicExtender achieves an OA of 0.6136, superior to CP-Word Transformer's 0.5814 and Polyffusion's 0.4731. This result demonstrates that, through SSIM structural regularization loss and conditional phrase completion mechanism, MusicExtender can more accurately reproduce the structural features of reference phrases during the generation process.

[0043] IV. Verification of precise control over the number of musical phrases: To verify the precise control of the generated length by the phrase-level autoregressive extension inference in Example 1, multiple sets of target phrase numbers (e.g., 4 phrases, 8 phrases, 16 phrases, and 32 phrases) were set for generation experiments: S1. The structural condition sequence corresponding to the number of target musical phrases predicted by the autoregressive prediction of the Structure Generative Network (SGN). ; S2 and MusicExtender expand progressively in units of musical phrases, with the generation of each phrase strictly depending on the previous phrase and the structural conditions specified by SGN. Experimental results show that MusicExtender can accurately generate polyphonic piano music with a specified number of phrases, and the structural relationships (repetition, variation, etc.) between phrases are explicitly controlled. In contrast, existing generation models mostly output fixed-length music, which cannot accurately specify the number of phrases in the generated music according to actual application needs.

[0044] Verification results: SSIMuse is the first to adapt image SSIM to the domain of symbolic music, simultaneously covering polyphonic textures (compositional level) and performance dynamics (performance level), requiring no training and being model-independent, achieving reliable repetition detection at the one-measure granularity; the automatic annotation method for phrase-level structures based on SSIMuse requires no manual intervention, is applicable to any polyphonic piano dataset, and breaks the dependence of existing structured generation methods on manual annotation or monophonic datasets; MusicExtender, through a diffusion completion training strategy specific to masked regions and SSIM structure regularization auxiliary loss, surpasses existing baselines in both objective metrics and subjective evaluations, and is the only generation method that supports explicit control of repetitive structures; based on the phrase-level autoregressive paradigm, MusicExtender supports music generation with any target number of phrases, meeting the needs of practical applications for music of specific durations.

[0045] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for detecting repetitions and generating long-term structures in symbolic music data, characterized in that: Includes the following steps: S1. Convert the symbolic music data to be processed into a piano roll diagram representation. The piano roll diagram includes a binary piano roll diagram and a velocity piano roll diagram. The binary piano roll diagram is marked as 1 at the note playback position and 0 at the other positions. The velocity piano roll diagram is assigned a MIDI velocity value at the note playback position and 0 at the other positions. S2. Based on the binary piano roll-up image and the dynamic piano roll-up image respectively, the similarity between the symbolic music segments is calculated using the adapted image structure similarity index SSIM, resulting in composition similarity SSIMuse-B and performance similarity SSIMuse-V. S3. Based on the similarity, the music is automatically labeled at the phrase level, a phrase adjacency matrix is ​​constructed, and the historical phrase with the highest similarity to each current phrase and its similarity score are extracted as structural condition labels. S4. Based on the structural conditions, train the structure generation network and use the historical structural conditions as input to autoregressively predict the starting beat and similarity score of the reference musical phrase for the next musical phrase. S5. Using the previous musical phrase and the aforementioned structural conditions as input, generate the current musical phrase phrase by phrase through the diffusion completion model; S6. Repeat steps S4-S5 until the target number of musical phrases is reached, and then splice the generated musical phrases to form the target symbolic music with a long-term repetitive structure.

2. The method for detecting repetitions in symbolic music data and generating long-term structures according to claim 1, characterized in that: Step S2, which involves calculating compositional similarity SSIMuse-B based on a binary piano roll-up image, includes: The brightness comparison function l(x,y) of SSIM is reinterpreted as a measure of note density consistency. The SSIM structural comparison function s(x,y) is reinterpreted as a measure of the synchronicity of note events and calculated using the Jaccard similarity index; The structure comparison function incorporates pitch-class folding, sliding window weighted averaging, and cyclic shift search with time penalty mechanisms.

3. The method for detecting repetitions in symbolic music data and generating long-term structures according to claim 2, characterized in that: The pitch class folding maps all MIDI pitches to 12 pitch classes within a single octave; the sliding window weighted average uses a power function of similarity as the window weights; The cyclic shift search performs a full cyclic shift on the time axis and pitch axis, and reduces the weight of larger time offsets with a linear penalty term.

4. The method for detecting repetitions in symbolic music data and generating long-term structures according to claim 1, characterized in that: Step S2, which involves calculating the performance similarity SSIMuse-V based on the dynamic piano roll diagram, includes: The SSIM brightness comparison function l(x,y) is reinterpreted as an overall dynamic consistency measure, and the mean is calculated only at the note playback position; The contrast comparison function c(x,y) of SSIM is reinterpreted as a measure of dynamic dispersion consistency, and the standard deviation is calculated only at the note playback position; The SSIM structure comparison function s(x,y) is reinterpreted as a measure of consistency of temporal change of force. The maximum force value of each time step is extracted to form a one-dimensional sequence. After time alignment using dynamic time warping (DTW), the structure similarity is calculated.

5. The method for detecting repetitions in symbolic music data and generating long-term structures according to claim 1, characterized in that: The automatic annotation of phrase-level structures in step S3 includes: S31. Represent each piece of music as a dynamic piano roll diagram, with a fixed number of measures as a musical phrase; S32. For each current musical phrase, calculate its similarity to all historical musical phrases and construct a two-dimensional adjacency matrix, where the starting position of the historical musical phrases is not limited to an integer multiple of the phrase length; S33. Extract the historical phrase with the highest similarity to each current phrase from the adjacency matrix as a reference phrase, and together with the similarity score, form the structural condition label (o,v) of the phrase.

6. The method for detecting repetitions in symbolic music data and generating long-term structures according to claim 1, characterized in that: The structure generation network described in step S4 is an autoregressive structure prediction network based on the Transformer decoder, employing a two-stage prediction strategy: first predicting the starting beat of the reference phrase for the next musical phrase. Then, based on the starting beat of the reference musical phrase, a similarity score is predicted. .

7. The method for detecting repetitions in symbolic music data and generating long-term structures according to claim 1, characterized in that: The diffusion completion model mentioned in step S5 includes: The conditional encoding module uses an encoder-only Transformer to encode the reference musical phrase to obtain the latent vector of the reference musical phrase. The similarity scores are mapped through a linear layer and repeated to the same sequence length to obtain the latent similarity vector. Concatenate them into a condition vector ; The conditional phrase completion module uses a denoising network combining U-Net with convolutional and Transformer blocks to concatenate the previous phrase and the current phrase to be generated as input. The conditional vector is injected through cross-attention. The self-attention module processes the contextual relationship between the two phrases, and the cross-attention module introduces a reference phrase to guide structural similarity.

8. The method for detecting repetition in symbolic music data and generating long-term structures according to claim 7, characterized in that: The training strategy for the diffusion completion model includes: Only the noise in the current occluded musical phrase region is predicted, while the noise estimation of the previous musical phrase region is ignored; Introducing SSIM structure regularization loss, the SSIMuse similarity between the generated musical phrase and the reference musical phrase is calculated. Based on its similarity score with a given target The mean squared error between them is used as an additional constraint term.

9. The method for detecting repetitions in symbolic music data and generating long-term structures according to claim 7, characterized in that: The diffusion completion model employs a classifier-free training and inference strategy: during training, conditions are randomly discarded with a preset probability, and during inference, mixed noise is used for estimation. ,in To guide the weights.

10. The method for detecting repetitions in symbolic music data and generating long-term structures according to claim 1, characterized in that: The phrase-level autoregressive extension inference described in step S6 includes: S61. First, the structure is used to generate a network autoregressive prediction of the structural condition sequence for the entire music segment. ; S62. Then, the last musical phrase of the currently generated music is taken as the previous musical phrase. The reference musical phrase is generated by the structure-generating network. Using the similarity score v as a structural condition, the current musical phrase is obtained through diffusion completion sampling. Then it is spliced ​​into the generated sequence, and the loop continues until the target number of musical phrases is reached.