Terminal equipment and music generation method

Through multiple group co-evolution methods, combined with particle swarm algorithms and genetic algorithms, the problems of low music quality and slow speed in existing music generation methods are solved, and high-quality and diversified music are generated.

CN118942434AActive Publication Date: 2024-11-12HISENSE ELECTRONIC TECH (WUHAN) CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202310547893.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-12
Publication Date
2024-11-12
Estimated Expiration
2043-05-12

AI Technical Summary

Technical Problem

Existing music generation methods are difficult to generate high-quality and diverse music, and the speed is slow, especially the method based on genetic algorithms is slow to converge and the music quality is not high.

Method used

Using a method of co-evolution of multiple populations, we create initial populations by setting evaluation index functions and constraints, and iteratively evolve their respective populations using particle swarm algorithms and genetic algorithms, perform exchange operations at intervals, and finally generate target music.

Benefits of technology

The quality and speed of music generation are improved, and the solution space is more comprehensively searched through the collaborative evolution of multiple groups, resulting in more diverse and high-quality music.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118942434A_ABST
    Figure CN118942434A_ABST
Patent Text Reader

Abstract

The invention provides a terminal device and a music generation method, the method can set an evaluation index function and a constraint condition of music generation, and create an initial population, the initial population including a first population and a second population. The first population is then iteratively evolved using a first algorithm to iteratively search for optimal individuals in the first population, and the second population is iteratively evolved using a second algorithm to iteratively search for optimal individuals in the second population. And executing exchange operation on the individuals in the first population and the individuals in the second population at intervals of preset iteration times. And finally, target music is generated according to an iterative evolution result, the target music is an individual whose fitness function value is greater than a preset fitness threshold value when the number of iterations is equal to the iteration threshold value, and the fitness function value is calculated according to the evaluation index function and the constraint condition. According to the method, music is generated in a multi-population co-evolution mode, and the solution space can be searched more comprehensively, so that the quality and speed of music generation are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of audio processing technology, and in particular to a terminal device and a music generation method. Background Art

[0002] Music includes basic elements such as strength, tonality, duration, and timbre. Through the combination of the above basic elements, the formal elements of music are formed, such as rhythm, melody, harmony, as well as dynamics, speed, mode, form, texture, etc. Its medium is the sound waves organized in time and in a regular pattern. Different types of music have different formal elements. According to different senses of rhythm, they can be divided into many types of music, such as folk songs, pop, rock, rap, classical, etc.

[0003] Music can be generated based on rules and templates manually set by users, but the above method lacks adaptability and creativity, and it is difficult to generate diversified and rich music. Music can also be generated based on algorithms, for example, music can be generated based on genetic algorithms, but the convergence speed of genetic algorithms is slow, which reduces the speed of music generation, and the quality of music generation is low. For another example, music can be generated based on machine learning, deep learning and other algorithms. Machine learning, deep learning and other algorithms can automatically derive new music, and the generated music is more diversified and rich, and the music quality is higher, but the above algorithms require a lot of training data and time to achieve good results. Summary of the invention

[0004] The present application provides a terminal device and a music generation method to solve the problem of low music generation quality and slow speed.

[0005] In a first aspect, the present application provides a terminal device, comprising: an audio output interface and a controller; wherein the audio output interface is configured to play music; and the controller is configured to execute the following program steps:

[0006] Set evaluation index functions and constraints;

[0007] Creating an initial population, wherein the initial population includes a first population and a second population;

[0008] Iteratively evolving the first population using a first algorithm, and iteratively evolving the second population using a second algorithm;

[0009] Performing an exchange operation on individuals in the first population and individuals in the second population at intervals of a preset number of iterations;

[0010] Generate target music, the target music is an individual whose fitness function value is greater than a preset fitness threshold when the number of iterations is equal to the iteration threshold, and the fitness function value is calculated according to the evaluation index function and the constraint condition.

[0011] In a second aspect, the present application further provides a music generation method, the method comprising:

[0012] Set evaluation index functions and constraints;

[0013] Creating an initial population, wherein the initial population includes a first population and a second population;

[0014] Iteratively evolving the first population using a first algorithm, and iteratively evolving the second population using a second algorithm;

[0015] Performing an exchange operation on individuals in the first population and individuals in the second population at intervals of a preset number of iterations;

[0016] Generate target music, the target music is an individual whose fitness function value is greater than a preset fitness threshold when the number of iterations is equal to the iteration threshold, and the fitness function value is calculated according to the evaluation index function and the constraint condition.

[0017] It can be seen from the above technical solutions that the present application provides a terminal device and a music generation method, the method can set the evaluation index function and constraints for music generation, and create an initial population, wherein the initial population includes a first population and a second population. Then use the first algorithm to iteratively evolve the first population to iteratively search for the best individual in the first population, and use the second algorithm to iteratively evolve the second population to iteratively search for the best individual in the second population. And at intervals of a preset number of iterations, perform an exchange operation on the individuals in the first population and the individuals in the second population. Finally, generate the target music according to the result of iterative evolution, wherein the target music is an individual whose fitness function value is greater than a preset fitness threshold when the number of iterations is equal to the iteration threshold, and the fitness function value is calculated according to the evaluation index function and the constraints. The method generates music by co-evolution of multiple populations, which can more comprehensively search the solution space, thereby improving the quality and speed of music generation. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 A schematic diagram of the system architecture of a terminal device provided in an embodiment of the present application;

[0020] Figure 2 A schematic diagram of the hardware configuration of a terminal device provided in an embodiment of the present application;

[0021] Figure 3 A schematic diagram of playing audio data in an embodiment of the present application;

[0022] Figure 4 Schematic diagram of the process of the music generation method in the embodiment of the present application;

[0023] Figure 5 This is a schematic diagram of the process of multiple population evolution in the embodiments of the present application;

[0024] Figure 6 This is a schematic diagram of the process of iteratively evolving the first population using the particle swarm algorithm in an embodiment of the present application;

[0025] Figure 7 This is a schematic diagram of a process of iteratively evolving the second population using a genetic algorithm in an embodiment of the present application;

[0026] Figure 8 This is a schematic diagram of a process for retaining individuals with higher fitness function values ​​in an embodiment of the present application;

[0027] Fig. 9 This is a schematic diagram of a process of iteratively evolving the second population using a genetic algorithm based on an elite retention strategy in an embodiment of the present application;

[0028] Fig.10 Schematic diagram of the exchange operation in the embodiment of the present application. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical solutions and advantages of the exemplary embodiments of the present application clearer, the technical solutions in the exemplary embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, not all of the embodiments.

[0030] Based on the exemplary embodiments shown in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application. In addition, although the disclosure in this application is introduced according to one or several exemplary examples, it should be understood that each aspect of these disclosures can also constitute a complete technical solution separately.

[0031] It should be understood that the terms "first", "second", "third", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, for example, they can be implemented according to an order other than those given in the diagrams or descriptions of the embodiments of this application.

[0032] In addition, the terms "include" and "have" and any variations thereof are intended to cover but not exclude inclusion, for example, a product or device comprising a list of components is not necessarily limited to those components expressly listed but may include other components not expressly listed or inherent to such products or devices.

[0033] Figure 1 An exemplary system architecture to which the audio localization method and terminal device of the present application can be applied is shown. Figure 1 As shown, 10 is a server, 200 is a terminal device, exemplarily including (smart TV 200a, mobile device 200b, smart speaker 200c).

[0034] In the present application, the server 10 and the terminal device 200 communicate data through various communication methods. The terminal device 200 may be allowed to communicate through a local area network (LAN), a wireless local area network (WLAN) and other networks. The server 10 may provide various content and interactions to the terminal device 20. Exemplarily, the terminal device 200 and the server 10 may send and receive information, and receive software program updates.

[0035] The server 10 may be a server that provides various services, such as a background server that provides support for audio data collected by the terminal device 200. The background server may analyze and process the received audio data, and feed back the processing results (such as endpoint information) to the terminal device. The server 10 may be a server cluster or multiple server clusters, and may include one or more types of servers.

[0036] The terminal device 200 can be hardware or software. When the terminal device 200 is hardware, it can be various electronic devices with sound collection functions, including but not limited to smart speakers, smart phones, televisions, tablet computers, e-book readers, smart watches, players, computers, AI devices, robots, smart vehicles, etc. When the terminal device 200 is software, it can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, for providing sound collection services), or it can be implemented as a single software or software module. No specific limitation is made here.

[0037] It should be noted that the music generation method provided in the embodiment of the present application can be executed by the server 10, can also be executed by the terminal device 200, and can also be executed jointly by the server 10 and the terminal device 200, and the present application does not limit this.

[0038] Figure 2 FIG. 2 shows a hardware configuration block diagram of a terminal device 200 according to an exemplary embodiment. Figure 2The terminal device 200 shown includes at least one of a communicator 220, a detector 230, an external device interface 240, a controller 250, a display 260, an audio output interface 270, a memory, a power supply, and a user interface 280. The controller includes a central processing unit, an audio processor, a graphics processor, a RAM, a ROM, and a first interface to an nth interface for input / output.

[0039] The display 260 includes a display screen component for presenting images, and a driving component for driving image display, which is used to receive image signals output from the controller, and display video content, image content, and menu control interface components and user control UI interface.

[0040] The display 260 may be a liquid crystal display, an OLED display, or a projection display, and may also be a projection device and a projection screen.

[0041] The communicator 220 is a component for communicating with an external device or server according to various communication protocol types. For example, the communicator may include at least one of a Wifi module, a Bluetooth module, a wired Ethernet module, other network communication protocol chips or a near field communication protocol chip, and an infrared receiver. The terminal device 200 may establish the sending and receiving of control signals and data signals through the communicator 220.

[0042] The user interface can be used to receive external control signals.

[0043] The detector 230 is used to collect signals from the external environment or the external interaction. For example, the detector 230 includes a light receiver, a sensor for collecting the intensity of ambient light; or, the detector 230 includes an image collector, such as a camera, which can be used to collect external environment scenes, user attributes or user interaction gestures; or, the detector 230 includes a sound collector, such as a microphone, etc., for receiving external sounds.

[0044] The sound collector can be a microphone, also called a "microphone" or "microphone", which can be used to receive the user's voice and convert the sound signal into an electrical signal. The terminal device 200 can be provided with at least one microphone. In other embodiments, the terminal device 200 can be provided with two microphones, which can not only collect sound signals but also realize the noise reduction function. In other embodiments, the terminal device 200 can also be provided with three, four or more microphones to realize the collection of sound signals, noise reduction, identification of the sound source, and realization of directional recording functions, etc.

[0045] In addition, the microphone may be built into the terminal device 200, or the microphone may be connected to the terminal device 200 by wire or wirelessly. Of course, the embodiment of the present application does not limit the position of the microphone on the terminal device 200. Alternatively, the terminal device 200 may not include a microphone, that is, the microphone is not provided in the terminal device 200. The terminal device 200 may be connected to an external microphone (also referred to as a microphone) through an interface (such as a USB interface). The external microphone may be fixed to the terminal device 200 by an external fixing (such as a camera bracket with a clip).

[0046] The external device interface 240 may include, but is not limited to, any one or more of the following interfaces: a high-definition multimedia interface (HDMI), an analog or digital high-definition component input interface (component), a composite video input interface (CVBS), a USB input interface (USB), an RGB port, etc. It may also be a composite input / output interface formed by the above multiple interfaces.

[0047] The controller 250 controls the operation of the terminal device and responds to the user's operation through various software control programs stored in the memory. The controller 250 controls the overall operation of the terminal device 200.

[0048] Exemplarily, the controller includes at least one of a central processing unit (CPU), an audio processor, a graphics processing unit (GPU), a random access memory (RAM), a read-only memory (ROM), a first interface to an nth interface for input / output, a communication bus, etc.

[0049] The audio output interface 270 is used to output audio signals to other devices to play audio. In some embodiments, the terminal device 200 has a built-in speaker, and the audio output interface 270 can input audio signals to the speaker to play audio through the speaker. In other embodiments, the terminal device 200 can be connected to an external audio device such as an amplifier, a speaker, or a loudspeaker through the audio output interface 270, and then the audio signal can be input to the external audio device to play audio through the external audio device. For example, Figure 3 As shown, the terminal device 200 can be connected to the audio device through the audio output interface 270. The audio data can be sent to the audio device through the audio output interface 270, and the audio data can be output through the audio device to play the audio.

[0050] The audio output interface 270 may include, but is not limited to, any one or more of the following interfaces: an RCA port, a butterfly clip port, an SPDIF port, and a headphone port, etc. It may also be a composite output interface formed by the above multiple interfaces.

[0051] In order to meet the user's demand for high-quality music, music can be generated by the above-mentioned terminal device 200, and the generated music can be played through the audio output interface 270. In some embodiments, music is composed of basic elements such as strength, tonality, duration, and timbre. Therefore, the user can pre-set the rules and templates for music generation, and the terminal device 200 generates music according to the above-mentioned rules and templates. For example, data parameters such as the rhythm, mode, melody, and chords of the music can be pre-set so that the terminal device 200 generates music according to the data parameters. However, the above method requires the user to manually set the rules and templates, lacks adaptability and creativity, and is difficult to generate diversified and enriched music.

[0052] In some embodiments, the terminal device 200 can also generate music by learning the characteristics of music based on neural network algorithm training. For example, music information data can be obtained as training data, and the training data can be input into the machine learning algorithm for training to learn the characteristics of music, such as the patterns and relationships between music elements, and then automatically derive new music. The above method can generate more diverse music, but it requires a lot of training data and time to achieve good results.

[0053] In some embodiments, the terminal device 200 can also simulate the biological evolution process based on a genetic algorithm to optimize the search for music that meets the requirements. Initialize the population in the genetic algorithm, and the individuals in the population can be regarded as a solution to be optimized, that is, a piece of music. Evaluate the quality of each individual in the population based on the fitness function, and perform evolutionary operations such as crossover, mutation, and selection on the population to generate a new population. The new population will replace the original population for the next round of iteration until the stop condition is met, and the optimal music is output. The above method does not require advance training, but the music generated by the genetic algorithm is of low quality and has a slow convergence speed.

[0054] In order to improve the quality and speed of music generation, some embodiments of the present application also provide a music generation method, which is applied to a terminal device 200 and is used to generate music based on a multi-population co-evolution method, thereby improving the quality and speed of music generation. Among them, the terminal device 200 that can apply the music generation method includes: an audio output interface 270 and a controller 250. The audio output interface 270 is configured to play music. The controller 250 is configured to execute the above-mentioned music generation method, Figure 4 Schematic diagram of the process of the music generation method in the embodiment of the present application. Figure 4As shown, specifically including the following:

[0055] S100: Setting evaluation index functions and constraints.

[0056] The music generation method provided in the embodiment of the present application can simultaneously perform optimization searches based on multiple populations, and different populations can interact and cooperate through information sharing, exchange or merging, so as to more comprehensively search the solution space. Before executing multi-population co-evolution, it is necessary to determine the objective function and constraints of music generation, that is, the problem of solving or optimizing based on the multi-population evolution algorithm. Therefore, the user can pre-set the evaluation index function and constraints, so that the terminal device 200 can iteratively search for the target music based on the multi-population evolution algorithm according to the evaluation index function and constraints.

[0057] The evaluation index function is an index used to judge the quality of individuals in a population. When setting the evaluation index function, it can be set according to the characteristics of music melody and rhythm. That is, in some embodiments, a music file can be obtained, and music features can be extracted from the music file, wherein the music features include but are not limited to melody features and rhythm features. Then, a quality evaluation index is generated according to the music features.

[0058] The music features may include the number of notes, note sequence, melody, etc. In some embodiments, the quality assessment index may include 9 indicators as shown in the following table, each indicator may be defined based on English symbols as shown in the following table, and each quality assessment indicator may be associated with a music feature for evaluating the quality of the music.

[0059] Quality Assessment Metrics describe ER The number of notes with the most repetitions NOJ Number of notes that jump more than an octave MAR1 First-order autocorrelation of a note sequence MAR2 Second-order autocorrelation of a note sequence MAR3 Third-order autocorrelation of a note sequence MUMax The melody has only one highest note MUMin The melody has only one lowest note Motif Number of notes that make up the motive PRMotif Number of notes of the repeated motive

[0060] In order to reduce the dimensional impact of different quality assessment indicators so far and improve the data processing speed. The quality assessment indicators can be normalized, and the indicator data is limited to a preset data range so that different quality assessment indicators have the same measurement scale. It should be noted that the embodiment of the present application does not limit the normalization method, for example, linear normalization, zero mean normalization, nonlinear normalization, batch normalization, maximum and minimum normalization, etc. Taking the maximum and minimum normalization method as an example, the quality assessment indicator can be linearly transformed, and the structure after the linear transformation can be mapped to a preset data interval (such as between the values ​​[0, 1]).

[0061] In order to meet the needs of users to generate different music, the normalized quality evaluation indicators can also be weighted. Different weights can be assigned to different quality evaluation indicators according to user needs, thereby better reflecting the importance of each quality evaluation indicator in the indicator system.

[0062] Constraints are the rules and constraints for music generation, i.e., the restrictions and requirements imposed when music is generated based on a multi-population evolutionary algorithm. When setting constraints, they can be set according to the basic elements that make up the music. For example, rhythm, melody, harmony, as well as intensity, speed, mode, form, texture, etc. In some embodiments, constraints may include a note range and a rhythm range. Among them, the range of notes includes empty beats and 7 basic pitches of Do, Re, Mi, Fa, Sol, La, Si, and the range of rhythms includes whole notes, half notes, quarter notes, ..., sixteenth notes, thirty-second notes, etc. Among them, the note data in the note range and the rhythm data in the rhythm range can be represented based on preset symbols. For example, based on digital symbols 0, 1, 2, 3, 4, 5, 6, 7, empty beats, Do, Re, Mi, Fa, Sol, La, Si are represented respectively. Based on digital symbols 1, 2, 4, ..., 16, 32, whole notes, half notes, quarter notes, ..., sixteenth notes, thirty-second notes are represented respectively.

[0063] S200: Create an initial population.

[0064] After the evaluation index function and constraint conditions of music generation are set, music can be generated based on a multi-population evolution algorithm. By creating an initial population, the initial population includes multiple populations, and different control parameters are assigned to different populations, and optimization searches are performed simultaneously based on multiple populations, so as to obtain music generated by the co-evolution of multiple populations. Among them, each population is relatively independent, and the optimal individuals generated by each population in the evolution process can be introduced into other populations through the preset immigration operator to realize information exchange between populations.

[0065] In some embodiments, Figure 5 As shown, the initial population includes a first population and a second population, that is, the initial population is divided into two sub-populations (a first population and a second population), and the first population and the second population are iteratively evolved respectively, and information can be shared between the two sub-populations, and optimization searches are performed simultaneously based on the first population and the second population to generate target music.

[0066] S300: iteratively evolving a first population using a first algorithm, and iteratively evolving a second population using a second algorithm.

[0067] Among them, the first algorithm can be a particle swarm algorithm, and the second algorithm can be a genetic algorithm based on an elite retention strategy. Both the particle swarm algorithm and the genetic algorithm based on an elite retention strategy are optimization algorithms based on iteration. The particle swarm algorithm has a high running rate and fewer control parameters. Therefore, iterating the first population based on the particle swarm algorithm can improve the search speed. Iteratively evolving the second population based on the genetic algorithm can improve stability. In addition, different sub-populations can interact and cooperate through information sharing, exchange or merging, so that the multi-population evolution algorithm can search the solution space more comprehensively in the search space, thereby improving the algorithm's search ability and global optimization performance.

[0068] The particle swarm algorithm searches for the optimal solution through collaboration and information sharing between individuals in the population. Among them, each body (particle) in the first population has two attributes, namely position and speed. The position of the individual is used to characterize the candidate solution of the optimization problem, that is, a piece of music generated in the embodiment of the present application. The speed of the individual is used to characterize the search direction and search distance of the individual. By randomly assigning an initial position and an initial speed to each individual in the search space. Then, the position of each individual is moved in turn according to the speed of each individual, the global optimal position in the search space, and the local optimal position of the individual. Among them, the position of each individual in the next generation is determined according to its position in the current generation and its own speed, and the speed can determine the direction and distance of the individual's movement during each iteration. With the iteration of the algorithm, all individuals will gather around a position, that is, the optimal solution is searched.

[0069] To facilitate understanding of the particle swarm algorithm, take the example of a flock of birds searching for the largest food source. There are food sources of different sizes in the search area, and the flock's task is to search for the largest food source (the optimal solution). During the entire search process, each bird transmits information about its position to each other, letting other birds know the location of the food source. Through the continuous movement of the flock's position, i.e. iteration, the entire flock will eventually gather around the largest food source, i.e., the optimal solution is found.

[0070] Among them, the degree of pros and cons of the position of each individual in the search space can be obtained according to the fitness function value of the individual's position in the problem to be solved or optimized. In the embodiment of the present application, the fitness function value can be calculated based on the evaluation index function and constraint conditions generated by the music. Each individual searches for the optimal solution separately in the search space, calculates the local optimal position according to the fitness function value, and shares the local optimal position with other individuals in the population, and then uses the best local optimal position among all individuals in the population as the global optimal position of the population. All individuals in the population adjust their own speed and position according to the individual's current position, current speed, local optimal position and global optimal position.

[0071] like Figure 6As shown in the figure, it is a schematic diagram of the process of iteratively evolving the first population using the particle swarm algorithm, initializing the position and velocity of the individuals in the first population, and assigning a random initial position and initial velocity to each individual in the first population. Among them, the position is used to represent the point in the search space of the first population, and the velocity is used to represent the search direction and search distance of the individual.

[0072] After assigning an initial position and initial velocity to each individual, the fitness function value of the individual's current position can be calculated, and the local optimal position and the global optimal position can be updated according to the fitness function value. Among them, the fitness function value is used to characterize the quality of the individual's current position. The local optimal position is the position with the highest individual fitness function value, and the global optimal position is the position with the highest fitness function value of the first population.

[0073] For each individual, the fitness function value of its current position can be compared with the fitness function value corresponding to its local optimal position. If the fitness function value of the current position is greater than the fitness function value corresponding to the local optimal position, the current position is updated to the local optimal position. If the fitness function value of the current position is less than or equal to the fitness function value corresponding to the local optimal position, the local optimal position is not updated.

[0074] For the first population, the local optimal positions of all individuals can be traversed. If there is a local optimal position whose fitness function value is greater than the fitness function value corresponding to the global optimal position, the local optimal position is updated to the global optimal position.

[0075] Update the position and speed of the individual, wherein the position of the individual is updated according to the local optimal position, the global optimal position and the current position of the individual, and the speed of the individual is updated according to the local optimal position and the current speed of the individual. The position of each individual in the next generation is determined by its position and speed in the current generation. During the iterative movement of the individual, the local optimal position of the individual and its corresponding fitness function value, as well as the global optimal position of the population and its corresponding fitness function value are recorded. And according to the local optimal position, the global optimal position, the current speed and current position of the individual, the global optimal position is gradually searched until the preset stop condition is reached, the iterative evolution stops, and the global optimal position of the first population is output.

[0076] In some embodiments, the stopping condition may be that when the number of iterations reaches the iteration threshold, the iterative evolution is stopped, and the global optimal position of the first population is output. For example, the user may pre-set the iteration threshold and store it in the terminal device 200. When the particle swarm algorithm is used to iteratively evolve the first population, after initializing the initial position and initial speed of the individuals in the first population, the fitness function value of the current position of the individual is calculated, and the local optimal position and the global optimal position are updated according to the fitness function value, that is, the position with the highest fitness function value of the individual is taken as the local optimal position (the initial position of the individual is taken as the local optimal position in the first iterative evolution), the local optimal positions of all individuals are traversed, and the local optimal position with the highest fitness function value is taken as the global optimal position. Then, the position of the individual is updated according to the local optimal position, the global optimal position and the current position of the individual, and the speed of the individual is updated according to the local optimal position and the current speed of the individual, that is, an iterative evolution is completed. Repeat the above iterative evolution process, and when the number of iterations reaches the iteration threshold, the iterative evolution is stopped, and the global optimal position is output. For example, the iteration threshold is 100, and when the number of iterations reaches 100, the global optimal position is output.

[0077] In some embodiments, the stopping condition may be that when the fitness function value is greater than the fitness threshold, the iterative evolution is stopped, and the global optimal position of the first population is output. That is, when the particle swarm algorithm is used to iteratively evolve the first population, the fitness function value of the current position of the individual is calculated, and the local optimal position and the global optimal position are updated according to the fitness function value. The position with the highest individual fitness function value is taken as the local optimal position, and the local optimal positions of all individuals are traversed, and the local optimal position with the highest fitness function value is taken as the global optimal position. The fitness function value of the global optimal position is compared with the fitness threshold. If the fitness function value of the global optimal position is greater than the fitness threshold, the iterative evolution is stopped, and the global optimal position of the first population is output. If the fitness function value of the global optimal position is less than or equal to the fitness threshold, the position and speed of the individual are updated according to the local optimal position, the global optimal position, the current position of the individual, and the current speed of the individual, and the above iterative evolution process is repeated. In each iterative evolution process, the fitness function value of the global optimal position is compared with the fitness threshold until the fitness function value of the global optimal position is greater than the fitness threshold, the iterative evolution is stopped, and the global optimal position is output.

[0078] Genetic algorithms search for optimal solutions by simulating the natural evolution process, converting the problem to be solved or optimized into the crossover and mutation of chromosome genes in biological evolution, and gradually approaching the optimal solution through the continuous evolution of the population. Among them, the second population includes multiple individuals (chromosomes), each of which is used to characterize a candidate solution to the optimization problem, that is, a piece of music generated in the embodiment of the present application. The individual includes multiple genetic parameters, each of which is used to characterize a component or attribute of a candidate solution. Multiple individuals (chromosomes) constitute a population, that is, multiple groups of solutions to an optimization problem constitute a population of solutions.

[0079] Among them, the degree of excellence of each individual in the search space can be obtained according to the fitness function value of the individual's position in the problem to be solved or optimized. In the embodiment of the present application, the fitness function value can be calculated based on the evaluation index function and constraint conditions generated by the music. The candidate solution corresponding to the individual with a higher fitness function value is better. The genetic parameters of each individual are randomly generated to form an initial population. The initial population is iteratively evolved. In each iterative evolution process, individuals can be selected according to the fitness function value of the individuals, and the individuals can be crossed and mutated according to the genetic operator to generate a new population composed of new individuals. It can be understood that each iterative evolution process is a process of gradually generating a better solution, and through iterative evolution, the optimal individual is generated, that is, the optimal solution is searched.

[0080] like Figure 7 , which is a flow chart of iteratively evolving the second population using a genetic algorithm, initializing individuals of the second population, wherein the individuals include a plurality of genetic parameters, and randomly generating genetic parameters of the individuals in the second population.

[0081] After initializing the individual, the fitness function value of the individual can be calculated, and the individual can be selected according to the fitness function value. Among them, the fitness function value is used to characterize the quality of the individual. Based on the selection operator, the individuals in the second population are selected, and the better individuals are directly added to the next generation population or new individuals are generated through crossover and mutation operations and then added to the next generation population. In order to improve the evolution effect. Individuals can be selected according to the fitness function value, and individuals with higher fitness function values ​​are selected.

[0082] Perform a crossover operation on the selected individuals to generate new individuals. That is, perform a crossover operation on the selected individuals based on the crossover operator to generate new individuals. The crossover operation is to exchange the genetic parameters between two individuals to generate new individuals. There are many ways of crossover operation, such as single-point crossover, two-point crossover, multi-point crossover, uniform crossover or arithmetic crossover.

[0083] Perform mutation operation on the genetic parameters of the selected individuals to generate new genetic parameters. That is, perform mutation operation on the generated new individuals based on the mutation operator to introduce new genetic parameters, thereby increasing the diversity of the search space. The mutation operation is to replace the genetic parameters on the individual locus with other allele parameters on the locus to generate new genetic parameters. Among them, the mutation operation includes many methods, such as basic position mutation, uniform mutation, boundary mutation, non-uniform mutation or Gaussian approximate mutation, etc.

[0084] The generated new individuals are added to the second population to update the second population. The new individuals generated after selection, crossover and mutation are added to the second population to update the second population, thus completing an iterative evolution. At the same time, some individuals with lower fitness function values ​​can be deleted from the second population, while some individuals with higher fitness function values ​​can be retained. For example, a threshold can be set to compare the fitness function value of each individual in the second population with the threshold, retaining individuals with fitness function values ​​greater than the threshold, and deleting individuals with fitness function values ​​less than or equal to the threshold.

[0085] After the second population completes one iteration of evolution, all individuals in the second population can be traversed, and the individual with the highest fitness function value is taken as the optimal individual. Repeat the above iterative evolution process, and an optimal individual will be generated after each iteration of evolution, and the fitness function value of the optimal individual will continue to increase with the number of iterations. Until the preset stop condition is reached, the iterative evolution stops, and the optimal individual of the second population is output.

[0086] Among them, the stop condition can refer to the stop condition setting of the above-mentioned particle swarm algorithm. When the second population is iteratively evolved using the genetic algorithm, the gene parameters of the individuals in the second population can be initialized, the fitness function value of the individuals can be calculated, the individuals can be selected according to the fitness function value, the crossover operation is performed on the selected individuals based on the crossover operator to generate new individuals, and the mutation operation is performed on the generated new individuals based on the mutation operator to introduce new gene parameters. The generated new individuals are added to the second population, and at the same time, some individuals with lower fitness function values ​​are deleted, and some individuals with higher fitness function values ​​are retained to update the second population, and the best individual in the second population (the individual with the highest fitness function value) is updated. Repeat the above iterative evolution process, and when the number of iterations reaches the iteration threshold, stop the iterative evolution and output the best individual of the second population.

[0087] A fitness threshold can also be set in advance. After each iterative evolution, the fitness function value of the best individual is compared with the fitness threshold. If the fitness function value of the best individual is greater than the fitness threshold, the iterative evolution is stopped and the best individual of the second population is output. If the fitness function value of the best individual is less than or equal to the fitness threshold, the iterative evolution continues until the best individual with a fitness function value greater than the fitness threshold is generated.

[0088] In some embodiments, individuals can be selected based on the roulette selection method by setting the selection probability of the individual, wherein the selection probability is the probability of the individual being selected, and the fitness function value is proportional to the selection probability. That is, the probability of the individual being selected is positively correlated with the fitness function value. A preset number of individuals are selected from the second population according to the selection probability. This method is similar to a roulette lottery, where the roulette is divided into a plurality of sectors of unequal area, and the greater the probability that the pointer falls on the sector with a larger area. Similarly, the higher the fitness function value of the individual, the higher the probability of its being selected.

[0089] For example, after initializing the individuals of the second population, calculate the fitness function value of each individual, set the selection probability of the individual according to the fitness function value, and select 7 individuals from the second population according to the selection probability. In this way, individuals with higher fitness function values ​​can be selected to perform crossover and mutation operations. It is also possible to select two individuals according to the selection probability based on the roulette selection method, compare the fitness function values ​​of the two individuals, and select the individual with the higher fitness function value, thus selecting an individual. Repeat the above steps until 7 individual positions are selected.

[0090] In order to retain individuals with higher fitness function values, individuals with higher fitness function values ​​can be selected from the second population and added directly to the next generation population. Figure 8 As shown, the first individual can be screened, wherein the first individual is an individual whose fitness function value is greater than the first threshold. The first individual is retained, and the first individual is added to the updated second population. That is, in each iterative evolution process, the fitness threshold of the individual is compared with the first threshold, and the first individual whose fitness threshold is greater than the first threshold is screened out, and the crossover and mutation operations are not performed on the first individual, and the crossover and mutation operations are performed on other selected individuals to generate new individuals, and add them to the second population to update the second population. It can also be that when selecting individuals, the individuals in the second population are traversed, and the individuals with the highest fitness function value are retained, that is, based on the method of the elite retention strategy, the best individuals in the population are copied to the next generation population.

[0091] For example, Fig. 9As shown, when the second population is iteratively evolved using a genetic algorithm, the genetic parameters of the individuals in the second population are initialized, the fitness function values ​​of the individuals are calculated, individuals are selected according to the fitness function values, and the first individual with the highest fitness function value is retained. A crossover operation is performed on the selected individuals based on the crossover operator to generate new individuals, and a mutation operation is performed on the generated new individuals based on the mutation operator to introduce new genetic parameters. The generated new individuals are added to the second population, and some individuals with lower fitness function values ​​are deleted, while some individuals with higher fitness function values ​​are retained. The above iterative evolution process is repeated. When the number of iterations reaches the iteration threshold, the iterative evolution is stopped, and the individual with the highest fitness function value in the second population is output.

[0092] S400: performing a swap operation on individuals in the first population and individuals in the second population at intervals of a preset number of iterations.

[0093] Since the first population and the second population are independent of each other, in order to achieve information sharing between the first population and the second population. Figure 5 As shown, an immigration condition can be set. When the immigration condition is met, the individuals in the first population and the individuals in the second population are exchanged, thereby exploring the solution space more comprehensively. The immigration condition can be to perform an exchange operation on the first population and the second population at intervals of a preset number of iterations. For example, the preset number of iterations can be 4, and the individuals in the first population and the individuals in the second population are exchanged every 4 iterations.

[0094] When performing the exchange operation, individuals with lower fitness function values ​​in the first population can be replaced by individuals with higher fitness function values ​​in the second population, and individuals with lower fitness function values ​​in the second population can be replaced by individuals with higher fitness function values ​​in the first population. Fig.10 As shown, the second individual can be selected from the first population, and the third individual can be selected from the second population, wherein the second individual is an individual whose fitness function value is greater than the second threshold, and the third individual is an individual whose fitness function value is less than the third threshold, and the second threshold is greater than the third threshold. That is, the second individual with a higher fitness function value is selected from the first population, and the third individual with a lower fitness function value is selected from the second population. The third individual in the second population is replaced by the second individual.

[0095] The above is to introduce individuals from the first population into the second population. Similarly, individuals with lower fitness function values ​​can be screened in the first population, individuals with higher fitness function values ​​can be screened in the second population, and individuals with lower fitness function values ​​in the first population can be replaced with individuals with higher fitness function values ​​in the second population to introduce individuals from the second population into the first population.

[0096] Alternatively, the individual with the highest fitness function value may be selected from the first population, the individual with the lowest fitness function value may be selected from the second population, and the individual with the lowest fitness function value in the second population may be replaced by the individual with the highest fitness function value in the first population. Accordingly, the individual with the lowest fitness function value in the first population may be replaced by the individual with the highest fitness function value in the second population, so as to realize information sharing between the first population and the second population.

[0097] S500: Generate target music.

[0098] In this embodiment, different algorithms are used to iteratively evolve the first population and the second population respectively, and information can be shared between the populations, thereby iteratively searching for the target music through the collaborative evolution of multiple populations. Wherein, referring to the above-mentioned embodiment of iteratively evolving the first population and the second population, when the target music satisfies the preset stop condition, the first population and the second population perform iterative evolution and output the individual.

[0099] The target music may be an individual whose fitness function value is greater than a preset fitness threshold when the number of iterations is equal to the iteration threshold, and the fitness function value may be calculated based on the evaluation index function and the constraint conditions. The evaluation index function is the fitness function, and the characteristics of individuals in the population may be mapped to a real value, namely, the fitness function value, according to the fitness function. In addition, a penalty term may be constructed according to the constraint conditions and applied to the fitness function. Based on the penalty function method, the fitness function value of individuals that violate the constraint conditions may be reduced, and then the fitness function value may be calculated based on the evaluation index function and the constraint conditions.

[0100] By pre-setting an iteration threshold, the individuals output after each generation of evolution in each population are stored to form a candidate set. When the number of iterative evolutions of the first population and the second population reaches the iteration threshold, the iterative evolution is stopped, and the target individuals whose fitness function values ​​are greater than the preset fitness threshold are screened out from the candidate set, and the target music is generated based on the target individuals.

[0101] Alternatively, an iteration threshold may be pre-set. When the number of iterative evolutions of the first population and the second population reaches the iteration threshold, the iterative evolution is stopped, the individuals output after the first population and the second population are obtained, and the target music is generated based on the individual with the highest fitness function value.

[0102] The target music may also be an individual whose fitness function value is greater than a preset fitness threshold, that is, when different algorithms are used to iteratively evolve the first population and the second population respectively, after each iterative evolution, the individuals output after the first population and the second population are respectively obtained. If there is an individual whose fitness function value is greater than the preset fitness threshold, the iterative evolution is stopped, and the target music is generated based on the individual.

[0103] In this embodiment, the population is divided into a first population and a second population, and the first population is iteratively evolved using a particle swarm algorithm to improve the search speed. The second population is iteratively evolved using a genetic algorithm to improve the algorithm stability. Different populations can share information, so that the multi-population evolution algorithm can search the solution space more comprehensively in the search space, thereby improving the quality and speed of music generation.

[0104] Based on the above music generation method, some embodiments of the present application further provide a terminal device 200, including: an audio output interface 270 and a controller 250. The audio output interface 270 is configured to play music, and the controller 250 is configured to execute the following program steps:

[0105] S100: Setting evaluation index functions and constraints.

[0106] S200: Create an initial population.

[0107] The initial population includes the first population and the second population.

[0108] S300: iteratively evolving a first population using a first algorithm, and iteratively evolving a second population using a second algorithm.

[0109] S400: performing a swap operation on individuals in the first population and individuals in the second population at intervals of a preset number of iterations.

[0110] S500: Generate target music.

[0111] Among them, the target music is an individual whose fitness function value is greater than a preset fitness threshold when the number of iterations is equal to the iteration threshold, and the fitness function value is calculated according to the evaluation index function and the constraint conditions.

[0112] It can be seen from the above technical solutions that the terminal device and the music generation method provided by the above embodiments can set the evaluation index function and constraints for music generation, and create an initial population, wherein the initial population includes a first population and a second population. Then use the first algorithm to iteratively evolve the first population to iteratively search for the best individual in the first population, and use the second algorithm to iteratively evolve the second population to iteratively search for the best individual in the second population. And at intervals of a preset number of iterations, perform exchange operations on individuals in the first population and individuals in the second population. Finally, generate target music according to the result of iterative evolution, wherein the target music is an individual whose fitness function value is greater than a preset fitness threshold when the number of iterations is equal to the iteration threshold, and the fitness function value is calculated according to the evaluation index function and the constraints. The method generates music by using a multi-population co-evolution method, which can search the solution space more comprehensively, thereby improving the quality and speed of music generation.

[0113] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

[0114] For the convenience of explanation, the above description has been made in conjunction with specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or limit the embodiments to the specific forms disclosed above. Based on the above teachings, various modifications and variations can be obtained. The selection and description of the above embodiments are to better explain the principles and practical applications, so that those skilled in the art can better use the embodiments and various different variations of the embodiments suitable for specific use considerations.

Claims

1. A terminal device, characterized in that: include: An audio output interface, configured to play music; The controller is configured as: Set evaluation index functions and constraints; Creating an initial population, wherein the initial population includes a first population and a second population; Iteratively evolving the first population using a first algorithm, and iteratively evolving the second population using a second algorithm; Performing an exchange operation on individuals in the first population and individuals in the second population at intervals of a preset number of iterations; Generate target music, the target music is an individual whose fitness function value is greater than a preset fitness threshold when the number of iterations is equal to the iteration threshold, and the fitness function value is calculated according to the evaluation index function and the constraint condition.

2. The terminal device according to claim 1, characterized in that: The controller performs the step of setting the evaluation index function and is configured to: Get music files; Extracting music features from the music file, wherein the music features include melody features and rhythm features; generating a quality assessment index according to the music features; A normalization process is performed on the quality assessment index, and a weighting process is performed on the normalized quality assessment index.

3. The terminal device according to claim 1, characterized in that: The first algorithm is a particle swarm algorithm, and the second algorithm is a genetic algorithm based on an elite retention strategy.

4. The terminal device according to claim 1, characterized in that: The controller performs the step of iteratively evolving the first population using a first algorithm, and is configured to: Initializing the position and velocity of an individual in the first population, wherein the position is used to represent a point in the search space of the first population, and the velocity is used to represent a search direction and a search distance of the individual; Calculating the fitness function value of the current position of the individual; Update the local optimal position and the global optimal position according to the fitness function value, wherein the local optimal position is the position where the individual fitness function value is the highest, and the global optimal position is the position where the first population fitness function value is the highest; updating the position of the individual according to the local optimal position, the global optimal position and the current position of the individual, and updating the speed of the individual according to the local optimal position and the current speed of the individual; When the number of iterations reaches an iteration threshold, the global optimal position of the first population is output.

5. The terminal device according to claim 1, characterized in that: The controller performs the step of iteratively evolving the second population using a second algorithm, and is configured to: Initializing individuals of the second population, wherein the individuals include a plurality of genetic parameters; Calculating the fitness function value of the individual; Selecting an individual according to the fitness function value; Performing a crossover operation on the selected individuals to generate new individuals; Performing a mutation operation on the selected genetic parameters of the individual to generate new genetic parameters; adding the generated new individuals to the second population to update the second population; When the number of iterations reaches an iteration threshold, the individuals whose fitness function values ​​are greater than a preset fitness threshold are output.

6. The terminal device according to claim 5, characterized in that: The controller performs the step of selecting an individual according to the fitness function value, and is further configured to: Setting the selection probability of the individual, wherein the fitness function value is proportional to the selection probability; A preset number of individuals are selected from the second population according to the selection probability.

7. The terminal device according to claim 5, characterized in that: The controller performs the step of selecting an individual according to the fitness function value, and is further configured to: Screening a first individual, where the first individual is an individual whose fitness function value is greater than a first threshold; The first individual is retained, and the first individual is added to the updated second population.

8. The terminal device according to claim 1, characterized in that: The controller performs the step of performing an exchange operation on individuals in the first population and individuals in the second population, and is further configured to: Screening a second individual from the first population, and screening a third individual from the second population, wherein the second individual is an individual whose fitness function value is greater than a second threshold, and the third individual is an individual whose fitness function value is less than a third threshold, and the second threshold is greater than the third threshold; The third individual in the second population is replaced by the second individual.

9. The terminal device according to claim 1, characterized in that: The controller is also configured to: Respectively obtaining individuals output after the first population and the second population perform iterative evolution; If there is an individual whose fitness function value is greater than a preset fitness threshold, the iterative evolution is stopped, and the target music is generated based on the individual.

10. A music generation method, characterized in that: The method comprises: Set evaluation index functions and constraints; Creating an initial population, wherein the initial population includes a first population and a second population; Iteratively evolving the first population using a first algorithm, and iteratively evolving the second population using a second algorithm; Performing an exchange operation on individuals in the first population and individuals in the second population at intervals of a preset number of iterations; Generate target music, the target music is an individual whose fitness function value is greater than a preset fitness threshold when the number of iterations is equal to the iteration threshold, and the fitness function value is calculated according to the evaluation index function and the constraint condition.

Citation Information

Patent Citations

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

    CN105374347A

  • D2D communication resource optimization method based on multi-population genetic algorithm

    CN106792451A

  • Differential evolution algorithm with variable crossover probability factor

    CN107909152A

  • Feature selection method based on improved shuffled frog leaping algorithm

    CN110288075A

  • Music generation method and device

    CN110444185A