A computer-based music composition method, system, electronic device, and storage medium.

By constructing a feature dataset and music theory constraints, and using an evolutionary algorithm to generate optimal music, the problem of monotonous music quality and insufficient innovation in existing computer composition methods is solved, and high-quality and diverse music generation is achieved.

CN116524881BActive Publication Date: 2026-04-03NANCHANG HANGKONG UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-23
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

Existing computer music composition methods consider too few factors affecting music quality, resulting in inconsistent and unoriginal music.

Method used

By acquiring multi-dimensional features from different types of emotional music, a feature dataset is constructed. Musical constraints are generated based on music theory knowledge. An evaluation model is constructed using the multi-feature dataset as the fitness function of the evolutionary algorithm to perform computer-generated music composition and generate the optimal music.

Benefits of technology

It improves the quality and innovation of music generation, ensures that the generated music meets the constraints of multi-dimensional features, and enhances the diversity and emotional expressiveness of the music.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116524881B_ABST
    Figure CN116524881B_ABST
Patent Text Reader

Abstract

This invention discloses a computer music composition method, system, electronic device, and storage medium, relating to the field of computer music composition. The method includes: acquiring multi-dimensional features from different types of emotional music to construct a feature dataset; the multi-dimensional features include: sound wave features, N-gram statistical features, and music theory parameter features; generating musical constraints based on music theory knowledge; the musical constraints include: pitch constraints, duration constraints, and intensity constraints; and based on the musical constraints, constructing an evaluation model using the multi-feature dataset as the fitness function of an evolutionary algorithm to compose music using computer music, obtaining the optimal generated music. This invention solves the problem that existing music generation methods have certain technical limitations in the generated music results due to overly singular data sources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer music composition technology, and in particular to a computer music composition method, system, electronic device, and storage medium. Background Technology

[0002] Today's society has an increasing demand for music, but music creation itself is a job that can only be done with professional knowledge. The emergence of computer music composition has greatly lowered the threshold for music production, enabling the rapid production of a large amount of music to meet social needs. Therefore, computer music composition has become one of the hot research directions in artificial intelligence.

[0003] Existing computer music composition methods consider too few factors affecting music quality, resulting in inconsistent and unoriginal music. Summary of the Invention

[0004] The purpose of this invention is to provide a computer composition method, system, electronic device, and storage medium to solve the problem that existing computer composition methods, considering that the factors affecting music quality are too singular, result in inconsistent music quality and a lack of innovation.

[0005] To achieve the above objectives, the present invention provides the following solution:

[0006] A computer-based music composition method, comprising:

[0007] Multi-dimensional features of different types of emotional music are obtained to construct a feature dataset; the multi-dimensional features include: sound wave features, N-gram statistical features, and music theory parameter features;

[0008] Musical constraints are generated based on music theory knowledge; the musical constraints include: pitch constraints, duration constraints, and intensity constraints.

[0009] Based on the musical constraints, an evaluation model is constructed using the multi-feature dataset as the fitness function of the evolutionary algorithm to compose music using computers, thereby obtaining the optimal generated music.

[0010] Optionally, multi-dimensional features from different types of emotional music can be obtained to construct a feature dataset, specifically including:

[0011] Based on music theory rules related to emotions, the music in the music database is divided into different categories of emotional music;

[0012] Different types of emotional music are converted into sound wave images, and sound wave features are extracted from the sound wave images; the sound wave features include: Mel spectrum, short-time Fourier transform, spectral centroid, and zero-crossing rate;

[0013] The pitch data of different types of emotional music were statistically analyzed using the N-gram statistical method to obtain N-gram statistical features;

[0014] From the perspective of music theory expertise, the music theory parameters of different types of emotional music are statistically analyzed; these parameters include: mode, rhythm, tempo, percentage of each note, percentage of each pitch, percentage of whole tone, and pitch range.

[0015] A feature dataset is constructed based on the sound wave features, the N-gram statistical features, and the music theory parameter features.

[0016] Optionally, musical constraints are generated based on music theory knowledge, specifically including:

[0017] Analyze pitch data in a music database to determine the maximum and minimum pitches;

[0018] The pitch generation range is determined based on the maximum pitch and the minimum pitch; the pitch constraint is that the generated pitch cannot exceed the pitch generation range.

[0019] A fixed time T is used as a musical measure; the note length constraint is that the note length of the generated music must satisfy the condition that the sum of every n note lengths is T, and the number of n is unlimited;

[0020] Set a fixed value for the intensity; the intensity constraint is that the intensity of the generated music is the set fixed value for the intensity.

[0021] Optionally, based on the musical constraints, an evaluation model is constructed using the multi-feature dataset as the fitness function of the evolutionary algorithm to compose computer music, thereby obtaining the optimal generated music. Specifically, this includes:

[0022] The population of individuals in the evolutionary algorithm is generated based on the music constraints; each individual in the population represents the generated music.

[0023] During the iteration process, an evaluation model is constructed using the multi-feature dataset to evaluate the generated music and output the optimal generated music.

[0024] Optionally, during the iteration process, an evaluation model is constructed using the multi-feature dataset to evaluate the generated music and output the optimal generated music, specifically including:

[0025] The similarity between the acoustic wave features of the generated music and the acoustic wave features in the feature dataset is calculated to obtain a first similarity; and a first evaluation result is calculated based on the first similarity.

[0026] The pitch data in the generated music are statistically analyzed, and a second evaluation result is calculated based on the statistical results and the N-gram statistical features in the feature dataset.

[0027] Music theory rules are determined based on the music theory parameter features in the aforementioned feature dataset;

[0028] The generated music is scored based on the aforementioned music theory rules to obtain a third evaluation result;

[0029] Based on the first evaluation result, the second evaluation result, and the third evaluation result, the optimal music is generated.

[0030] The present invention also provides a computer music composition system, comprising:

[0031] The feature dataset construction module is used to acquire multi-dimensional features from different types of emotional music and construct a feature dataset; the multi-dimensional features include: sound wave features, N-gram statistical features, and music theory parameter features;

[0032] The music constraint generation module is used to generate music constraints based on music theory knowledge; the music constraints include: pitch constraints, duration constraints, and intensity constraints.

[0033] The optimal music generation module is used to construct an evaluation model based on the music constraints and the multi-feature dataset as the fitness function of the evolutionary algorithm to compose music by computer and obtain the optimal generated music.

[0034] The present invention also provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to perform the above-described computer composition method.

[0035] The present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described computer composition method.

[0036] According to specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0037] This invention classifies music in a music database using emotion-based music rules and constructs a feature dataset. When generating music, constraints related to different types of emotion-based music are applied, and an evaluation model is constructed using the feature dataset as the fitness function of an evolutionary algorithm to evaluate the generated music and obtain the optimal generated music. This invention solves the problem that existing music generation methods have certain technical limitations due to overly singular data sources. Attached Figure Description

[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0039] Figure 1 A flowchart of a computer-based music composition method provided in Embodiment 1 of the present invention;

[0040] Figure 2 This is a schematic diagram of the computer music composition method provided in Embodiment 1 of the present invention. Detailed Implementation

[0041] 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.

[0042] The purpose of this invention is to provide a computer composition method, system, electronic device, and storage medium to solve the problem that existing computer composition methods, considering that the factors affecting music quality are too singular, result in inconsistent music quality and a lack of innovation.

[0043] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0044] Example 1

[0045] Embodiment 1 of the present invention provides a computer-based music composition method, such as... Figure 1-2 As shown, the method includes the following steps:

[0046] S1: Obtain multi-dimensional features from different types of emotional music and construct a feature dataset; multi-dimensional features include: sound wave features, N-gram statistical features, and music theory parameter features.

[0047] Furthermore, S1 specifically includes:

[0048] S11: Obtain the raw music database.

[0049] S12: Classify the selected music database. Using known music theory rules related to emotions, classify the music database into four emotional categories: happy, angry, sad, and calm. Table 1 shows the specific music theory rules, and Table 2 shows how different emotions are expressed within these rules.

[0050] Table 1. Specific Rules for Classifying Musical Emotions

[0051]

[0052] Table 2. Performance of Music with Different Emotional Contexts within the Rules

[0053]

[0054] S13: Match the categorized music with corresponding emotions to create independent emotion music databases;

[0055] S14: Extract multi-dimensional features from different types of emotional music to construct a multi-feature dataset for emotional music. These multi-dimensional features include: sound wave features, N-gram statistical features, and music theory parameter features.

[0056] Furthermore, step S14 specifically includes:

[0057] S141: Analyze the acoustic wave characteristics, the steps are as follows:

[0058] Different types of emotional music are converted into sound wave image representations. Corresponding optimized feature data (Mel spectrum, short-time Fourier transform, spectral centroid, and zero-crossing rate) are extracted, and these features are vertically superimposed into a data matrix, corresponding to the sound wave feature data. Specific features and calculation formulas are shown in Table 3.

[0059] Table 3 Feature Extraction Formulas

[0060]

[0061] f is the frequency of the audio signal, x(t) is the input signal, h(τ-t) is the analysis window function, τ is the slice length centered at time t, E(n) is the spectral energy of the frequency corresponding to the short-time Fourier transform of the continuous time-domain signal x(t), and sgn(n) is the sign function.

[0062] S142: Extract N-gram statistical features, the steps are as follows:

[0063] Based on the statistical method of the language model N-gram, pitch data of different types of emotional music are statistically analyzed to obtain N2 and N3 data. N2 is the probability data of two adjacent pitch combinations, and N3 is the probability data of three adjacent pitch combinations. The final dataset is N-gram statistical feature data.

[0064] The N-gram statistical model expression is as follows:

[0065]

[0066] The formula represents the N-gram data when the number of note combinations is n, P(w n ,w n+1 ,...,w m ) indicates that in a piece of music w n+1 ,...,w m The proportion of pitch combinations occurring in all pitch combinations of length mn is used to determine the N2 and N3 values, with n=2 and n=3 respectively. Specifically, N2 represents the probability of a different second pitch value in a statistically analyzed 2-pitch combination, given the first pitch value; N3 represents the probability of a different third pitch value in a statistically analyzed 3-pitch combination, given the first two pitch values. The proportion of different note combinations is recorded in matrix form, where the vertical axis represents known notes and the horizontal axis represents the last note. N2 and N3 form a corresponding data matrix as N-gram statistical feature data.

[0067] S143: Design music theory parameter characteristics, the steps are as follows:

[0068] From the perspective of music theory expertise, we statistically analyzed multiple parameters of different types of emotional music, including mode, rhythm, tempo, percentage of each note, percentage of each pitch, percentage of whole tone, and pitch range, ultimately obtaining music theory parameter characteristic data.

[0069] S2: Generate musical constraints based on music theory knowledge; musical constraints include: pitch constraints, duration constraints, and intensity constraints.

[0070] A piece of music needs three basic elements: pitch, duration, and intensity. In computer music composition, different constraints are set for these three elements when generating music. Specifically, S2 includes:

[0071] S21: For pitch, it is necessary to statistically analyze the pitch data in the music database to obtain the maximum pitch, minimum pitch, and the corresponding quantity for each pitch. Pitches should be generated within the range of the maximum and minimum pitches, avoiding the generation of pitches not present in the music database. The pitch of generated individual music pieces should be restricted to be randomly generated within the pitch range of the emotional music dataset. The pitch constraint is that the generated pitches cannot exceed the pitch generation range.

[0072] S22: For note lengths, it is necessary to statistically analyze the note length data in the music database to obtain the proportion of each note length. Then, note lengths are randomly generated based on the proportion of each note length. At the same time, a fixed time T is used as the measure of the music. The note length constraint is that the generated note lengths must satisfy the condition that the sum of every n note lengths is T, where the number of n is unlimited.

[0073] S23: Set the intensity to a fixed value; the intensity constraint is that the intensity of the generated music is the set fixed value.

[0074] S3: Based on musical constraints, an evaluation model is constructed using a multi-feature dataset as the fitness function of an evolutionary algorithm for computer music composition, yielding the optimal generated music. The evolutionary algorithm can be, but is not limited to, genetic algorithms, NSGA-III algorithms, and immune algorithms.

[0075] The designed musical constraints are used as the population individuals generated during computer music composition using an evolutionary algorithm. A multi-feature evaluation method is designed to evaluate the music using data from a multi-feature dataset. The evaluation results are used as the output of the fitness function. The iterative model is trained to finally obtain high-quality music.

[0076] Furthermore, step S3 specifically includes:

[0077] S31: Individuals in a population are defined as complete musical pieces composed of pitch, duration, and fixed intensity.

[0078] S32: Extract features that are consistent with the sound wave features in the generated music individual and the multi-feature dataset, compare the similarity between the two feature datasets, and use the result as S. wave .

[0079] Mel spectrum, short-time Fourier transform, spectral centroid, and zero-crossing rate features of the generated music are extracted and compared with the acoustic features in the multi-feature dataset. The similarity comparison method is the Pearson correlation coefficient, and the formula is as follows: This is used to generate the similarity between the music and the music in the database. In the formula, η represents a certain dataset. γ represents the mean of this dataset, and γ represents another different dataset. ρ represents the mean of another dataset, and the result of the formula ρ represents the correlation between dataset η and dataset γ.

[0080] With formula S wave =∑ρ i / m calculates the first evaluation result, where ρ i The similarity result is calculated for multiple features, where m is the number of features.

[0081] S33: Statistically generate pitch data n2 and n3 for the music, where n2 represents two consecutive pitch combinations and n3 represents three consecutive pitch combinations. This is achieved through the constructed formula S... N-gram =∑n 2i +∑n 3l Calculate the second evaluation result, where n 2i To generate the N2 combination probability from the N-gram statistical features of the multi-feature dataset corresponding to the two pitch combinations of music, n 3l The N3 combination probability is calculated from the N-gram statistical features of the corresponding multi-feature dataset.

[0082] S34: From a music theory perspective, using formula S rule =∑S ri Multiple music theory rules are selected, each with different penalty / reward scores. Each individual musician is scored according to these rules. rule The sum of the final scores for multiple rules.

[0083] Design music theory rules to evaluate music quality, and evaluate each piece of music generated. The specific evaluation rules are shown in the table below:

[0084] Table 4 Music Theory Evaluation Rules

[0085]

[0086] Pitch span refers to the span between two consecutive notes not exceeding one octave; key deviation rate refers to the presence of notes that do not conform to the rules of major or minor keys; parallel fifths and parallel octaves refer to three consecutive notes where the pitch spans simultaneously upwards or downwards by a fifth or an octave; the restriction condition for repeated notes is that the pitch of a note is repeated no more than four times; the whole-tone ratio (C, D, E, F, G, A, B) is calculated by comparing the proportion of whole-tone scales in the generated pitches with the data statistically obtained from the music theory parameter features in the corresponding multi-feature dataset; note uniqueness is the number of different notes in each measure of the generated pitches, with the comparison parameter being the parameter in the music theory parameter features.

[0087] The music theory rules are set according to weights to score the generated music, and the final score, Srule, is used as the third evaluation result.

[0088] S35: In computer music composition, the algorithm iteration process is treated as a multi-objective optimization problem, with S wave S N-gram S rule As a three-objective function value, each musical individual in the population generated under the constraint rules will be evaluated by multiple indicators and selected as the best, ensuring that the final result generated by the computer composition method is high-quality music.

[0089] Example 2

[0090] Regarding the computer-based music composition method provided in Embodiment 1, Embodiment 2 of the present invention provides a specific implementation method, the specific process of which is as follows:

[0091] Step 1: First, utilize the differences in music with different emotions to summarize rules and classify the original music database through music theory parameters. The original music database includes 1034 piano pieces. The music database is divided into four categories of emotional music databases: happy music database, angry music database, sad music database, and calm music database.

[0092] Step 2: Extract multiple feature data for each piece of music in the four types of emotional music libraries. The features include sound wave features, N-gram statistical features, and music theory parameter features, which can serve as a dataset that can represent the characteristics of different emotional music libraries.

[0093] Step 3: When generating music, set constraints, including pitch range, probability of different note lengths, note length segmentation structure, fixed length of each measure of music set to 2048, and uniform intensity set to 90.

[0094] Step 4: Use music that meets the conditions in Step 3 as the initial music input for the genetic algorithm. Select the fitness function to build an evaluation model. Use the dataset from Step 2 as the basic reference data to build three evaluation indicators. The evaluation includes three aspects: sound wave feature similarity, N-gram evaluation, and rule evaluation. The evaluation result of the fusion of the three is used to judge the quality of the music.

[0095] Step 5: Network training module. Following the process set in step 4, the built evaluation model is used to optimize and generate music. The number of iterations is set to 500, and finally, music with relatively stable evaluation results and good quality is obtained.

[0096] Example 3

[0097] In order to implement the method corresponding to Embodiment 1 above and achieve the corresponding functions and technical effects, a computer music composition system is provided below.

[0098] The system includes:

[0099] The feature dataset construction module is used to obtain multi-dimensional features from different types of emotional music and construct feature datasets. The multi-dimensional features include: sound wave features, N-gram statistical features, and music theory parameter features.

[0100] The music constraint generation module is used to generate music constraints based on music theory knowledge; the music constraints include: pitch constraints, duration constraints, and intensity constraints.

[0101] The optimal music generation module is used to compose music by computer based on music constraints and by constructing an evaluation model using a multi-feature dataset as the fitness function of an evolutionary algorithm, thereby obtaining the optimal generated music.

[0102] Example 4

[0103] Embodiment 4 of the present invention provides an electronic device, including a memory and a processor. The memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to perform the computer composition method provided in Embodiment 1.

[0104] Example 5

[0105] Based on the description of Embodiment 4, Embodiment 5 of the present invention provides a storage medium on which a computer program is stored, which can be executed by a processor to implement the computer composition method of Embodiment 1.

[0106] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.

[0107] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A computer-based music composition method, characterized in that, include: To acquire multi-dimensional features from different types of emotional music and construct a feature dataset; The multi-dimensional features include: sound wave features, N-gram statistical features, and music theory parameter features; Musical constraints are generated based on music theory knowledge; the musical constraints include: pitch constraints, duration constraints, and intensity constraints. Based on the musical constraints, an evaluation model is constructed using the feature dataset as the fitness function of the evolutionary algorithm to compose music using computers, thereby obtaining the optimal generated music. Specifically, this includes: generating a population of individuals for the evolutionary algorithm based on the musical constraints; each individual in the population represents the generated music; and evaluating the generated music using the evaluation model constructed from the feature dataset during the iteration process, outputting the optimal generated music. Specifically, during the iteration process, an evaluation model is constructed using the aforementioned feature dataset to evaluate the generated music and output the optimal generated music. This includes: The similarity between the acoustic wave features of the generated music and the acoustic wave features in the feature dataset is calculated to obtain a first similarity; and a first evaluation result is calculated based on the first similarity. The pitch data in the generated music are statistically analyzed, and a second evaluation result is calculated based on the statistical results and the N-gram statistical features in the feature dataset. Music theory rules are determined based on the music theory parameter features in the aforementioned feature dataset; The generated music is scored based on the aforementioned music theory rules to obtain a third evaluation result; The optimal generated music is determined based on the first evaluation result, the second evaluation result, and the third evaluation result.

2. The computer composition method according to claim 1, characterized in that, To acquire multi-dimensional features from different types of emotional music and construct a feature dataset, specifically including: Based on music theory rules related to emotions, the music in the music database is divided into different categories of emotional music; Different types of emotional music are converted into sound wave images, and sound wave features are extracted from the sound wave images; the sound wave features include: Mel spectrum, short-time Fourier transform, spectral centroid, and zero-crossing rate; The pitch data of different types of emotional music were statistically analyzed using the N-gram statistical method to obtain N-gram statistical features; From the perspective of music theory expertise, the music theory parameters of different types of emotional music are statistically analyzed; these parameters include: mode, rhythm, tempo, percentage of each note, percentage of each pitch, percentage of whole tone, and pitch range. A feature dataset is constructed based on the sound wave features, the N-gram statistical features, and the music theory parameter features.

3. The computer-based music composition method according to claim 1, characterized in that, Musical constraints are generated based on music theory knowledge, specifically including: Analyze pitch data in a music database to determine the maximum and minimum pitches; The pitch generation range is determined based on the maximum pitch and the minimum pitch; the pitch constraint is that the generated pitch cannot exceed the pitch generation range. A fixed time T is used as a musical measure; the note length constraint is that the note length of the generated music must satisfy the condition that the sum of every n note lengths is T, and the number of n is unlimited; Set a fixed value for the intensity; the intensity constraint is that the intensity of the generated music is the set fixed value for the intensity.

4. A computer composition system, performing the computer composition method according to any one of claims 1-3, characterized in that, The system includes: The feature dataset construction module is used to acquire multi-dimensional features from different types of emotional music and construct a feature dataset; the multi-dimensional features include: sound wave features, N-gram statistical features, and music theory parameter features; The music constraint generation module is used to generate music constraints based on music theory knowledge; the music constraints include: pitch constraints, duration constraints, and intensity constraints. The optimal music generation module is used to construct an evaluation model based on the music constraints and the feature dataset as the fitness function of the evolutionary algorithm to perform computer music composition and obtain the optimal generated music.

5. An electronic device, characterized in that, The device includes a memory and a processor, the memory being used to store a computer program, and the processor running the computer program to cause the electronic device to perform the computer composition method according to any one of claims 1-3.

6. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the computer composition method as described in any one of claims 1-3.

Citation Information

Patent Citations

  • A mixed algorithm-based computer-aided composition method for popular tunes in regions south of the Yangtze River

    CN105374347A

  • Automatic composition method and system

    CN113470601A