WO2021218158A1 - Harmony matching method and apparatus, electronic device, and computer readable medium - Google Patents

Harmony matching method and apparatus, electronic device, and computer readable medium Download PDF

Info

Publication number
WO2021218158A1
WO2021218158A1 PCT/CN2020/134894 CN2020134894W WO2021218158A1 WO 2021218158 A1 WO2021218158 A1 WO 2021218158A1 CN 2020134894 W CN2020134894 W CN 2020134894W WO 2021218158 A1 WO2021218158 A1 WO 2021218158A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
segment
chords
melody
preset
Prior art date
Application number
PCT/CN2020/134894
Other languages
French (fr)
Chinese (zh)
Inventor
蒋慧军
黄尹星
姜凯英
徐伟
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021218158A1 publication Critical patent/WO2021218158A1/en

Links

Images

Classifications

    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10HELECTROPHONIC MUSICAL INSTRUMENTS; INSTRUMENTS IN WHICH THE TONES ARE GENERATED BY ELECTROMECHANICAL MEANS OR ELECTRONIC GENERATORS, OR IN WHICH THE TONES ARE SYNTHESISED FROM A DATA STORE
    • G10H1/00Details of electrophonic musical instruments
    • G10H1/36Accompaniment arrangements
    • G10H1/38Chord
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/60Information retrieval; Database structures therefor; File system structures therefor of audio data
    • G06F16/68Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually
    • G06F16/683Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually using metadata automatically derived from the content
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N7/00Computing arrangements based on specific mathematical models
    • G06N7/01Probabilistic graphical models, e.g. probabilistic networks
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10HELECTROPHONIC MUSICAL INSTRUMENTS; INSTRUMENTS IN WHICH THE TONES ARE GENERATED BY ELECTROMECHANICAL MEANS OR ELECTRONIC GENERATORS, OR IN WHICH THE TONES ARE SYNTHESISED FROM A DATA STORE
    • G10H1/00Details of electrophonic musical instruments
    • G10H1/36Accompaniment arrangements
    • G10H1/38Chord
    • G10H1/383Chord detection and/or recognition, e.g. for correction, or automatic bass generation
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10HELECTROPHONIC MUSICAL INSTRUMENTS; INSTRUMENTS IN WHICH THE TONES ARE GENERATED BY ELECTROMECHANICAL MEANS OR ELECTRONIC GENERATORS, OR IN WHICH THE TONES ARE SYNTHESISED FROM A DATA STORE
    • G10H7/00Instruments in which the tones are synthesised from a data store, e.g. computer organs
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10HELECTROPHONIC MUSICAL INSTRUMENTS; INSTRUMENTS IN WHICH THE TONES ARE GENERATED BY ELECTROMECHANICAL MEANS OR ELECTRONIC GENERATORS, OR IN WHICH THE TONES ARE SYNTHESISED FROM A DATA STORE
    • G10H2210/00Aspects or methods of musical processing having intrinsic musical character, i.e. involving musical theory or musical parameters or relying on musical knowledge, as applied in electrophonic musical tools or instruments
    • G10H2210/031Musical analysis, i.e. isolation, extraction or identification of musical elements or musical parameters from a raw acoustic signal or from an encoded audio signal
    • G10H2210/066Musical analysis, i.e. isolation, extraction or identification of musical elements or musical parameters from a raw acoustic signal or from an encoded audio signal for pitch analysis as part of wider processing for musical purposes, e.g. transcription, musical performance evaluation; Pitch recognition, e.g. in polyphonic sounds; Estimation or use of missing fundamental

Definitions

  • This application relates to the field of computer technology. Specifically, this application relates to a method, a device, an electronic device, and a computer-readable medium for matching harmony.
  • Harmony is a very important part in tonal music, and it is one of the basic means of music. Although a melody can be presented independently, the addition of harmony for accompaniment can increase the richness of the melody and make the sense of hearing fuller. In the analysis of western traditional music, harmony is a very important dimension.
  • the method of using the first note of each bar as the root note of the chord is generally used as the melody to match the corresponding harmony.
  • the inventor of the present application has discovered that there are multiple possible harmony combinations for the same melody.
  • the unit of measure is one measure and the first note of each measure is used as the root note of the melody match harmony, its limitations are more limited. Large; and the harmony corresponding to a melody segment is closely related to the information of all the notes in the entire melody segment.
  • the prior art cannot consider the correlation between the chords matched by adjacent bars in the melody and the information of all the notes between adjacent chords , Resulting in an abrupt harmony performance effect matched by the melody.
  • a method for matching harmony includes: dividing the melody segment into multiple target segments based on the beat of the melody segment; respectively calculating multiple preset chords and chords based on the note sequence of each target segment The matching degree of each target segment, and for each target segment, the preset chord with the highest matching degree is used as the target chord of the corresponding target segment; based on the target chords corresponding to the multiple target segments, the Harmony clips with melody clips.
  • a device for matching harmony including: a dividing module for dividing the melody segment into multiple target segments based on the beat of the melody segment;
  • the note sequence calculates the matching degree between a plurality of preset chords and the respective target segments, and for each target segment, the preset chord with the highest matching degree is used as the target chord of the corresponding target segment;
  • a generating module is used to generate The target chords respectively corresponding to the multiple target segments generate a harmony segment matched with the melody segment.
  • an electronic device in a third aspect of the present application, includes: a memory and a processor; a computer program is stored in the memory; and the processor is configured to execute the following method when the computer program is running:
  • a harmony segment matched with the melody segment is generated.
  • a computer-readable medium on which a computer program is stored, and when the computer program is executed by a processor, the following method is implemented:
  • a harmony segment matched with the melody segment is generated.
  • the present application divides the melody segments based on the beats of the melody segments.
  • adjacent target segments are closely related; because the adjacent target segments are strongly related, it makes adjacent note sequences It also has strong relevance; when calculating the matching degree of multiple preset chords with each target segment based on the note sequence of each target segment, and using the preset chord with the highest matching degree as the target chord of the corresponding target segment, it is beneficial Fully consider the information of all the notes between the chords matched by the adjacent target segments, and the adjacent target chords corresponding to the adjacent target segments are strongly related. Generating harmony segments based on the target chords corresponding to multiple target segments is beneficial to improve the melody-based segments Match the accuracy of the harmony segment and the smoothness of the overall performance of the harmony segment.
  • FIG. 1 is a flowchart of a method for matching harmony provided by an embodiment of the application
  • FIG. 2 is a flowchart of a method for matching harmony provided by an embodiment of the application
  • FIG. 3 is a flowchart of a method for matching harmony provided by an embodiment of the application.
  • FIG. 4 is a flowchart of a method for matching harmony provided by an embodiment of the application.
  • FIG. 5 is a flowchart of a method for matching harmony provided by an embodiment of the application.
  • FIG. 6 is a flowchart of a method for matching harmony provided by an embodiment of the application.
  • FIG. 7 is a flowchart of a method for matching harmony provided by an embodiment of the application.
  • FIG. 8 is a schematic diagram of generating a harmony segment in the method for collocation harmony provided by an embodiment of the application.
  • FIG. 9 is a schematic structural diagram of a device for matching harmony provided by an embodiment of the application.
  • FIG. 10 is a schematic structural diagram of an electronic device provided by an embodiment of the application.
  • the technical solution of this application can be applied to the fields of artificial intelligence, smart city, blockchain and/or big data technology to perform harmony matching and realize smart life.
  • the data involved in this application such as melody segments and/or harmony segments, can be stored in a database, or can be stored in a blockchain, such as distributed storage through a blockchain, which is not limited in this application.
  • Melody segment Melody is the primary element of music. It usually refers to an organized and rhythmic sequence formed by several musical tones through artistic conception. The melody fragment can be a certain part of the sequence, or it can be a complete sequence.
  • Beat is a unit of measuring rhythm. In music, a series of beats with a certain strength and weakness are repeated at regular intervals. Such as 2/4, 4/4, 3/4 beat and so on. The beat expresses the fixed unit time value and the organizational form of strength and weakness in the music.
  • Note sequence is a symbol used to record notes of different lengths. Whole notes, half notes, quarter notes, eighth notes, and sixteenth notes are the most common notes.
  • the note sequence refers to a sequence composed of multiple notes, which specifically includes note information and the order of each note name, where the note information includes the duration of the note.
  • Chord refers to a group of sounds with a certain interval relationship, that is, three or more tones are combined in the vertical direction according to the superimposed relationship of thirds or non-thirds, and they are called chords.
  • Harmony refers to a sound combination composed of two or more different sounds sounded at the same time according to a certain rule. It includes chords and harmony progression, among which chords are the basic material of harmony, consisting of 3 or more different sounds, combined according to three-degree stacking or other methods at the same time. This is the longitudinal structure of harmony; harmony Progression refers to the sequential connection of chords, which is the horizontal structure of harmony. Harmony segment refers to a sequence formed by successively connecting multiple chords, and its length is generally the same as the melody segment.
  • this application provides a method of matching harmony, which can be specifically executed by the electronic device of the embodiment of this application.
  • This application includes:
  • S101 divides the melody segment into multiple target segments based on the beat of the melody segment
  • S102 based on the note sequence of each target segment, respectively calculates the matching degree between a plurality of preset chords and the target segment, and for each target segment, the chord with the highest matching degree is used as the target chord of the corresponding target segment;
  • S103 generates a harmony segment matched with the melody segment based on the target chords respectively corresponding to the multiple target segments.
  • the melody segment is divided into a plurality of target segments based on the beat of the melody segment.
  • the melody segment may be inputted locally by the user or obtained from a third-party application program, or inputted by the user in an existing storage. It is specified in multiple melody segments; the acquired melody segment is a MIDI file, which is a binary file, and each note of the melody segment is recorded as a number.
  • the beat in the same melody segment is fixed, such as 4/4 beats.
  • the melody segment can be divided into one target segment per measure based on the beat of the melody segment, or it can be divided into multiple target segments per measure. Multiple bars are divided into a target segment; a melody segment is divided into at least one target segment.
  • the above melody segment can also be stored in a node of a blockchain.
  • step S102 based on the note sequence of each target segment, the matching degree between a plurality of preset chords and the target segment is calculated, and for each target segment, the chord with the highest matching degree is used as the target chord of the corresponding target segment ,
  • the note sequence is composed of the notes in the target segment arranged in the order of performance; the preset chords include at least two, which can be adjusted according to actual matching requirements; different preset chords and target segments will have different collocations
  • the matching degree between the preset chord and the target segment is calculated based on the note sequence, specifically related to the note name corresponding to the note, and the matching degree obtained by matching multiple preset chords with each target segment The highest preset chord serves as the target chord corresponding to the corresponding target segment, and one target segment corresponds to one target chord.
  • this embodiment uses the hidden Markov model combined with the Viterbi algorithm (HMM Viterbi algorithm) to calculate the matching degree between multiple preset chords and each target segment, and for each target segment, the preset with the highest matching degree is calculated
  • the chord as the target chord of the corresponding target segment is specifically based on the HMM Viterbi algorithm to backtrack from the target segment sorted at the end of the melody segment to obtain the chord sequence with the greatest probability (consisting of the target chord corresponding to each target segment), namely The hidden state sequence.
  • step S103 based on the target chords respectively corresponding to the multiple target segments, a harmony segment that matches the melody segment is generated.
  • the harmony segment is used to add when the melody segment is performed, so as to enrich the overall performance of the music.
  • Harmony segment is formed by successively connecting multiple target chords (harmonization progress), wherein since each target chord corresponds to the beat of the melody segment, the harmony segment generated based on the multiple target chords has the same beat as the melody segment.
  • each target chord is sorted based on the performance order of the corresponding target segment in the melody segment, and one target segment corresponds to one target chord, and a harmony segment with the same performance form as the melody segment is generated.
  • the embodiment of the present application divides the melody segment based on the beat of the melody segment, and the adjacent target segments among the multiple target segments that are divided into are closely related; because the adjacent target segments are strongly related, it makes the adjacent target segments
  • the note sequence also has a strong correlation; when calculating the matching degree of multiple preset chords with each target segment based on the note sequence of each target segment, and using the preset chord with the highest matching degree as the target chord of the corresponding target segment, It is helpful to fully consider the information of all the notes between the chords matched by the adjacent target segments, and the adjacent target chords corresponding to the adjacent target segments are strongly related. Generating harmony segments based on the target chords corresponding to multiple target segments is beneficial to improve the melody The accuracy of the segment matching the harmony segment, and the smoothness of the overall performance of the harmony segment.
  • step S101 divides the melody segment into multiple target segments based on the beat of the melody segment, including:
  • S201 Determine a variable parameter based on the beat of the melody segment; wherein the variable parameter is a preset value or a chord density set by the user based on the beat of the melody segment;
  • S202 divides the melody segment into multiple target segments based on the variable parameter.
  • variable parameter is the parameter that can be matched with chords in each measure of the melody segment.
  • a target segment of 4/4 beats of a measure has a total note length of 4 beats, and the maximum number of chords that can be matched is 4;
  • the variable parameter can be set to 1, that is, assuming that the beat of the melody segment is 4/4 beats, and the variable parameter is the minimum number of chords that can be matched, the melody segment is performed in a unit of 4 beats.
  • chord value interval such as a 4/4 beat melody segment
  • Chord density refers to the number of chords matched in a target segment. For example, a target segment in 4/4 time. The chord density includes 1, 2, 3, and 4. When the chord density is 1, a target segment matches one chord.
  • variable parameter is the chord density set by the user based on the beat of the melody segment
  • first determine the beat of the melody segment assuming it is 4/4 beats, and the user sets the chord density to 2, then each measure will be divided into 2 segments.
  • the melody segment is divided to form multiple target segments with a note length of 2 beats.
  • the step S101 to divide the melody segment into multiple target segments based on the beat of the melody segment further includes:
  • the melody segment is divided into multiple target segments based on the note duration.
  • the note duration value of a whole note is 1, the note duration value of a half note is 1/2, and so on.
  • a whole note is included, it can match up to one chord; if it includes two half notes, it can match up to two chords.
  • the standard for dividing the melody segment is a variable parameter, which can be set by the user based on the beat of the melody segment (in the harmony model, an interface is provided for the user to set the variable parameter)
  • the user can adjust the variable parameters (chord density) based on actual needs. For example, when the user is not familiar with the melody segment, lower the variable parameters, so that fewer chords are matched and the performance is reduced. Difficulty.
  • this embodiment divides the melody segment according to the variable parameters to form multiple target segments, which is beneficial to enrich the number of matched chords and strengthen the relevance of the chords matched by adjacent target segments; further, when the variable parameter is When the chord density is set by the user, based on the different needs of the user, the number of chords and the types of chords that need to be matched to divide the melody segment into multiple target segments are different, which is beneficial to strengthen the closeness of human-computer interaction and improve the user experience.
  • step S102 calculates the matching degree between a plurality of preset chords and each target segment based on the note sequence of each target segment, and for each target segment, the highest matching degree is calculated
  • the preset chord of as the target chord of the corresponding target segment including:
  • S301 determines target parameters based on the note sequence of each target segment and multiple preset chords
  • a Hidden Markov Model is used to calculate the matching degree of multiple preset chords with the respective target segments based on the target parameters, and the target chords corresponding to the respective target segments are obtained, and the target chords are corresponding to the corresponding target segments.
  • a multi-selection and multi-step model is constructed to solve the optimal selection problem, and multiple preset chords and each target are calculated in sequence
  • the matching degree of the segment collocation (log likelihood value).
  • the pitch names (pitches_name_class) involved in this embodiment include: C, #C, D, #D, E, F, #F, G, #G, A, #A, B; preset chords (chords) Including a variety of chord types.
  • the chord types include: major, minor, augmented, diminished, major7, minor7, dominant7, half The minus triad is half-diminished.
  • chord candidates Due to the situation that some note compositions may not correspond to any chords, a no chord is added to the preset chords to indicate no chord collocation; through the collocation of each note name with multiple preset chords, a total of 97 (12*8+1)
  • chord candidates that is, there are a total of 97 chord candidates.
  • the probability of each note name appears is 1/12; when the preset chord corresponds to a certain note name, the probability of each preset chord appears is 1/9.
  • the above note names and preset chords can be adjusted based on actual conditions.
  • the target parameter is the calculation parameter of the hidden Markov model, which is determined by the note sequence of each target segment and multiple preset chords.
  • the note sequence of the target segment includes note information and the order of each note name in the target segment, and the note information includes the length of time each note name appears in the corresponding target segment.
  • a set of target parameters is jointly determined based on the note sequence of each target segment and multiple preset chords.
  • the hidden Markov model can infer the matching degree of multiple preset chords with each target segment based on the target parameters through the Viterbi algorithm, and obtain the corresponding target chords of each target segment, and output the multiple target chords in sequence The target chord sequence.
  • the target chord is the preset chord with the highest degree of matching with the corresponding target segment.
  • step S301 determines target parameters based on the note sequence of each target segment and a plurality of preset chords, including:
  • S403 calculates the state transition probability of a combination of multiple preset chords and each key signature based on the preset change probability; wherein, the preset change probability includes the key signature change probability and the preset chord change probability;
  • S404 generates target parameters based on the note sequence, collocation probability, probability distribution, and state transition probability of each target segment.
  • step S401 determining the collocation probability of a plurality of preset chords and each target segment based on the note sequence of each target segment. Specifically, according to the note sequence of each target segment, determine the number of 97 chord candidates in the corresponding target segment. Probability. Among them, the note sequence includes note information.
  • step S402 the probability distribution of multiple preset chords in each key signature is determined based on the interval relationship between the multiple key signatures in the melody segment and each preset chord.
  • the relationship between pitches that is, the distance between two tones in pitch, is called degree.
  • Each key signature corresponds to each note name involved in the melody segment.
  • calculate each preset chord composition tone in and out of the key calculate each preset chord composition tone in and out of the key, and get the preset chord under each key signature Probability distribution (key_chord_distribution).
  • the external tone of the tonal can be considered as a certain key signature key, the component tone of the preset chord is not the natural tone under the key.
  • the preset chords are called the external chord of this key.
  • the D major triad D#F A is the outer key
  • the D minor triad D F A is the inner key.
  • the probability distribution of multiple preset chords under each key signature can also be calculated according to the condition of minor tonality, polytonality, and the accompaniment effect of the collocation of out-of-tune chords and melody.
  • step S403 the state transition probability of a combination of multiple preset chords and each key signature is calculated based on the preset change probability; wherein, the preset change probability includes the key signature change probability and the preset chord change probability, specifically, each tone
  • the key signature corresponding to the name includes C,#C,D,#D,E,F,#F,G,#G,A,#A,B.
  • the note name may include all note names in music theory knowledge. Among them, the number of combinations of a key signature and multiple preset chords is determined by the number of preset chords, and the combination of a certain key signature and a certain preset chord is characterized as a combination of key signature and preset chord.
  • the state transition probability represents the probability of each key signature and multiple preset chords conversion. For example, in the C major key, the probability of the preset chords being converted from 1, 3, and 5 to #1, 3, and #5. In the HMM Viterbi algorithm solution method, it is specifically characterized as a matrix corresponding to the state transition probability of all key signatures and preset chord combinations.
  • the preset variation probability matches the multiple note names and multiple preset chords involved in this embodiment after multiple tests, and can be adapted and adjusted under actual conditions.
  • the following formulas (1) and (2) can be used to calculate the state transition probability of each key signature and multiple preset chord combinations.
  • is the probability that the preset chord chord changes
  • is the probability that the key signature key changes
  • f(h t ) is the probability key_chord_distribution of the preset chord and key signature combination in a certain key signature key
  • step S404 target parameters are generated based on the note sequence, collocation probability, probability distribution, and state transition probability of each target segment, specifically, the visible state sequence is determined based on the note sequence of each target segment; for example, a target segment of 4/4 beat
  • is 4-3-5-2
  • is 1-4-6-7
  • the visible state sequence is 4-3- 5-2-1-4-6-7.
  • the visible state sequence is in a known observation state, and the visible state sequence corresponds to the sequence of notes in the melody segment.
  • the visible state sequence derived from the observable melody segment, the collocation probability of multiple preset chords and each target segment, the probability distribution of multiple preset chords in each key signature, and multiple preset chords and each generates the target parameter, and the process of generating the target parameter is the training process of the hidden Markov model.
  • step S401 determines the matching probabilities of multiple preset chords and each target segment based on the note sequence of each target segment, including:
  • S501 Determine the duration vector of each note name in each target segment based on the note sequence of each target segment
  • S502 based on the duration vector, determines the collocation probability of a plurality of preset chords and the respective target segments.
  • step S501 determining the duration vector of each note name in each target segment based on the note sequence of each target segment.
  • the note sequence includes determining the duration information of each note name appearing in each target segment, which may be based on the duration.
  • the information determines the duration vector, and the duration vector represents the length and direction of each sound name corresponding to the middle sound of each target segment.
  • the time length vector (note_pitch_vector) of each note name in each target segment is determined, such as 4/4 shot target segment A:
  • step S502 determining the collocation probability of multiple preset chords and each target segment based on the duration vector. Specifically, assume that the target segment A is shot in 4/4:
  • the matching probability of the preset chord DFA is 0.5
  • the matching probability of CEG is 0.75
  • the matching probability of CbEG is 0.75
  • the matching probability of BDF is 0.5.
  • the matching probability is 0.25.
  • step S302 respectively calculates the matching degree between a plurality of preset chords and the respective target segments based on the target parameters, and obtains the target chords corresponding to the respective target segments, including:
  • S601 based on the target parameters, respectively calculate the matching degree between a plurality of preset chords and the target segment sorted at the top of the melody segment;
  • the step of calculating the matching degree between a plurality of preset chords and the first target segment is performed: Target parameters, and the matching degree between multiple preset chords and the previous target segment, respectively calculating the matching degrees between the multiple preset chords and the first target segment, and sorting the next target after the first target segment A segment as a first target segment; wherein the preamble target segment is a previous target segment sorted before the first target segment in the melody segment;
  • S603 re-execute the step of calculating the matching degree between the multiple preset chords and the first target segment, until the calculation of the matching degree between the multiple preset chords and the respective target segment is completed;
  • the degree of matching between a plurality of preset chords and each target segment is sequentially calculated, and the target chord corresponding to each target segment is obtained.
  • the target chord is the preset chord with the highest degree of matching with the corresponding target segment, which is specifically the prediction process of the hidden Markov model.
  • step S601 the matching degree between a plurality of preset chords and the target segment sorted at the top of the melody segment is calculated separately based on the target parameter. Specifically, the calculation of the matching degree starts with the target segment sorted at the top of the melody segment, and combines The target parameters respectively calculate the matching degree of multiple preset chords with the target segment.
  • step S602 if the currently calculated target segment is ranked first in the melody segment, it is determined that the currently calculated target segment is the first target segment, and the step of calculating the matching degree between a plurality of preset chords and the first target segment is performed: The target parameter and the matching degree between the multiple preset chords and the pre-order target segment are calculated respectively, and the matching degree between the multiple preset chords and the first target segment is calculated, and the sequence is sorted after the first target segment.
  • step S603 the step of calculating the matching degree between the multiple preset chords and the first target segment is re-executed, until the matching degree calculation between the multiple preset chords and the respective target segment is completed, specifically, in the calculation process of the matching degree , Obtain each target segment sorted after the first position of the melody segment in order, combine the target segment and the matching degree of multiple preset chords with the previous target segment, calculate the multiple preset chords and sort them after the first position of the melody segment. The matching degree of each target segment.
  • Example 1 The melody segment is divided into 4 target segments. Based on the sort position in the melody segment, the sequence composed of the 4 target segments is: D1-D2-D3- D4; In the step of calculating the matching degree, the first step is to obtain the target segment D1, and the target parameters are combined to calculate the matching degree of multiple preset chords with the target segment D1; the second step is to obtain the target segment D2, combining the target parameters, And the matching degree between multiple preset chords and the target segment D1, respectively calculate the matching degree between multiple preset chords and the target segment D2; the third step, obtain the target segment D3, combine the target parameters, and multiple preset chords and targets The matching degree of segment D2 is calculated separately for the matching degree of multiple preset chords and the target segment D3; the fourth step is to obtain the target segment D4, combining the target parameters and the matching degree of multiple preset chords with the target segment D3, respectively The degree of matching between multiple preset chords and the target segment
  • the first step is to obtain the target segment D4, and the target chord H4 of the target segment D4 is determined;
  • the second step is to obtain the target segment D3, and the target chord H3 of the target segment D3 is determined;
  • the third step is to obtain the target segment D2 , Determine the target chord H2 of the target segment D2;
  • the fourth step obtain the target segment D1, determine the target chord H1 of the target segment D1; since then, the step of backtracking is completed.
  • the sequence of H3 and H4 can form the target chord sequence.
  • the obtained matching degree is not only calculated for a single target segment, it comprehensively considers multiple preset chords.
  • the matching degree with the previous target segment, and the matching degree between the target segment sorted in other positions of the melody segment and multiple preset chords has nothing to do. This improves the relevance of the target chords matched between adjacent segments and also improves The overall performance smoothness of the harmony segment generated by the target chords corresponding to the multiple target segments.
  • the matching degree between multiple preset chords and each target segment is the multiple pairs of each target segment under all key signatures and preset chord combinations (that is, 1164 combinations).
  • Log-likelihood the log-likelihood is calculated by the Viterbi algorithm based on the target parameters.
  • the degree of matching of the target segment sorted at the top of the melody segment with multiple preset chords is calculated to obtain multiple combinations of the target segment under all key signatures and preset chords.
  • each target segment sorted after the first place of the melody segment is based on the matrix of the state transition probability of the combination of the key signature and the preset chord, and combined with the relevant information of the previous target segment (multiple preset chords and pre-targets Segment matching degree), and calculate the multiple log-likelihood values of each target segment sorted after the first of the melody segment under all key signatures and preset chord combinations.
  • the final model corresponds to how much each target segment will be stored.
  • the model determines the target chords corresponding to each target fragment by tracing back from the target fragments sorted at the end of the melody fragment, and outputs a target chord sequence composed of multiple target chords; among them, the target chord is corresponding to The preset chord with the highest matching degree of the target segment.
  • the hidden state sequence (target chord sequence) is inferred based on the observable visible state sequence (melody segment) and state transition probability; specifically, the following 5 are included step:
  • Hidden Markov model is used to calculate the matching degree of each target segment with multiple preset chords based on the visible state sequence, collocation probability, probability distribution and state transition probability through the Viterbi algorithm. For each target segment, the highest matching degree is calculated.
  • the preset chord is used as the target chord of the corresponding target segment, and a target chord sequence (consisting of multiple target chords in sequence) that is composed of each target chord and has the greatest probability of matching with the melody segment is obtained.
  • the degree of matching between a plurality of preset chords and the target segment sorted at the top of the melody segment is calculated based on the target parameters; if the currently calculated target segment is sorted after the top of the melody segment, it is determined that the currently calculated The target segment is the first target segment, and the step of calculating the matching degree between a plurality of preset chords and the first target segment is performed: based on the target parameter and the matching degree between the plurality of preset chords and the pre-order target segment, calculating the matching degree respectively
  • the degree of matching between a preset chord and the first target segment will be the next target segment sorted after the first target segment as the first target segment; wherein, the preamble target segment is in the melody
  • the previous target segment sorted before the first target segment in the segments that is, the target segment sorted one digit before the first target segment
  • re-execute the step of calculating the matching degree between a plurality of preset chords and the first target segment Until the matching degree calculation between multiple preset chords and
  • obtaining the target chords corresponding to the respective target segments in step S302 includes:
  • the chord with the highest matching degree is used as the target chord. If the current backtracking target segment has the same identifier as the backtracked target segment, then the target chord corresponding to the backtracked target segment is used as the current backtracking target segment The target chord.
  • the target segments with the same note sequence are added with the same identifier.
  • the target chord corresponding to the backtracked target segment is taken as the target chord of the current backtracked target segment, which reduces the amount of backtracking calculations and effectively improves the efficiency of the model.
  • step S103 generates a harmony segment matched with the melody segment based on the target chords respectively corresponding to the multiple target segments, including:
  • S703 generates a harmony segment matched with the melody segment based on the target chord after the combined time value.
  • step S701 it is determined that one measure in the melody segment is divided into at least two or more target segments.
  • one measure may not necessarily be divided into one target segment, and it is possible to divide one measure.
  • step S702 in the target chords corresponding to at least two or more target segments that constitute one measure of the melody segment, the timings of the same and adjacent target chords are merged. Specifically, if one of the melody segments is The bar includes two or more target chords. If there are the same and adjacent target chords, the time values of the two are merged, and after the merge, the first target chord is left; when one measure of the melody segment is divided into four When there are two target segments, the four target segments included in each measure correspond to four target chords.
  • a measure includes four identical targets
  • four identical target chord progression time values are merged, and after the merging time values, the first target chord sequence remains after the merging;
  • the smoothness of the harmony segment generated by the target chord is the smoothness of the harmony segment generated by the target chord.
  • step S703 based on the target chords after merging the timing value, generating a harmony segment matched with the melody segment, specifically, the target chord after merging the timing value still corresponds to the sorted position of the target segment in the melody segment, forming a merge
  • the performance form of the corresponding melody segment of the target chord sequence after the combined time value is generated to generate a harmony segment. For example, based on the beat of the melody segment, the target chord sequence after the time value is combined to generate the corresponding harmony Fragment.
  • each melody segment has only one target segment per measure, there is no need to merge the timing of the target chord; or each melody segment includes two or more target segments, but the two or more targets If the target chords corresponding to the segments are not the same or not adjacent, there is no need to merge the timing values of the target chords.
  • the harmony segment corresponding to the melody segment can be obtained based on the above-mentioned method of collocation harmony, and then the file is edited On the track of, the track corresponding to the input melody segment is added to the track of the harmony segment, as shown in Figure 8, to obtain a result file based on the melody and harmony, and then output it to the user.
  • FIG. 9 is a schematic structural diagram of a harmony-matching device provided by an embodiment of the present application.
  • the harmony-matching device 900 of the embodiment of the present application may include:
  • the dividing module 901 is configured to divide the melody segment into multiple target segments based on the beat of the melody segment;
  • the matching module 902 is configured to calculate the matching degree between a plurality of preset chords and each target segment based on the note sequence of each target segment, and for each target segment, use the preset chord with the highest matching degree as the corresponding target The target chord of the segment;
  • the generating module 903 is configured to generate a harmony segment matched with the melody segment based on the target chords respectively corresponding to the multiple target segments.
  • the dividing module 901 includes: a determining unit for determining a variable parameter based on the beat of the melody segment; wherein the variable parameter is a preset value or a user based on the beat setting of the melody segment The chord density of; a dividing unit for dividing the melody segment into multiple target segments based on the variable parameter.
  • the matching module includes: a determining unit, configured to determine target parameters based on the note sequence of each target segment and a plurality of preset chords; and the matching unit, configured to adopt a hidden Markov model based on the target parameters
  • the degree of matching between a plurality of preset chords and the respective target segments is calculated respectively, and the target chords corresponding to the respective target segments are obtained, and the target chord is the preset chord with the highest degree of matching with the corresponding target segment.
  • the determining unit includes: a first subunit, configured to determine the collocation probability of a plurality of preset chords and the respective target segment based on the note sequence of each target segment; and a second subunit, configured to The interval relationship between the multiple key signatures in the melody segment and each preset chord determines the probability distribution of the multiple preset chords in each key signature; the third subunit is used to calculate multiple presets based on the preset change probability Set the state transition probability of the combination of a chord and each key signature; wherein, the preset change probability includes the key signature change probability and the preset chord change probability; the fourth subunit is used for the note sequence and collocation based on each target segment Probability, probability distribution and state transition probability generate target parameters.
  • the first subunit is further configured to determine the duration vector of each note name in each target segment based on the note sequence of each target segment; determine multiple preset chords and chords based on the duration vector The collocation probability of each target segment.
  • the matching unit includes: a first matching subunit, configured to calculate the matching degree between a plurality of preset chords and the target segment ranked first in the melody segment based on the target parameter; and a second matching The subunit is used to determine that the currently calculated target segment is the first target segment if the currently calculated target segment is sorted after the first of the melody segment, and execute the step of calculating the matching degree between a plurality of preset chords and the first target segment : Based on the target parameter and the matching degree between the multiple preset chords and the pre-order target segment, respectively calculate the matching degree between the multiple preset chords and the first target segment, and sort them after the first target segment The next target segment of, as the first target segment; wherein, the preamble target segment is the previous target segment sorted before the first target segment in the melody segment; the third matching subunit is used for Re-execute the step of calculating the matching degree between the multiple preset chords and the first target segment until the calculation of the matching degree between the multiple preset chords and the respective
  • the generating module 903 includes: a target determining unit, configured to determine that a measure in the melody segment is divided into at least two or more target segments; a merging unit, configured to compose the melody Among the target chords corresponding to at least two or more target segments in one measure of the segment, the timing values of the same and adjacent target chords are merged; the generating unit is used to generate and the said chords based on the merged timing values of the target chords. Harmony clips with melody clips.
  • the device with harmony in the embodiments of this application can execute a method of harmony with the method provided in the embodiments of this application, and its implementation principle is similar.
  • Each module in the device with harmony in each embodiment of this application The actions performed correspond to the steps in the method for matching harmony in each embodiment of the present application.
  • For the detailed function description of each module of the device with harmony please refer to the corresponding combination and harmony shown in the preceding text. The description in the sound method will not be repeated here.
  • FIG. 10 shows a schematic structural diagram of an electronic device (such as a mobile terminal) 600 suitable for implementing the embodiments of the present application.
  • the mobile terminal in the embodiment of the present application may include, but is not limited to, a device such as a computer.
  • the electronic device shown in FIG. 10 is only an example, and should not bring any limitation to the function and scope of use of the embodiments of the present application.
  • the electronic device includes a memory and a processor.
  • the processor here may be referred to as the processing device 601 below, and the memory may include a read-only memory (ROM) 602, a random access memory (RAM) 603, and a storage device 608 below.
  • ROM read-only memory
  • RAM random access memory
  • storage device 608 At least one item of, as follows:
  • the electronic device 600 may include a processing device (such as a central processing unit, a graphics processor, etc.) 601, which may be loaded into a random access device according to a program stored in a read-only memory (ROM) 602 or from a storage device 608.
  • the program in the memory (RAM) 603 executes various appropriate actions and processing.
  • various programs and data required for the operation of the electronic device 600 are also stored.
  • the processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604.
  • An input/output (I/O) interface 605 is also connected to the bus 604.
  • the following devices can be connected to the I/O interface 605: including input devices 606 such as touch screens, touch pads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; including, for example, liquid crystal displays (LCD), speakers, vibration An output device 607 such as a device; a storage device 608 such as a magnetic tape, a hard disk, etc.; and a communication device 609.
  • the communication device 609 may allow the electronic device 600 to perform wireless or wired communication with other devices to exchange data.
  • FIG. 10 shows an electronic device 600 having various devices, it should be understood that it is not required to implement or have all of the illustrated devices. It may be implemented alternatively or provided with more or fewer devices.
  • the process described above with reference to the flowchart can be implemented as a computer software program.
  • the embodiments of the present application include a computer program product, which includes a computer program carried on a non-transitory computer readable medium, and the computer program includes program code for executing the method shown in the flowchart.
  • the computer program may be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602.
  • the computer program is executed by the processing device 601, it executes the above-mentioned functions defined in the method of the embodiment of the present application.
  • the embodiments of the present application also provide a computer-readable (storage) medium on which a computer program is stored.
  • a computer program When the computer program is executed by a processor, the steps of the method in the above embodiments are realized, or when the computer program is executed by the processor, the steps of the method in the above embodiments are realized.
  • the function of each module/unit of the device in the above embodiment will not be repeated here.
  • the media involved in this application such as computer-readable media, may be non-volatile or volatile.
  • the above-mentioned computer-readable medium in the present application may be a computer-readable signal medium or a computer-readable medium or any combination of the two.
  • the computer-readable medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination of the above. More specific examples of computer-readable media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable Read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
  • the computer-readable medium can be any tangible medium that contains or stores a program, and the program can be used by or in combination with an instruction execution system, apparatus, or device.
  • the computer-readable signal medium may include a data signal propagated in baseband or as a part of a carrier wave, and computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer-readable signal medium may also be any computer-readable medium other than the computer-readable medium, and the computer-readable signal medium may send, propagate, or transmit the program for use by or in combination with the instruction execution system, apparatus, or device.
  • the program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wire, optical cable, RF (Radio Frequency), etc., or any suitable combination of the above.
  • the client and server can communicate with any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and can communicate with digital data in any form or medium.
  • Communication e.g., communication network
  • Examples of communication networks include local area networks (“LAN”), wide area networks (“WAN”), the Internet (for example, the Internet), and end-to-end networks (for example, ad hoc end-to-end networks), as well as any currently known or future research and development network of.
  • the above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist alone without being assembled into the electronic device.
  • the above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the electronic device, the electronic device is caused to perform the following steps: divide the melody segment into multiple targets based on the beat of the melody segment Segment; calculate the matching degree of multiple preset chords with the target segment based on the note sequence of each target segment, and for each target segment, use the preset chord with the highest matching degree as the target chord of the corresponding target segment ; Generate a harmony segment matched with the melody segment based on the target chords respectively corresponding to the multiple target segments.
  • the computer program code used to perform the operations of the present application can be written in one or more programming languages or a combination thereof.
  • the above-mentioned programming languages include but are not limited to object-oriented programming languages—such as Java, Smalltalk, C++, etc. Including conventional procedural programming languages-such as "C" language or similar programming languages.
  • the program code can be executed entirely on the user's computer, partly on the user's computer, executed as an independent software package, partly on the user's computer and partly executed on a remote computer, or entirely executed on the remote computer or server.
  • the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, using an Internet service provider to pass Internet connection).
  • LAN local area network
  • WAN wide area network
  • each block in the flowchart or block diagram can represent a module, program segment, or part of code, and the module, program segment, or part of code contains one or more for realizing the specified logic function.
  • Executable instructions can also occur in a different order from the order marked in the drawings. For example, two blocks shown one after another can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved.
  • each block in the block diagram and/or flowchart, and the combination of the blocks in the block diagram and/or flowchart can be implemented by a dedicated hardware-based system that performs the specified functions or operations Or it can be realized by a combination of dedicated hardware and computer instructions.
  • the modules or units involved in the embodiments described in this application can be implemented in software or hardware. Wherein, the name of the module or unit does not constitute a limitation on the unit itself under certain circumstances.
  • the generating module can also be described as "generating the melody segment based on the target chords corresponding to the multiple target segments. Harmony clips with matching modules".
  • exemplary types of hardware logic components include: Field Programmable Gate Array (FPGA), Application Specific Integrated Circuit (ASIC), Application Specific Standard Product (ASSP), System on Chip (SOC), Complex Programmable Logical device (CPLD) and so on.
  • FPGA Field Programmable Gate Array
  • ASIC Application Specific Integrated Circuit
  • ASSP Application Specific Standard Product
  • SOC System on Chip
  • CPLD Complex Programmable Logical device
  • the blockchain referred to in this application is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • Blockchain essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information for verification. The validity of the information (anti-counterfeiting) and the generation of the next block.
  • the blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
  • a machine-readable medium may be a tangible medium, which may contain or store a program for use by the instruction execution system, apparatus, or device or in combination with the instruction execution system, apparatus, or device.
  • the machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium.
  • the machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing.
  • machine-readable storage media would include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
  • RAM random access memory
  • ROM read-only memory
  • EPROM or flash memory erasable programmable read-only memory
  • CD-ROM compact disk read only memory
  • magnetic storage device or any suitable combination of the foregoing.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Acoustics & Sound (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Library & Information Science (AREA)
  • Data Mining & Analysis (AREA)
  • Probability & Statistics with Applications (AREA)
  • Databases & Information Systems (AREA)
  • Algebra (AREA)
  • Artificial Intelligence (AREA)
  • Computational Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Electrophonic Musical Instruments (AREA)

Abstract

A harmony matching method and apparatus, an electronic device, and a computer readable medium. The method comprises: dividing a melody segment into multiple target segments on the basis of a meter of the melody segment (S101); respectively calculating, on the basis of note sequences of the respective target segments, matching degrees between multiple preset chords and each target segment, and for each target segment, using a preset chord having the highest matching degree as a target chord of the corresponding target segment (S102); and generating, on the basis of target chords respectively corresponding to the multiple target segments, a harmony segment matching the melody segment (S103). The invention improves the accuracy of matching between harmony segments and melody segments, and improves the smoothness of the overall performance of harmony segments. In addition, the invention further relates to blockchain technology, and allows melody segments to be stored in a blockchain.

Description

搭配和声的方法、装置、电子设备及计算机可读介质Method, device, electronic equipment and computer readable medium for matching harmony
本申请要求于2020年4月30日提交中国专利局、申请号为202010364461.2,发明名称为“搭配和声的方法、装置、电子设备及计算机可读介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed with the Chinese Patent Office on April 30, 2020, the application number is 202010364461.2, and the invention title is "Methods, devices, electronic equipment and computer-readable media for collocation of harmony", all of which The content is incorporated in this application by reference.
技术领域Technical field
本申请涉及计算机技术领域,具体而言,本申请涉及一种搭配和声的方法、装置、电子设备及计算机可读介质。This application relates to the field of computer technology. Specifically, this application relates to a method, a device, an electronic device, and a computer-readable medium for matching harmony.
背景技术Background technique
和声在调性音乐(Tonal music)中是一个很重要的部分,是音乐的基本表现手段之一。尽管一段旋律可以独立呈现,但加上用于伴奏的和声可以增加旋律的丰富性,在听感上更加丰满,并且在对西方传统音乐进行分析时,和声是一个很重要的维度。Harmony is a very important part in tonal music, and it is one of the basic means of music. Although a melody can be presented independently, the addition of harmony for accompaniment can increase the richness of the melody and make the sense of hearing fuller. In the analysis of western traditional music, harmony is a very important dimension.
现有技术中,一般采用以每小节的第一个音作为和弦根音的方法为旋律搭配上相应的和声。本申请发明人发现,对同一旋律而言存在多种和声搭配的可能性,当以一小节为单位且以每小节的第一个音作为根音为旋律搭配和声时,其局限性较大;且一个旋律片段所对应的和声与整个旋律片段内的所有音符的信息都息息相关,现有技术无法考虑旋律中相邻小节所搭配和弦间的相关性以及相邻和弦间所有音符的信息,导致为旋律所搭配的和声演奏效果突兀。In the prior art, the method of using the first note of each bar as the root note of the chord is generally used as the melody to match the corresponding harmony. The inventor of the present application has discovered that there are multiple possible harmony combinations for the same melody. When the unit of measure is one measure and the first note of each measure is used as the root note of the melody match harmony, its limitations are more limited. Large; and the harmony corresponding to a melody segment is closely related to the information of all the notes in the entire melody segment. The prior art cannot consider the correlation between the chords matched by adjacent bars in the melody and the information of all the notes between adjacent chords , Resulting in an abrupt harmony performance effect matched by the melody.
发明内容Summary of the invention
提供该发明内容部分以便以简要的形式介绍构思,这些构思将在后面的具体实施方式部分被详细描述。该发明内容部分并不旨在标识要求保护的技术方案的关键特征或必要特征,也不旨在用于限制所要求的保护的技术方案的范围。The content of the invention is provided in order to introduce concepts in a brief form, and these concepts will be described in detail in the following specific embodiments. The content of the invention is not intended to identify the key features or essential features of the technical solution required to be protected, nor is it intended to be used to limit the scope of the technical solution required to be protected.
本申请第一方面,提供了一种搭配和声的方法,包括:基于旋律片段的节拍将所述旋律片段划分成多个目标片段;基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦;基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段。In the first aspect of the present application, a method for matching harmony is provided, which includes: dividing the melody segment into multiple target segments based on the beat of the melody segment; respectively calculating multiple preset chords and chords based on the note sequence of each target segment The matching degree of each target segment, and for each target segment, the preset chord with the highest matching degree is used as the target chord of the corresponding target segment; based on the target chords corresponding to the multiple target segments, the Harmony clips with melody clips.
本申请第二方面,提供了一种搭配和声的装置,包括:划分模块,用于基于旋律片段的节拍将所述旋律片段划分成多个目标片段;匹配模块,用于基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦;生成模块,用于基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段。In a second aspect of the present application, a device for matching harmony is provided, including: a dividing module for dividing the melody segment into multiple target segments based on the beat of the melody segment; The note sequence calculates the matching degree between a plurality of preset chords and the respective target segments, and for each target segment, the preset chord with the highest matching degree is used as the target chord of the corresponding target segment; a generating module is used to generate The target chords respectively corresponding to the multiple target segments generate a harmony segment matched with the melody segment.
本申请第三方面,提供了一种电子设备,所述电子设备包括:存储器和处理器;存储器中存储有计算机程序;处理器,用于在运行计算机程序时执行以下方法:In a third aspect of the present application, an electronic device is provided, the electronic device includes: a memory and a processor; a computer program is stored in the memory; and the processor is configured to execute the following method when the computer program is running:
基于旋律片段的节拍将所述旋律片段划分成多个目标片段;Dividing the melody segment into multiple target segments based on the beat of the melody segment;
基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦;Calculate the matching degree between a plurality of preset chords and each target segment based on the note sequence of each target segment, and for each target segment, use the preset chord with the highest matching degree as the target chord of the corresponding target segment;
基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段。Based on the target chords respectively corresponding to the multiple target segments, a harmony segment matched with the melody segment is generated.
本申请第四方面,提供了一种计算机可读介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现以下方法:In a fourth aspect of the present application, a computer-readable medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following method is implemented:
基于旋律片段的节拍将所述旋律片段划分成多个目标片段;Dividing the melody segment into multiple target segments based on the beat of the melody segment;
基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦;Calculate the matching degree between a plurality of preset chords and each target segment based on the note sequence of each target segment, and for each target segment, use the preset chord with the highest matching degree as the target chord of the corresponding target segment;
基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段。Based on the target chords respectively corresponding to the multiple target segments, a harmony segment matched with the melody segment is generated.
本申请基于旋律片段的节拍对旋律片段进行划分,其划分成的多个目标片段中相邻的目标片段具有密切的关联性;由于相邻的目标片段关联性强,其使得相邻的音符序列也具有较强的关联性;在基于各个目标片段的音符序列计算多个预设和弦与各个目标片段的匹配度,并以匹配度最高的预设和弦作为相应目标片段的目标和弦时,有利于充分考虑相邻目标片段所搭配和弦间所有音符的信息,且相邻目标片段对应的相邻目标和弦关联性强,基于多个目标片段分别对应的目标和弦生成和声片段有利于提高基于旋律片段搭配和声片段的准确性,以及和声片段整体演奏效果的平滑度。The present application divides the melody segments based on the beats of the melody segments. Among the multiple target segments that are divided into, adjacent target segments are closely related; because the adjacent target segments are strongly related, it makes adjacent note sequences It also has strong relevance; when calculating the matching degree of multiple preset chords with each target segment based on the note sequence of each target segment, and using the preset chord with the highest matching degree as the target chord of the corresponding target segment, it is beneficial Fully consider the information of all the notes between the chords matched by the adjacent target segments, and the adjacent target chords corresponding to the adjacent target segments are strongly related. Generating harmony segments based on the target chords corresponding to multiple target segments is beneficial to improve the melody-based segments Match the accuracy of the harmony segment and the smoothness of the overall performance of the harmony segment.
附图说明Description of the drawings
结合附图并参考以下具体实施方式,本申请各实施例的上述和其他特征、优点及方面将变得更加明显。贯穿附图中,相同或相似的附图标记表示相同或相似的元素。应当理解附图是示意性的,原件和元素不一定按照比例绘制。With reference to the drawings and the following specific implementations, the above and other features, advantages, and aspects of the embodiments of the present application will become more apparent. Throughout the drawings, the same or similar reference signs indicate the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
图1为本申请实施例提供的搭配和声的方法的流程图;FIG. 1 is a flowchart of a method for matching harmony provided by an embodiment of the application;
图2为本申请实施例提供的搭配和声的方法的流程图;FIG. 2 is a flowchart of a method for matching harmony provided by an embodiment of the application;
图3为本申请实施例提供的搭配和声的方法的流程图;FIG. 3 is a flowchart of a method for matching harmony provided by an embodiment of the application;
图4为本申请实施例提供的搭配和声的方法的流程图;FIG. 4 is a flowchart of a method for matching harmony provided by an embodiment of the application;
图5为本申请实施例提供的搭配和声的方法的流程图;FIG. 5 is a flowchart of a method for matching harmony provided by an embodiment of the application;
图6为本申请实施例提供的搭配和声的方法的流程图;FIG. 6 is a flowchart of a method for matching harmony provided by an embodiment of the application;
图7为本申请实施例提供的搭配和声的方法的流程图;FIG. 7 is a flowchart of a method for matching harmony provided by an embodiment of the application;
图8为本申请实施例提供的搭配和声的方法中生成和声片段的示意图;FIG. 8 is a schematic diagram of generating a harmony segment in the method for collocation harmony provided by an embodiment of the application; FIG.
图9为本申请实施例提供的一种搭配和声的装置的结构示意图;FIG. 9 is a schematic structural diagram of a device for matching harmony provided by an embodiment of the application;
图10为本申请实施例提供的一种电子设备的结构示意图。FIG. 10 is a schematic structural diagram of an electronic device provided by an embodiment of the application.
具体实施方式Detailed ways
下面将参照附图更详细地描述本申请的实施例。虽然附图中显示了本申请的某些实施例,然而应当理解的是,本申请可以通过各种形式来实现,而且不应该被解释为限于这里阐述的实施例,相反提供这些实施例是为了更加透彻和完整地理解本申请。应当理解的是,本申请的附图及实施例仅用于示例性作用,并非用于限制本申请的保护范围。Hereinafter, embodiments of the present application will be described in more detail with reference to the accompanying drawings. Although some embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided for Have a more thorough and complete understanding of this application. It should be understood that the drawings and embodiments of the present application are only used for exemplary purposes, and are not used to limit the protection scope of the present application.
应当理解,本申请的方法实施方式中记载的各个步骤可以按照不同的顺序执行,和/或并行执行。此外,方法实施方式可以包括附加的步骤和/或省略执行示出的步骤。本申请的范围在此方面不受限制。It should be understood that the steps described in the method embodiments of the present application may be executed in a different order, and/or executed in parallel. In addition, method implementations may include additional steps and/or omit to perform the illustrated steps. The scope of this application is not limited in this respect.
本文使用的术语“包括”及其变形是开放性包括,即“包括但不限于”。术语“基于”是“至少部分地基于”。术语“一个实施例”表示“至少一个实施例”;术语“另一实施例”表示“至少一个另外的实施例”;术语“一些实施例”表示“至少一些实施例”。其他术语的相关定义将在下文描述中给出。The term "including" and its variations as used herein are open-ended includes, that is, "including but not limited to". The term "based on" is "based at least in part on." The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments." Related definitions of other terms will be given in the following description.
需要注意,本申请中提及的“第一”、“第二”等概念仅用于对装置、模块或单元进行区分,并非用于限定这些装置、模块或单元一定为不同的装置、模块或单元,也并非用于限定这些装置、模块或单元所执行的功能的顺序或者相互依存关系。It should be noted that the “first”, “second” and other concepts mentioned in this application are only used to distinguish devices, modules, or units, and are not used to limit these devices, modules, or units to be different devices, modules, or Units are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
需要注意,本申请中提及的“一个”、“多个”的修饰是示意性而非限制性的,本领域技术人员应当理解,除非在上下文另有明确指出,否则应该理解为“一个或多个”。It should be noted that the modification of “a” and “a plurality of” mentioned in this application is illustrative and not restrictive, and those skilled in the art should understand that unless the context clearly indicates otherwise, it should be understood as “one or Multiple".
本申请的技术方案可应用于人工智能、智慧城市、区块链和/或大数据技术领域,以进行和声搭配,实现智慧生活。可选的,本申请涉及的数据如旋律片段和/或和声片段等可存储于数据库中,或者可以存储于区块链中,比如通过区块链分布式存储,本申请不做限定。The technical solution of this application can be applied to the fields of artificial intelligence, smart city, blockchain and/or big data technology to perform harmony matching and realize smart life. Optionally, the data involved in this application, such as melody segments and/or harmony segments, can be stored in a database, or can be stored in a blockchain, such as distributed storage through a blockchain, which is not limited in this application.
本申请实施方式中的多个装置之间所交互的消息或者信息的名称仅用于说明性的目的,而并不是用于对这些消息或信息的范围进行限制。The names of messages or information exchanged between multiple devices in the embodiments of the present application are only used for illustrative purposes, and are not used to limit the scope of these messages or information.
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。In order to make the purpose, technical solutions, and advantages of the present application clearer, the implementation manners of the present application will be described in further detail below in conjunction with the accompanying drawings.
首先对本申请涉及的几个名词进行介绍和解释:First, introduce and explain several terms involved in this application:
旋律片段:旋律是音乐的首要要素,通常指若干乐音经过艺术构思而形成的有组织、节奏的序列。旋律片段可以是序列中的某一部分,也可以是完整的序列。Melody segment: Melody is the primary element of music. It usually refers to an organized and rhythmic sequence formed by several musical tones through artistic conception. The melody fragment can be a certain part of the sequence, or it can be a complete sequence.
节拍:节拍是衡量节奏的单位,在音乐中,有一定强弱分别的一系列拍子在每隔一定时间重复出现。如2/4、4/4、3/4拍等。节拍在乐曲中表示固定单位时值和强弱规律的组织形式。Beat: Beat is a unit of measuring rhythm. In music, a series of beats with a certain strength and weakness are repeated at regular intervals. Such as 2/4, 4/4, 3/4 beat and so on. The beat expresses the fixed unit time value and the organizational form of strength and weakness in the music.
音符序列:音符是用来记录不同长短的音的进行符号。全音符、二分音符、四分音符、八分音符、十六分音符是最常见的音符。音符序列是指由多个音符组成的序列,其具体包括音符信息及各个音名的排序,其中音符信息包括音符出现的时长。Note sequence: Note is a symbol used to record notes of different lengths. Whole notes, half notes, quarter notes, eighth notes, and sixteenth notes are the most common notes. The note sequence refers to a sequence composed of multiple notes, which specifically includes note information and the order of each note name, where the note information includes the duration of the note.
和弦:和弦是指有一定音程关系的一组声音,即将三个或以上的音,按照三度或非三度的叠置关系,在纵向上加以结合,就称为和弦。Chord: Chord refers to a group of sounds with a certain interval relationship, that is, three or more tones are combined in the vertical direction according to the superimposed relationship of thirds or non-thirds, and they are called chords.
和声片段:和声是指两个或两个以上不同的音按一定的法则同时发声而构成的音响组合。它包含和弦与和声进行,其中和弦是和声的基本素材,由3个或3个以上不同的音,根据三度叠置或其他方法同时结合构成,这是和声的纵向结构;和声进行是指各和弦的先后连接,这是和声的横向结构。和声片段是指由多个和弦先后连接形成的序列,其长度一般与旋律片段相同。Harmony segment: Harmony refers to a sound combination composed of two or more different sounds sounded at the same time according to a certain rule. It includes chords and harmony progression, among which chords are the basic material of harmony, consisting of 3 or more different sounds, combined according to three-degree stacking or other methods at the same time. This is the longitudinal structure of harmony; harmony Progression refers to the sequential connection of chords, which is the horizontal structure of harmony. Harmony segment refers to a sequence formed by successively connecting multiple chords, and its length is generally the same as the melody segment.
下面以具体地实施例对本申请的技术方案以及本申请的技术方案如何解决上述技术问题进行详细说明。下面这几个具体的实施例可以相互结合,对于相同或相似的概念或过程可能在某些实施例中不再赘述。下面将结合附图,对本申请的实施例进行描述。The technical solution of the present application and how the technical solution of the present application solves the above technical problems will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
请参照图1,本申请提供了一种搭配和声的方法,该方法具体可以由本申请实施例的电子设备执行,本申请包括:Please refer to FIG. 1, this application provides a method of matching harmony, which can be specifically executed by the electronic device of the embodiment of this application. This application includes:
S101基于旋律片段的节拍将所述旋律片段划分成多个目标片段;S101 divides the melody segment into multiple target segments based on the beat of the melody segment;
S102基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的和弦作为相应目标片段的目标和弦;S102, based on the note sequence of each target segment, respectively calculates the matching degree between a plurality of preset chords and the target segment, and for each target segment, the chord with the highest matching degree is used as the target chord of the corresponding target segment;
S103基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段。S103 generates a harmony segment matched with the melody segment based on the target chords respectively corresponding to the multiple target segments.
在步骤S101基于旋律片段的节拍将所述旋律片段划分成多个目标片段中,具体地,旋律片段可以由用户从本地获取输入或从第三方应用程序获取后输入,或由用户在现有存储的多个旋律片段中指定;获取到的旋律片段为MIDI文件,MIDI文件属于二进制文件,将旋律片段的每个音符记录为一个数字。同一段旋律片段中节拍是固定的,如4/4拍,基于旋律片段的节拍对旋律片段进行划分可以是每小节划分为一个目标片段,也可以是每小节划分为多个目标片段,还可以是多个小节划分为一个目标片段;一个旋律片段至少被划分成一个目标片段。In step S101, the melody segment is divided into a plurality of target segments based on the beat of the melody segment. Specifically, the melody segment may be inputted locally by the user or obtained from a third-party application program, or inputted by the user in an existing storage. It is specified in multiple melody segments; the acquired melody segment is a MIDI file, which is a binary file, and each note of the melody segment is recorded as a number. The beat in the same melody segment is fixed, such as 4/4 beats. The melody segment can be divided into one target segment per measure based on the beat of the melody segment, or it can be divided into multiple target segments per measure. Multiple bars are divided into a target segment; a melody segment is divided into at least one target segment.
需要强调的是,为进一步保证上述旋律片段的私密和安全性,上述旋律片段还可以存储于一区块链的节点中。It should be emphasized that, in order to further ensure the privacy and security of the above melody segment, the above melody segment can also be stored in a node of a blockchain.
在步骤S102基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的和弦作为相应目标片段的目标和弦中,具体地,音符序列由目标片段中的音符按照演奏顺序排列而成;预设和 弦至少包括两个,其可根据实际搭配需求调整预设和弦;不同的预设和弦与目标片段搭配将产生不同的演奏效果,在本实施例中,预设和弦与目标片段的匹配度基于音符序列计算,具体地与音符对应的音名相关,且将多个预设和弦与各个目标片段搭配所得的匹配度最高的预设和弦作为相应目标片段对应的目标和弦,一个目标片段对应一个目标和弦。其中,本实施例通过隐马尔可夫模型结合维特比算法(HMM维特比算法)计算多个预设和弦与各个目标片段的匹配度,针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦具体为根据HMM维特比算法从排序在旋律片段末位的目标片段向前回溯,得到具有最大概率的和弦序列(由各个目标片段分别对应的目标和弦构成),即隐含状态序列。In step S102, based on the note sequence of each target segment, the matching degree between a plurality of preset chords and the target segment is calculated, and for each target segment, the chord with the highest matching degree is used as the target chord of the corresponding target segment , Specifically, the note sequence is composed of the notes in the target segment arranged in the order of performance; the preset chords include at least two, which can be adjusted according to actual matching requirements; different preset chords and target segments will have different collocations In this embodiment, the matching degree between the preset chord and the target segment is calculated based on the note sequence, specifically related to the note name corresponding to the note, and the matching degree obtained by matching multiple preset chords with each target segment The highest preset chord serves as the target chord corresponding to the corresponding target segment, and one target segment corresponds to one target chord. Among them, this embodiment uses the hidden Markov model combined with the Viterbi algorithm (HMM Viterbi algorithm) to calculate the matching degree between multiple preset chords and each target segment, and for each target segment, the preset with the highest matching degree is calculated The chord as the target chord of the corresponding target segment is specifically based on the HMM Viterbi algorithm to backtrack from the target segment sorted at the end of the melody segment to obtain the chord sequence with the greatest probability (consisting of the target chord corresponding to each target segment), namely The hidden state sequence.
在步骤S103基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段中,具体地,和声片段用于在旋律片段演奏时加入,以丰富音乐整体的演奏效果;和声片段由多个目标和弦先后连接构成(和声进行),其中由于各个目标和弦对应于旋律片段的节拍,其基于多个目标和弦生成的和声片段与旋律片段的节拍相同。具体地,各个目标和弦基于相应的目标片段在旋律片段中的演奏顺序进行排序,一个目标片段对应一个目标和弦,生成与旋律片段演奏形式相同的和声片段。In step S103, based on the target chords respectively corresponding to the multiple target segments, a harmony segment that matches the melody segment is generated. Specifically, the harmony segment is used to add when the melody segment is performed, so as to enrich the overall performance of the music. ; Harmony segment is formed by successively connecting multiple target chords (harmonization progress), wherein since each target chord corresponds to the beat of the melody segment, the harmony segment generated based on the multiple target chords has the same beat as the melody segment. Specifically, each target chord is sorted based on the performance order of the corresponding target segment in the melody segment, and one target segment corresponds to one target chord, and a harmony segment with the same performance form as the melody segment is generated.
本申请实施例基于旋律片段的节拍对旋律片段进行划分,其划分成的多个目标片段中相邻的目标片段具有密切的关联性;由于相邻的目标片段关联性强,其使得相邻的音符序列也具有较强的关联性;在基于各个目标片段的音符序列计算多个预设和弦与各个目标片段的匹配度,并以匹配度最高的预设和弦作为相应目标片段的目标和弦时,有利于充分考虑相邻目标片段所搭配和弦间所有音符的信息,且相邻目标片段对应的相邻目标和弦关联性强,基于多个目标片段分别对应的目标和弦生成和声片段有利于提高旋律片段搭配和声片段的准确性,以及和声片段整体演奏效果的平滑度。The embodiment of the present application divides the melody segment based on the beat of the melody segment, and the adjacent target segments among the multiple target segments that are divided into are closely related; because the adjacent target segments are strongly related, it makes the adjacent target segments The note sequence also has a strong correlation; when calculating the matching degree of multiple preset chords with each target segment based on the note sequence of each target segment, and using the preset chord with the highest matching degree as the target chord of the corresponding target segment, It is helpful to fully consider the information of all the notes between the chords matched by the adjacent target segments, and the adjacent target chords corresponding to the adjacent target segments are strongly related. Generating harmony segments based on the target chords corresponding to multiple target segments is beneficial to improve the melody The accuracy of the segment matching the harmony segment, and the smoothness of the overall performance of the harmony segment.
在一实施例中,请参照图2,步骤S101基于旋律片段的节拍将所述旋律片段划分成多个目标片段,包括:In an embodiment, referring to FIG. 2, step S101 divides the melody segment into multiple target segments based on the beat of the melody segment, including:
S201基于旋律片段的节拍确定可变参数;其中,所述可变参数为预设值或用户基于所述旋律片段的节拍设定的和弦密度;S201 Determine a variable parameter based on the beat of the melody segment; wherein the variable parameter is a preset value or a chord density set by the user based on the beat of the melody segment;
S202基于所述可变参数将所述旋律片段划分成多个目标片段。S202 divides the melody segment into multiple target segments based on the variable parameter.
具体地,可变参数(chords_per_bar)为旋律片段每小节可搭配和弦的参数,如一小节4/4拍的目标片段,其音符总长度为4拍,最大可搭配和弦数为4;当可变参数为预设值时,可变参数可设定为1,即假设旋律片段的节拍为4/4拍,可变参数为可搭配和弦数的最小值,则以4拍为一个单元对旋律片段进行划分形成多个音符总长度为4拍的目标片段;当可变参数为预设值时,可变参数还可设定为可搭配和弦数值区间的随机值,如4/4拍的旋律片段,可搭配和弦数值区间为[1-4],若随机值为2,则以2拍为一个单元对旋律片段进行划分形成多个音符总长度为2拍的目标片段。和弦密度是指一个目标片段中搭配的和弦数目,如一个4/4拍的目标片段,和弦密度包括1、2、3、和4,当和弦密度为1时,一个目标片段搭配一种和弦。当可变参数为用户基于旋律片段的节拍设定的和弦密度时,首先确定旋律片段的节拍,假设为4/4拍,用户设定和弦密度为2,则将以每小节划分为2段为单位,对旋律片段进行划分形成多个音符长度为2拍的目标片段。Specifically, the variable parameter (chords_per_bar) is the parameter that can be matched with chords in each measure of the melody segment. For example, a target segment of 4/4 beats of a measure has a total note length of 4 beats, and the maximum number of chords that can be matched is 4; When it is the default value, the variable parameter can be set to 1, that is, assuming that the beat of the melody segment is 4/4 beats, and the variable parameter is the minimum number of chords that can be matched, the melody segment is performed in a unit of 4 beats. Divide multiple notes into a target segment with a total length of 4 beats; when the variable parameter is a preset value, the variable parameter can also be set to a random value that can match the chord value interval, such as a 4/4 beat melody segment, The range of possible chord values is [1-4]. If the random value is 2, the melody segment is divided into a unit of 2 beats to form multiple target segments with a total length of 2 beats. Chord density refers to the number of chords matched in a target segment. For example, a target segment in 4/4 time. The chord density includes 1, 2, 3, and 4. When the chord density is 1, a target segment matches one chord. When the variable parameter is the chord density set by the user based on the beat of the melody segment, first determine the beat of the melody segment, assuming it is 4/4 beats, and the user sets the chord density to 2, then each measure will be divided into 2 segments. Unit, the melody segment is divided to form multiple target segments with a note length of 2 beats.
在一实施例中,步骤S101基于旋律片段的节拍将旋律片段划分为多个目标片段,还包括:In one embodiment, the step S101 to divide the melody segment into multiple target segments based on the beat of the melody segment further includes:
基于旋律片段的节拍确定每小节中各音符的音符时值;Determine the note time value of each note in each bar based on the beat of the melody segment;
基于音符时值将旋律片段划分成多个目标片段。The melody segment is divided into multiple target segments based on the note duration.
具体地,一个全音符的音符时值为1,一个二分音符的音符时值为1/2,如此类推。 在4/4拍的一小节旋律片段中,若包括全音符则最多可搭配一种和弦;若包括两个二分音符则最多可搭配两种和弦。Specifically, the note duration value of a whole note is 1, the note duration value of a half note is 1/2, and so on. In a melody segment in 4/4 time, if a whole note is included, it can match up to one chord; if it includes two half notes, it can match up to two chords.
在本实施例中,对旋律片段进行划分的标准为可变参数,该可变参数可由用户基于旋律片段的节拍设定(在搭配和声的模型中,提供接口供用户设定可变参数),在搭配和声的过程中,用户可基于实际需要调整可变参数(和弦密度),如在用户对旋律片段不熟悉时,将可变参数调低,使得所搭配的和弦较少,降低演奏难度。进一步地,本实施例根据可变参数对旋律片段进行划分形成多个目标片段,有利于丰富所搭配和弦的数量,加强相邻目标片段所搭配和弦的关联性;进一步地,当可变参数为用户设定的和弦密度时,基于用户需求的不同,将旋律片段划分成多个目标片段所相应需要搭配的和弦数量及和弦种类不同,有利于加强人机互动的紧密性,提高用户的体验。In this embodiment, the standard for dividing the melody segment is a variable parameter, which can be set by the user based on the beat of the melody segment (in the harmony model, an interface is provided for the user to set the variable parameter) In the process of matching the harmony, the user can adjust the variable parameters (chord density) based on actual needs. For example, when the user is not familiar with the melody segment, lower the variable parameters, so that fewer chords are matched and the performance is reduced. Difficulty. Further, this embodiment divides the melody segment according to the variable parameters to form multiple target segments, which is beneficial to enrich the number of matched chords and strengthen the relevance of the chords matched by adjacent target segments; further, when the variable parameter is When the chord density is set by the user, based on the different needs of the user, the number of chords and the types of chords that need to be matched to divide the melody segment into multiple target segments are different, which is beneficial to strengthen the closeness of human-computer interaction and improve the user experience.
在一实施例中,请参照图3,步骤S102基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦,包括:In one embodiment, referring to FIG. 3, step S102 calculates the matching degree between a plurality of preset chords and each target segment based on the note sequence of each target segment, and for each target segment, the highest matching degree is calculated The preset chord of as the target chord of the corresponding target segment, including:
S301基于各个目标片段的音符序列与多个预设和弦确定目标参数;S301 determines target parameters based on the note sequence of each target segment and multiple preset chords;
S302采用隐马尔可夫模型基于所述目标参数分别计算多个预设和弦与所述各个目标片段的匹配度,获得所述各个目标片段分别对应的目标和弦,所述目标和弦为与相应目标片段匹配度最高的预设和弦。In S302, a Hidden Markov Model is used to calculate the matching degree of multiple preset chords with the respective target segments based on the target parameters, and the target chords corresponding to the respective target segments are obtained, and the target chords are corresponding to the corresponding target segments. The preset chord with the highest matching degree.
具体地,通过隐马尔可夫模型(Hidden Markov Model,HMM)结合维特比算法(Viterbi算法),构建多选择多步骤的模型解决最优选择的问题,按序计算多个预设和弦与各个目标片段搭配的匹配度(对数似然值)。在本实施例中所涉及的音名(pitches_name_class)包括:C,#C,D,#D,E,F,#F,G,#G,A,#A,B;预设和弦(chords)包括多种和弦种类,在本实施例中和弦种类包括:大三和弦major,小三和弦minor,增三和弦augmented,减三和弦diminished,大七和弦major7,小七和弦minor7,属七和弦dominant7,半减三和弦half-diminished。由于存在某些音符组成可能不对应任何和弦的情况,在预设和弦中增加一个no chord表征无和弦搭配;通过各个音名与多个预设和弦的搭配,共有97(12*8+1)种和弦候选的可能性,即共有97种和弦候选项。具体地,各个音名出现的概率是1/12;预设和弦在对应某一个音名时,各个预设和弦出现的概率是1/9。以上音名与预设和弦可基于实际情况调整。Specifically, through the Hidden Markov Model (HMM) combined with the Viterbi algorithm (Viterbi algorithm), a multi-selection and multi-step model is constructed to solve the optimal selection problem, and multiple preset chords and each target are calculated in sequence The matching degree of the segment collocation (log likelihood value). The pitch names (pitches_name_class) involved in this embodiment include: C, #C, D, #D, E, F, #F, G, #G, A, #A, B; preset chords (chords) Including a variety of chord types. In this embodiment, the chord types include: major, minor, augmented, diminished, major7, minor7, dominant7, half The minus triad is half-diminished. Due to the situation that some note compositions may not correspond to any chords, a no chord is added to the preset chords to indicate no chord collocation; through the collocation of each note name with multiple preset chords, a total of 97 (12*8+1) The possibility of chord candidates, that is, there are a total of 97 chord candidates. Specifically, the probability of each note name appears is 1/12; when the preset chord corresponds to a certain note name, the probability of each preset chord appears is 1/9. The above note names and preset chords can be adjusted based on actual conditions.
其中,目标参数为隐马尔可夫模型的计算参数,由各个目标片段的音符序列及多个预设和弦确定。目标片段的音符序列包括音符信息及各音名在目标片段中的排序,音符信息包括各音名在相应目标片段中出现的时长。在本实施例中,基于各个目标片段的音符序列与多个预设和弦共同确定一份目标参数。Among them, the target parameter is the calculation parameter of the hidden Markov model, which is determined by the note sequence of each target segment and multiple preset chords. The note sequence of the target segment includes note information and the order of each note name in the target segment, and the note information includes the length of time each note name appears in the corresponding target segment. In this embodiment, a set of target parameters is jointly determined based on the note sequence of each target segment and multiple preset chords.
其中,隐马尔可夫模型基于目标参数通过维特比算法可推断出多个预设和弦与各个目标片段的匹配度,并获得各个目标片段分别相应的目标和弦,将多个目标和弦按序排列输出目标和弦序列。其中目标和弦为与相应目标片段匹配度最高的预设和弦。Among them, the hidden Markov model can infer the matching degree of multiple preset chords with each target segment based on the target parameters through the Viterbi algorithm, and obtain the corresponding target chords of each target segment, and output the multiple target chords in sequence The target chord sequence. The target chord is the preset chord with the highest degree of matching with the corresponding target segment.
在一实施例中,请参照图4,步骤S301基于各个目标片段的音符序列与多个预设和弦确定目标参数,包括:In one embodiment, referring to FIG. 4, step S301 determines target parameters based on the note sequence of each target segment and a plurality of preset chords, including:
S401基于各个目标片段的音符序列确定多个预设和弦与所述各个目标片段的搭配概率;S401, based on the note sequence of each target segment, determine the collocation probability of a plurality of preset chords and each target segment;
S402基于所述旋律片段中的多个调号与每个预设和弦的音程关系确定多个预设和弦在各个调号中的概率分布;S402, based on the interval relationship between the multiple key signatures in the melody segment and each preset chord, determine the probability distribution of the multiple preset chords in each key signature;
S403基于预设变化概率计算多个预设和弦与各个调号组合的状态转移概率;其中,所述预设变化概率包括调号变化概率和预设和弦变化概率;S403 calculates the state transition probability of a combination of multiple preset chords and each key signature based on the preset change probability; wherein, the preset change probability includes the key signature change probability and the preset chord change probability;
S404基于所述各个目标片段的音符序列、搭配概率、概率分布以及状态转移概率生成目标参数。S404 generates target parameters based on the note sequence, collocation probability, probability distribution, and state transition probability of each target segment.
在步骤S401基于各个目标片段的音符序列确定多个预设和弦与所述各个目标片段的搭配概率中,具体地,根据各个目标片段的音符序列,确定97种和弦候选项在相应目标片段中的概率。其中,音符序列包括音符信息。In step S401, determining the collocation probability of a plurality of preset chords and each target segment based on the note sequence of each target segment. Specifically, according to the note sequence of each target segment, determine the number of 97 chord candidates in the corresponding target segment. Probability. Among them, the note sequence includes note information.
在步骤S402基于所述旋律片段中的多个调号与每个预设和弦的音程关系确定多个预设和弦在各个调号中的概率分布中,具体地,音程是指两个音级在音高上的相互关系,也即两个音在音高上的距离,其单位名称叫做度。各个调号与旋律片段中涉及的各个音名相应。根据不同调号key下大调音阶的音程关系与每个预设和弦组成的音程关系,计算每个预设和弦组成音在调内和调外的情况,得到各个调号下各预设和弦的概率分布(key_chord_distribution)。其中,音调外音可以认为对于某个调号key来说,预设和弦的组成音存在不是这个key下的自然音的预设和弦都称为这个调的调外和弦。如C大调中,D大三和弦D#F A为调外,D小三和弦D F A为调内。基于上述背景,本实施例中调号包括多个,如C调,D调,E调等,虽然对应同一旋律片段,但是在搭配和弦时可通过移调变换旋律片段在搭配和声片段时的整体风格,因此,需要考虑不同调号下与多个预设和弦搭配的概率分布。当调号为C大调时,若预设和弦仅包括D major和D minor,则C大调下50%为调内的概率分布,50%为调外的概率分布;对此,在一实施例中,还可根据小调性、多调性的情况,以及调外和弦与旋律搭配所起的伴奏效果计算各个调号下多个预设和弦的概率分布。In step S402, the probability distribution of multiple preset chords in each key signature is determined based on the interval relationship between the multiple key signatures in the melody segment and each preset chord. The relationship between pitches, that is, the distance between two tones in pitch, is called degree. Each key signature corresponds to each note name involved in the melody segment. According to the interval relationship of the major scale under different key signatures and the interval relationship of each preset chord composition, calculate each preset chord composition tone in and out of the key, and get the preset chord under each key signature Probability distribution (key_chord_distribution). Among them, the external tone of the tonal can be considered as a certain key signature key, the component tone of the preset chord is not the natural tone under the key. The preset chords are called the external chord of this key. For example, in the key of C major, the D major triad D#F A is the outer key, and the D minor triad D F A is the inner key. Based on the above background, in this embodiment, there are multiple key signatures, such as C, D, E, etc. Although they correspond to the same melody segment, the melody segment can be transformed by transposing the chord when matching the harmony segment. The overall style, therefore, needs to consider the probability distribution of collocation with multiple preset chords under different key signatures. When the key signature is C major, if the preset chord only includes D major and D minor, then 50% of the C major down is the probability distribution within the key, and 50% is the probability distribution outside the key; In the example, the probability distribution of multiple preset chords under each key signature can also be calculated according to the condition of minor tonality, polytonality, and the accompaniment effect of the collocation of out-of-tune chords and melody.
在步骤S403基于预设变化概率计算多个预设和弦与各个调号组合的状态转移概率;其中,所述预设变化概率包括调号变化概率和预设和弦变化概率中,具体地,各个音名对应的调号包括C,#C,D,#D,E,F,#F,G,#G,A,#A,B。在一实施例中,音名可包括所有乐理知识中的音名。其中,一个调号与多个预设和弦组合的数量由多个预设和弦的数量确定,某一个调号与某一个预设和弦的组合表征为调号与预设和弦组合,在本实施例所涉及的多个音名与多个预设和弦下,调号与预设和弦组合(key-chord)共有1164(97*12)个。状态转移概率表征各个调号与多个预设和弦转换的概率,如在C大调下,预设和弦从1、3、5转换为#1、3、#5的概率。在HMM维特比算法求解方法中,具体表征为所有调号与预设和弦组合的状态转移概率相应的矩阵。具体地,预设的变化概率包括调号变化概率为0.001,key_change_prob(=0.001)及预设和弦变化概率为0.5,chord_change_prob(=0.5)。预设的变化概率经多次测试与本实施例涉及的多个音名与多个预设和弦匹配,在实际情况下,可适应调整。通过下述公式(1)和(2)可计算出各个调号与多个预设和弦组合的状态转换概率。In step S403, the state transition probability of a combination of multiple preset chords and each key signature is calculated based on the preset change probability; wherein, the preset change probability includes the key signature change probability and the preset chord change probability, specifically, each tone The key signature corresponding to the name includes C,#C,D,#D,E,F,#F,G,#G,A,#A,B. In an embodiment, the note name may include all note names in music theory knowledge. Among them, the number of combinations of a key signature and multiple preset chords is determined by the number of preset chords, and the combination of a certain key signature and a certain preset chord is characterized as a combination of key signature and preset chord. In this embodiment Under the multiple note names and multiple preset chords involved, there are a total of 1164 (97*12) key-chord combinations (key-chord). The state transition probability represents the probability of each key signature and multiple preset chords conversion. For example, in the C major key, the probability of the preset chords being converted from 1, 3, and 5 to #1, 3, and #5. In the HMM Viterbi algorithm solution method, it is specifically characterized as a matrix corresponding to the state transition probability of all key signatures and preset chord combinations. Specifically, the preset change probability includes a key signature change probability of 0.001, key_change_prob (=0.001), and a preset chord change probability of 0.5, chord_change_prob (=0.5). The preset variation probability matches the multiple note names and multiple preset chords involved in this embodiment after multiple tests, and can be adapted and adjusted under actual conditions. The following formulas (1) and (2) can be used to calculate the state transition probability of each key signature and multiple preset chord combinations.
Figure PCTCN2020134894-appb-000001
Figure PCTCN2020134894-appb-000001
Figure PCTCN2020134894-appb-000002
Figure PCTCN2020134894-appb-000002
在公式(1)中,γ为预设和弦chord变化的概率,ρ为调号key变化的概率,f(h t)为根据预设和弦与调号组合概率key_chord_distribution得到的在某个调号key下的多个预设和弦音高的二项分布,初始化设定γ=0.5,ρ=0.001。 In formula (1), γ is the probability that the preset chord chord changes, ρ is the probability that the key signature key changes, and f(h t ) is the probability key_chord_distribution of the preset chord and key signature combination in a certain key signature key The binomial distribution of multiple preset chord pitches under the initial setting γ=0.5, ρ=0.001.
在步骤S404基于所述各个目标片段的音符序列、搭配概率、概率分布及状态转移概率生成目标参数中,具体地,基于各个目标片段的音符序列确定可见状态序列;如 4/4拍的目标片段A|4 3 5 2|的音符序列为4-3-5-2,目标片段B|1 4 6 7|的音符序列为1-4-6-7,则构成可见状态序列为4-3-5-2-1-4-6-7。在HMM维特比算法中,可见状态序列处于已知的观察状态,可见状态序列对应于旋律片段中的音符排序。具体地,将可观察旋律片段得出的可见状态序列、多个预设和弦与各个目标片段的搭配概率、多个预设和弦在各个调号中的概率分布、以及多个预设和弦与各个调号组合的状态转移概率生成目标参数,生成目标参数的过程为隐马尔可夫模型的训练过程。In step S404, target parameters are generated based on the note sequence, collocation probability, probability distribution, and state transition probability of each target segment, specifically, the visible state sequence is determined based on the note sequence of each target segment; for example, a target segment of 4/4 beat The note sequence of A|4 3 5 2| is 4-3-5-2, and the note sequence of target segment B|1 4 6 7| is 1-4-6-7, and the visible state sequence is 4-3- 5-2-1-4-6-7. In the HMM Viterbi algorithm, the visible state sequence is in a known observation state, and the visible state sequence corresponds to the sequence of notes in the melody segment. Specifically, the visible state sequence derived from the observable melody segment, the collocation probability of multiple preset chords and each target segment, the probability distribution of multiple preset chords in each key signature, and multiple preset chords and each The state transition probability of the key signature combination generates the target parameter, and the process of generating the target parameter is the training process of the hidden Markov model.
在一实施例中,请参照图5,步骤S401基于各个目标片段的音符序列确定多个预设和弦与所述各个目标片段的搭配概率,包括:In one embodiment, referring to FIG. 5, step S401 determines the matching probabilities of multiple preset chords and each target segment based on the note sequence of each target segment, including:
S501基于各个目标片段的音符序列确定各个音名在所述各个目标片段中的时长向量;S501 Determine the duration vector of each note name in each target segment based on the note sequence of each target segment;
S502基于所述时长向量确定多个预设和弦与所述各个目标片段的搭配概率。S502, based on the duration vector, determines the collocation probability of a plurality of preset chords and the respective target segments.
在步骤S501基于各个目标片段的音符序列确定各个音名在所述各个目标片段中的时长向量中,具体地,音符序列中包括确定各个音名在各个目标片段中出现的时长信息,可基于时长信息确定时长向量,时长向量表征各个音名对应在各个目标片段中音进行的长短及方向。在一实施例中,确定各个音名在各个目标片段中出现的时长向量(note_pitch_vector),如4/4拍目标片段A:|5-2 3|,则G在目标片段A中出现时长为2拍,D在目标片段A中出现时长为1拍,E在目标片段A中出现时长为1拍;基于该时长信息可确定出相应的时长向量;其中,出现时长与时值相关。In step S501, determining the duration vector of each note name in each target segment based on the note sequence of each target segment. Specifically, the note sequence includes determining the duration information of each note name appearing in each target segment, which may be based on the duration. The information determines the duration vector, and the duration vector represents the length and direction of each sound name corresponding to the middle sound of each target segment. In one embodiment, the time length vector (note_pitch_vector) of each note name in each target segment is determined, such as 4/4 shot target segment A: |5-2 3|, then G appears in target segment A for 2 Beat, the duration of D appearing in target segment A is 1 beat, and the duration of appearing E in target segment A is 1 beat; the corresponding duration vector can be determined based on the duration information; among them, the duration of appearance is related to the time value.
在步骤S502基于所述时长向量确定多个预设和弦与所述各个目标片段的搭配概率中,具体地,假设4/4拍目标片段A:|5-2 3|中G在目标片段A中出现时长为2拍,D在目标片段A中出现时长为1拍,E在目标片段A中出现时长为1拍。则可根据该目标片段A的音符组成情况确定97种和弦候选项在目标片段A中的概率,即包含音名G、D、E的和弦更有可能被认为是目标片段A的和弦搭配。其中,假设多个预设和弦包括DFA、CEG、CbEG、BDF,则在目标片段A中,预设和弦DFA的搭配概率为0.5、CEG的搭配概率为0.75、CbEG的搭配概率为0.75、BDF的搭配概率为0.25。通过该步骤的实施可以知悉各个和弦候选项(共97种)与各个目标片段搭配的概率(chord_frame_loglike)。In step S502, determining the collocation probability of multiple preset chords and each target segment based on the duration vector. Specifically, assume that the target segment A is shot in 4/4: |5-2 3|, where G is in the target segment A The appearance duration is 2 beats, the appearance duration of D in the target segment A is 1 beat, and the appearance duration of E in the target segment A is 1 beat. Then, the probability of 97 chord candidates in the target segment A can be determined according to the note composition of the target segment A, that is, the chords containing the note names G, D, and E are more likely to be considered as the chord collocation of the target segment A. Among them, assuming that multiple preset chords include DFA, CEG, CbEG, and BDF, in the target segment A, the matching probability of the preset chord DFA is 0.5, the matching probability of CEG is 0.75, the matching probability of CbEG is 0.75, and the matching probability of BDF is 0.5. The matching probability is 0.25. Through the implementation of this step, it is possible to know the probability (chord_frame_loglike) of each chord candidate (97 types in total) and each target segment.
在一实施中,请参照图6,步骤S302基于所述目标参数分别计算多个预设和弦与所述各个目标片段的匹配度,获得所述各个目标片段分别对应的目标和弦,包括:In an implementation, referring to FIG. 6, step S302 respectively calculates the matching degree between a plurality of preset chords and the respective target segments based on the target parameters, and obtains the target chords corresponding to the respective target segments, including:
S601基于所述目标参数分别计算多个预设和弦与排序在所述旋律片段首位的目标片段的匹配度;S601, based on the target parameters, respectively calculate the matching degree between a plurality of preset chords and the target segment sorted at the top of the melody segment;
S602若当前计算的目标片段排序在所述旋律片段的首位之后,确定当前计算的目标片段为第一目标片段,执行计算多个预设和弦与第一目标片段的匹配度的步骤:基于所述目标参数、及多个预设和弦与前序目标片段的匹配度,分别计算多个预设和弦与所述第一目标片段的匹配度,将排序在所述第一目标片段之后的下一目标片段,作为第一目标片段;其中,所述前序目标片段为在所述旋律片段中排序在所述第一目标片段之前的前一目标片段;S602 If the currently calculated target segment is sorted after the first of the melody segment, it is determined that the currently calculated target segment is the first target segment, and the step of calculating the matching degree between a plurality of preset chords and the first target segment is performed: Target parameters, and the matching degree between multiple preset chords and the previous target segment, respectively calculating the matching degrees between the multiple preset chords and the first target segment, and sorting the next target after the first target segment A segment as a first target segment; wherein the preamble target segment is a previous target segment sorted before the first target segment in the melody segment;
S603重新执行计算多个预设和弦与第一目标片段的匹配度的步骤,直至完成多个预设和弦与所述各个目标片段的匹配度计算;S603 re-execute the step of calculating the matching degree between the multiple preset chords and the first target segment, until the calculation of the matching degree between the multiple preset chords and the respective target segment is completed;
S604自排序在所述旋律片段末位的目标片段向前回溯确定所述各个目标片段分别对应的目标和弦。S604 Backward from the target segment sorted at the end of the melody segment to determine the target chord corresponding to each target segment.
具体地,结合目标参数根据维特比算法,针对各个目标片段在旋律片段中的排序,按序计算多个预设和弦与每个目标片段的匹配度,获得所述各个目标片段分别对应的目标和弦,目标和弦为与相应目标片段匹配度最高的预设和弦,其具体为隐马尔可夫 模型的预测过程。Specifically, according to the Viterbi algorithm in combination with the target parameters, for the ordering of each target segment in the melody segment, the degree of matching between a plurality of preset chords and each target segment is sequentially calculated, and the target chord corresponding to each target segment is obtained. , The target chord is the preset chord with the highest degree of matching with the corresponding target segment, which is specifically the prediction process of the hidden Markov model.
在步骤S601基于所述目标参数分别计算多个预设和弦与排序在所述旋律片段首位的目标片段的匹配度中,具体地,匹配度的计算自排序在旋律片段首位的目标片段开始,结合目标参数分别计算多个预设和弦与该目标片段的匹配度。In step S601, the matching degree between a plurality of preset chords and the target segment sorted at the top of the melody segment is calculated separately based on the target parameter. Specifically, the calculation of the matching degree starts with the target segment sorted at the top of the melody segment, and combines The target parameters respectively calculate the matching degree of multiple preset chords with the target segment.
在步骤S602若当前计算的目标片段排序在所述旋律片段的首位之后,确定当前计算的目标片段为第一目标片段,执行计算多个预设和弦与第一目标片段的匹配度的步骤:基于所述目标参数、及多个预设和弦与前序目标片段的匹配度,分别计算多个预设和弦与所述第一目标片段的匹配度,将排序在所述第一目标片段之后的下一目标片段,作为第一目标片段;其中,所述前序目标片段为在所述旋律片段中排序在所述第一目标片段之前的前一目标片段中,具体地,匹配度的计算在进行到排序在旋律片段的首位之后时,结合目标片段、及多个预设和弦与前序目标片段的匹配度,分别计算多个预设和弦与排序在旋律片段的首位之后的目标片段的匹配度。In step S602, if the currently calculated target segment is ranked first in the melody segment, it is determined that the currently calculated target segment is the first target segment, and the step of calculating the matching degree between a plurality of preset chords and the first target segment is performed: The target parameter and the matching degree between the multiple preset chords and the pre-order target segment are calculated respectively, and the matching degree between the multiple preset chords and the first target segment is calculated, and the sequence is sorted after the first target segment. A target segment as the first target segment; wherein the preamble target segment is the previous target segment sorted before the first target segment in the melody segment, specifically, the calculation of the matching degree is in progress When it is sorted after the first position of the melody segment, combine the target segment and the matching degree of multiple preset chords with the previous target segment, respectively calculate the matching degree of multiple preset chords with the target segment sorted after the first position of the melody segment .
在步骤S603重新执行计算多个预设和弦与第一目标片段的匹配度的步骤,直至完成多个预设和弦与所述各个目标片段的匹配度计算中,具体地,在匹配度的计算过程中,按序获取排序在旋律片段首位之后的各个目标片段,结合目标片段、及多个预设和弦与前序目标片段的匹配度,分别计算多个预设和弦与排序在旋律片段首位之后的各个目标片段的匹配度。In step S603, the step of calculating the matching degree between the multiple preset chords and the first target segment is re-executed, until the matching degree calculation between the multiple preset chords and the respective target segment is completed, specifically, in the calculation process of the matching degree , Obtain each target segment sorted after the first position of the melody segment in order, combine the target segment and the matching degree of multiple preset chords with the previous target segment, calculate the multiple preset chords and sort them after the first position of the melody segment. The matching degree of each target segment.
基于步骤S601、S602、S603、S604,举例说明,例1:旋律片段被划分为4个目标片段,基于在旋律片段中的排序位置,4个目标片段构成的序列为:D1-D2-D3-D4;在匹配度的计算步骤中,第一步,获取目标片段D1,结合目标参数分别计算多个预设和弦与目标片段D1的匹配度;第二步,获取目标片段D2,结合目标参数、及多个预设和弦与目标片段D1的匹配度,分别计算多个预设和弦与目标片段D2的匹配度;第三步,获取目标片段D3,结合目标参数、及多个预设和弦与目标片段D2的匹配度,分别计算多个预设和弦与目标片段D3的匹配度;第四步,获取目标片段D4,结合目标参数、及多个预设和弦与目标片段D3的匹配度,分别计算多个预设和弦与目标片段D4的匹配度;自此,完成多个预设和弦与4个目标片段的匹配度计算。在回溯的步骤中,第一步,获取目标片段D4,确定目标片段D4的目标和弦H4;第二步,获取目标片段D3,确定目标片段D3的目标和弦H3;第三步,获取目标片段D2,确定目标片段D2的目标和弦H2,;第四步,获取目标片段D1,确定目标片段D1的目标和弦H1;自此,完成回溯的步骤,在完成回溯步骤后,基于目标和弦H1、H2、H3和H4的排序可构成目标和弦序列。从以上例子可见,在本实施例中,针对多个预设和弦与每个目标片段的匹配度计算中,所得匹配度并非仅针对单一的目标片段得出,其综合考虑了多个预设和弦与前序目标片段的匹配度,且和排序在旋律片段其他位置的目标片段与多个预设和弦的匹配度无关,由此提高了相邻片段间所搭配目标和弦的关联性,也提高了由多个目标片段分别对应的目标和弦生成的和声片段整体的演奏平滑度。Based on steps S601, S602, S603, S604, for example, Example 1: The melody segment is divided into 4 target segments. Based on the sort position in the melody segment, the sequence composed of the 4 target segments is: D1-D2-D3- D4; In the step of calculating the matching degree, the first step is to obtain the target segment D1, and the target parameters are combined to calculate the matching degree of multiple preset chords with the target segment D1; the second step is to obtain the target segment D2, combining the target parameters, And the matching degree between multiple preset chords and the target segment D1, respectively calculate the matching degree between multiple preset chords and the target segment D2; the third step, obtain the target segment D3, combine the target parameters, and multiple preset chords and targets The matching degree of segment D2 is calculated separately for the matching degree of multiple preset chords and the target segment D3; the fourth step is to obtain the target segment D4, combining the target parameters and the matching degree of multiple preset chords with the target segment D3, respectively The degree of matching between multiple preset chords and the target segment D4; since then, the calculation of the degree of matching between multiple preset chords and the 4 target segments has been completed. In the backtracking step, the first step is to obtain the target segment D4, and the target chord H4 of the target segment D4 is determined; the second step is to obtain the target segment D3, and the target chord H3 of the target segment D3 is determined; the third step is to obtain the target segment D2 , Determine the target chord H2 of the target segment D2; the fourth step, obtain the target segment D1, determine the target chord H1 of the target segment D1; since then, the step of backtracking is completed. After the step of backtracking is completed, based on the target chord H1, H2, The sequence of H3 and H4 can form the target chord sequence. It can be seen from the above example that in the present embodiment, in the calculation of the matching degree between multiple preset chords and each target segment, the obtained matching degree is not only calculated for a single target segment, it comprehensively considers multiple preset chords. The matching degree with the previous target segment, and the matching degree between the target segment sorted in other positions of the melody segment and multiple preset chords has nothing to do. This improves the relevance of the target chords matched between adjacent segments and also improves The overall performance smoothness of the harmony segment generated by the target chords corresponding to the multiple target segments.
具体地,在模型基于目标参数进行匹配度计算时,多个预设和弦与各个目标片段的匹配度为各个目标片段在所有调号与预设和弦组合(即1164种组合)下的多个对数似然值(log-likelihood),对数似然值通过维特比算法基于目标参数计算。当按照旋律片段划分的顺序拼接多个目标片段时,对于排序在旋律片段首位的目标片段与多个预设和弦匹配度的计算得到该目标片段在所有调号与预设和弦组合下的多个对数似然值;排序在旋律片段首位之后的各个目标片段根据调号与预设和弦组合的状态转移概率的矩阵,并结合前序目标片段的相关信息(多个预设和弦与前序目标片段的匹配度),分别计算得到排序在旋律片段首位之后的各个目标片段在所有调号与预设和弦组合下的多个对数似然值,最终模型相应于每一个目标片段将存储有多个对数似然值相应的 调号与预设和弦组合的矩阵(path_matrix),即存储有各个目标片段与多个预设和弦的匹配度,以及相应的调号与预设和弦组合;即通过HMM维特比算法在计算每一个目标片段与所有预设和弦的搭配匹配度中均保存了各个前序目标片段到当前计算的一个目标片段与当前一个预设和弦搭配的匹配度(对数似然值),以及在当前计算的一个目标片段与当前一个预设和弦搭配的匹配度最高的情况下,各个前序目标片段分别相应的匹配度最高的预设和弦。进一步地,模型通过从排序在旋律片段末位的目标片段向前回溯,确定出各个目标片段分别对应的目标和弦,并输出由多个目标和弦构成的目标和弦序列;其中,目标和弦为与相应目标片段匹配度最高的预设和弦。Specifically, when the model calculates the matching degree based on the target parameters, the matching degree between multiple preset chords and each target segment is the multiple pairs of each target segment under all key signatures and preset chord combinations (that is, 1164 combinations). Log-likelihood (log-likelihood), the log-likelihood is calculated by the Viterbi algorithm based on the target parameters. When multiple target segments are spliced in the order of division of the melody segment, the degree of matching of the target segment sorted at the top of the melody segment with multiple preset chords is calculated to obtain multiple combinations of the target segment under all key signatures and preset chords. Log likelihood value; each target segment sorted after the first place of the melody segment is based on the matrix of the state transition probability of the combination of the key signature and the preset chord, and combined with the relevant information of the previous target segment (multiple preset chords and pre-targets Segment matching degree), and calculate the multiple log-likelihood values of each target segment sorted after the first of the melody segment under all key signatures and preset chord combinations. The final model corresponds to how much each target segment will be stored. A matrix (path_matrix) of key signatures and preset chord combinations corresponding to log likelihood values (path_matrix), which stores the matching degrees of each target segment with multiple preset chords, and the corresponding key signatures and preset chord combinations; that is, through The HMM Viterbi algorithm saves the matching degree of each target segment to the currently calculated target segment and the current preset chord in the calculation of the matching degree of each target segment with all preset chords (log-likelihood) Value), and when the currently calculated target segment has the highest matching degree with the current preset chord, each pre-order target segment corresponds to the preset chord with the highest matching degree. Furthermore, the model determines the target chords corresponding to each target fragment by tracing back from the target fragments sorted at the end of the melody fragment, and outputs a target chord sequence composed of multiple target chords; among them, the target chord is corresponding to The preset chord with the highest matching degree of the target segment.
在本实施例中,通过使用HMM维特比算法,在已知可观察的可见状态序列(旋律片段)与状态转移概率,推断出隐含状态序列(目标和弦序列);具体地,包括以下5个步骤:In this embodiment, by using the HMM Viterbi algorithm, the hidden state sequence (target chord sequence) is inferred based on the observable visible state sequence (melody segment) and state transition probability; specifically, the following 5 are included step:
(1)将旋律片段进行划分形成多个目标片段后,对各个目标片段(frame)的音符信息进行统计,得到包含各个音名在各个目标片段中出现的时长向量(note_pitch_vector);(1) After dividing the melody segment into multiple target segments, the note information of each target segment (frame) is counted to obtain the time length vector (note_pitch_vector) containing the appearance of each note name in each target segment;
(2)根据时长向量,确定多个预设和弦对应各个音名定义下的各种和弦候选项与各个目标片段搭配的搭配概率(chord_frame_loglike)。(2) According to the duration vector, determine the collocation probability (chord_frame_loglike) of multiple preset chords corresponding to various chord candidates under each note name definition and each target segment.
(3)根据不同调号key下大调音阶的音程关系与每个预设和弦组成的音程关系,计算每个预设和弦组成在调内和调外的情况,得到每个调号下各个预设和弦的概率分布。(3) According to the interval relationship of the major scale under different key signatures and the interval relationship of each preset chord composition, calculate the situation of each preset chord composition in and out of the key, and obtain each preset under each key signature. Let the probability distribution of the chord.
(4)基于预设变化概率,根据上述公式(1)计算各个调号与多个预设和弦组合的状态转移概率。(4) Based on the preset change probability, calculate the state transition probability of each key signature and multiple preset chord combinations according to the above formula (1).
采用隐马尔可夫模型基于可见状态序列、搭配概率、概率分布与状态转移概率通过维特比算法计算各个目标片段与多个预设和弦搭配的匹配度,针对每个目标片段,将匹配度最高的预设和弦作为相应目标片段的目标和弦,获得由各个目标和弦构成的与旋律片段搭配具有最大概率的目标和弦序列(由多个目标和弦依次排序构成)。具体地,基于所述目标参数分别计算多个预设和弦与排序在所述旋律片段首位的目标片段的匹配度;若当前计算的目标片段排序在所述旋律片段的首位之后,确定当前计算的目标片段为第一目标片段,执行计算多个预设和弦与第一目标片段的匹配度的步骤:基于所述目标参数、及多个预设和弦与前序目标片段的匹配度,分别计算多个预设和弦与所述第一目标片段的匹配度,将排序在所述第一目标片段之后的下一目标片段,作为第一目标片段;其中,所述前序目标片段为在所述旋律片段中排序在所述第一目标片段之前的前一目标片段(即排序在第一目标片段前一位的目标片段);重新执行计算多个预设和弦与第一目标片段的匹配度的步骤,直至完成多个预设和弦与所述各个目标片段的匹配度计算;在匹配度计算过程中,模型存储有各个目标片段中匹配度最高的调号与预设和弦组合的矩阵(path_matrix);并自排序在旋律片段末位的目标片段向前回溯,获得匹配度最高的路径(旋律片段整体对应的匹配度最高的目标和弦序列)。Hidden Markov model is used to calculate the matching degree of each target segment with multiple preset chords based on the visible state sequence, collocation probability, probability distribution and state transition probability through the Viterbi algorithm. For each target segment, the highest matching degree is calculated. The preset chord is used as the target chord of the corresponding target segment, and a target chord sequence (consisting of multiple target chords in sequence) that is composed of each target chord and has the greatest probability of matching with the melody segment is obtained. Specifically, the degree of matching between a plurality of preset chords and the target segment sorted at the top of the melody segment is calculated based on the target parameters; if the currently calculated target segment is sorted after the top of the melody segment, it is determined that the currently calculated The target segment is the first target segment, and the step of calculating the matching degree between a plurality of preset chords and the first target segment is performed: based on the target parameter and the matching degree between the plurality of preset chords and the pre-order target segment, calculating the matching degree respectively The degree of matching between a preset chord and the first target segment will be the next target segment sorted after the first target segment as the first target segment; wherein, the preamble target segment is in the melody The previous target segment sorted before the first target segment in the segments (that is, the target segment sorted one digit before the first target segment); re-execute the step of calculating the matching degree between a plurality of preset chords and the first target segment , Until the matching degree calculation between multiple preset chords and each target segment is completed; in the matching degree calculation process, the model stores a matrix (path_matrix) of the key signature with the highest matching degree in each target segment and the preset chord combination; And self-sort the target segment at the end of the melody segment to go back and get the path with the highest matching degree (the target chord sequence with the highest matching degree corresponding to the overall melody segment).
在一实施例中,步骤S302获得所述各个目标片段分别对应的目标和弦,包括:In an embodiment, obtaining the target chords corresponding to the respective target segments in step S302 includes:
遍历各个目标片段,将音符序列相同的目标片段添加相同标识;Traverse each target segment, and add the same mark to the target segments with the same note sequence;
从排序最后的目标片段向前回溯将所述匹配度最高的和弦作为目标和弦,若当前回溯目标片段与已回溯目标片段具有相同标识,则将已回溯目标片段对应的目标和弦作为当前回溯目标片段的目标和弦。Backtracking from the last-ordered target segment, the chord with the highest matching degree is used as the target chord. If the current backtracking target segment has the same identifier as the backtracked target segment, then the target chord corresponding to the backtracked target segment is used as the current backtracking target segment The target chord.
具体地,本实施例通过遍历各个目标片段,将音符序列相同的目标片段添加相同标识,在后期模型回溯确定各个目标片段分别对应的目标和弦时,若当前回溯目标片 段与已回溯目标片段具有相同标识,则将已回溯目标片段对应的目标和弦作为当前回溯目标片段的目标和弦,减少回溯的计算量,有效提高模型的效率。Specifically, in this embodiment, by traversing each target segment, the target segments with the same note sequence are added with the same identifier. When the later model backtracks to determine the target chords corresponding to each target segment, if the current backtracked target segment and the backtracked target segment have the same Mark, the target chord corresponding to the backtracked target segment is taken as the target chord of the current backtracked target segment, which reduces the amount of backtracking calculations and effectively improves the efficiency of the model.
在一实施例中,请参照图7,步骤S103基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段,包括:In an embodiment, referring to FIG. 7, step S103 generates a harmony segment matched with the melody segment based on the target chords respectively corresponding to the multiple target segments, including:
S701确定所述旋律片段中一小节被划分成至少两个及以上的目标片段;In S701, it is determined that a measure in the melody segment is divided into at least two or more target segments;
S702在构成所述旋律片段一小节的至少两个及以上的目标片段分别对应的目标和弦中,将相同且相邻的目标和弦的时值进行合并;In S702, among the target chords respectively corresponding to at least two or more target segments that constitute one measure of the melody segment, merge the timing values of the same and adjacent target chords;
S703基于合并时值后的目标和弦生成与所述旋律片段搭配的和声片段。S703 generates a harmony segment matched with the melody segment based on the target chord after the combined time value.
在步骤S701确定所述旋律片段中一小节被划分成至少两个以上的目标片段中,具体地,在对旋律片段进行划分时不一定将一小节划分为一个目标片段,有可能将一小节划分为两个及以上的目标片段;由于一个目标片段对应一个目标和弦,此时当将旋律片段的一小节划分为两个及以上的目标片段时,每小节将包括两个及以上的目标和弦。In step S701, it is determined that one measure in the melody segment is divided into at least two or more target segments. Specifically, when dividing the melody segment, one measure may not necessarily be divided into one target segment, and it is possible to divide one measure. There are two or more target segments; since one target segment corresponds to one target chord, when a measure of the melody segment is divided into two or more target segments, each measure will include two or more target chords.
在步骤S702在构成所述旋律片段一小节的至少两个及以上的目标片段分别对应的目标和弦中,将相同且相邻的目标和弦的时值进行合并中,具体地,若旋律片段的一小节包括两个及以上的目标和弦中,存在相同且相邻的目标和弦则将两者的时值进行合并,合并后剩余排序在前的一个目标和弦;当将旋律片段的一小节划分为四个目标片段时,每小节包括的四个目标片段对应四个目标和弦,若该四个目标和弦两两相同且相邻则将其时值进行合并,如:一小节中包括四个相同的目标和弦,则将四个相同的目标和弦进行时值合并,合并时值后剩余排序在前的一个目标和弦;本实施例的实施有利于减少每小节对应的目标和弦数量,提高由合并时值后的目标和弦生成的和声片段演奏的平滑性。In step S702, in the target chords corresponding to at least two or more target segments that constitute one measure of the melody segment, the timings of the same and adjacent target chords are merged. Specifically, if one of the melody segments is The bar includes two or more target chords. If there are the same and adjacent target chords, the time values of the two are merged, and after the merge, the first target chord is left; when one measure of the melody segment is divided into four When there are two target segments, the four target segments included in each measure correspond to four target chords. If the four target chords are the same and adjacent to each other, their time values will be combined, such as: a measure includes four identical targets For chords, four identical target chord progression time values are merged, and after the merging time values, the first target chord sequence remains after the merging; The smoothness of the harmony segment generated by the target chord.
在步骤S703基于合并时值后的目标和弦生成与所述旋律片段搭配的和声片段中,具体地,进行时值合并后的目标和弦仍对应于目标片段在旋律片段中的排序位置,形成合并时值后的目标和弦序列,将该合并时值后的目标和弦序列相应旋律片段的演奏形式生成和声片段,如基于旋律片段的节拍,将合并时值后的目标和弦序列生成相应的和声片段。In step S703, based on the target chords after merging the timing value, generating a harmony segment matched with the melody segment, specifically, the target chord after merging the timing value still corresponds to the sorted position of the target segment in the melody segment, forming a merge For the target chord sequence after the time value, the performance form of the corresponding melody segment of the target chord sequence after the combined time value is generated to generate a harmony segment. For example, based on the beat of the melody segment, the target chord sequence after the time value is combined to generate the corresponding harmony Fragment.
在本实施例中,若旋律片段每小节仅有一个目标片段,则无需进行对目标和弦的时值合并;或旋律片段每小节包括两个及以上的目标片段,但该两个及以上的目标片段分别对应的目标和弦不相同或不相邻,则无需进行对目标和弦的时值合并。In this embodiment, if the melody segment has only one target segment per measure, there is no need to merge the timing of the target chord; or each melody segment includes two or more target segments, but the two or more targets If the target chords corresponding to the segments are not the same or not adjacent, there is no need to merge the timing values of the target chords.
通过上述实施例提供的方法,在一种搭配和声的系统中,当获取到用户输入的旋律片段后,基于上述搭配和声的方法可获得与旋律片段相应的和声片段,则在编辑文件的轨道上,对应输入旋律片段的轨道加入和声片段的轨道,如图8所示,得到基于旋律搭配和声的结果文件,进而输出给用户使用。According to the method provided by the above-mentioned embodiment, in a system with harmony collocation, when the melody segment input by the user is obtained, the harmony segment corresponding to the melody segment can be obtained based on the above-mentioned method of collocation harmony, and then the file is edited On the track of, the track corresponding to the input melody segment is added to the track of the harmony segment, as shown in Figure 8, to obtain a result file based on the melody and harmony, and then output it to the user.
请参照图9,本申请实施例提供的一种搭配和声的装置的结构示意图,本申请实施例的搭配和声的装置900可以包括:Please refer to FIG. 9, which is a schematic structural diagram of a harmony-matching device provided by an embodiment of the present application. The harmony-matching device 900 of the embodiment of the present application may include:
划分模块901,用于基于旋律片段的节拍将所述旋律片段划分成多个目标片段;The dividing module 901 is configured to divide the melody segment into multiple target segments based on the beat of the melody segment;
匹配模块902,用于基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦;The matching module 902 is configured to calculate the matching degree between a plurality of preset chords and each target segment based on the note sequence of each target segment, and for each target segment, use the preset chord with the highest matching degree as the corresponding target The target chord of the segment;
生成模块903,用于基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段。The generating module 903 is configured to generate a harmony segment matched with the melody segment based on the target chords respectively corresponding to the multiple target segments.
在一实施例中,所述划分模块901包括:确定单元,用于基于旋律片段的节拍确定可变参数;其中,所述可变参数为预设值或用户基于所述旋律片段的节拍设定的和 弦密度;划分单元,用于基于所述可变参数将所述旋律片段划分成多个目标片段。In an embodiment, the dividing module 901 includes: a determining unit for determining a variable parameter based on the beat of the melody segment; wherein the variable parameter is a preset value or a user based on the beat setting of the melody segment The chord density of; a dividing unit for dividing the melody segment into multiple target segments based on the variable parameter.
在一实施例中,所述匹配模块包括:确定单元,用于基于各个目标片段的音符序列与多个预设和弦确定目标参数;匹配单元,用于采用隐马尔可夫模型基于所述目标参数分别计算多个预设和弦与所述各个目标片段的匹配度,获得所述各个目标片段分别对应的目标和弦,所述目标和弦为与相应目标片段匹配度最高的预设和弦。In an embodiment, the matching module includes: a determining unit, configured to determine target parameters based on the note sequence of each target segment and a plurality of preset chords; and the matching unit, configured to adopt a hidden Markov model based on the target parameters The degree of matching between a plurality of preset chords and the respective target segments is calculated respectively, and the target chords corresponding to the respective target segments are obtained, and the target chord is the preset chord with the highest degree of matching with the corresponding target segment.
在一实施例中,所述确定单元包括:第一子单元,用于基于各个目标片段的音符序列确定多个预设和弦与所述各个目标片段的搭配概率;第二子单元,用于基于所述旋律片段中的多个调号与每个预设和弦的音程关系确定多个预设和弦在各个调号中的概率分布;第三子单元,用于基于预设变化概率计算多个预设和弦与各个调号组合的状态转移概率;其中,所述预设变化概率包括调号变化概率和预设和弦变化概率;第四子单元,用于基于所述各个目标片段的音符序列、搭配概率、概率分布及状态转移概率生成目标参数。In an embodiment, the determining unit includes: a first subunit, configured to determine the collocation probability of a plurality of preset chords and the respective target segment based on the note sequence of each target segment; and a second subunit, configured to The interval relationship between the multiple key signatures in the melody segment and each preset chord determines the probability distribution of the multiple preset chords in each key signature; the third subunit is used to calculate multiple presets based on the preset change probability Set the state transition probability of the combination of a chord and each key signature; wherein, the preset change probability includes the key signature change probability and the preset chord change probability; the fourth subunit is used for the note sequence and collocation based on each target segment Probability, probability distribution and state transition probability generate target parameters.
在一实施例中,所述第一子单元,还用于基于各个目标片段的音符序列确定各个音名在所述各个目标片段中的时长向量;基于所述时长向量确定多个预设和弦与所述各个目标片段的搭配概率。In an embodiment, the first subunit is further configured to determine the duration vector of each note name in each target segment based on the note sequence of each target segment; determine multiple preset chords and chords based on the duration vector The collocation probability of each target segment.
在一实施例中,所述匹配单元包括:第一匹配子单元,用于基于所述目标参数分别计算多个预设和弦与排序在所述旋律片段首位的目标片段的匹配度;第二匹配子单元,用于若当前计算的目标片段排序在所述旋律片段的首位之后,确定当前计算的目标片段为第一目标片段,执行计算多个预设和弦与第一目标片段的匹配度的步骤:基于所述目标参数、及多个预设和弦与前序目标片段的匹配度,分别计算多个预设和弦与所述第一目标片段的匹配度,将排序在所述第一目标片段之后的下一目标片段,作为第一目标片段;其中,所述前序目标片段为在所述旋律片段中排序在所述第一目标片段之前的前一目标片段;第三匹配子单元,用于重新执行计算多个预设和弦与第一目标片段的匹配度的步骤,直至完成多个预设和弦与所述各个目标片段的匹配度计算;回溯子单元,用于自排序在所述旋律片段末位的目标片段向前回溯确定所述各个目标片段分别对应的目标和弦。In an embodiment, the matching unit includes: a first matching subunit, configured to calculate the matching degree between a plurality of preset chords and the target segment ranked first in the melody segment based on the target parameter; and a second matching The subunit is used to determine that the currently calculated target segment is the first target segment if the currently calculated target segment is sorted after the first of the melody segment, and execute the step of calculating the matching degree between a plurality of preset chords and the first target segment : Based on the target parameter and the matching degree between the multiple preset chords and the pre-order target segment, respectively calculate the matching degree between the multiple preset chords and the first target segment, and sort them after the first target segment The next target segment of, as the first target segment; wherein, the preamble target segment is the previous target segment sorted before the first target segment in the melody segment; the third matching subunit is used for Re-execute the step of calculating the matching degree between the multiple preset chords and the first target segment until the calculation of the matching degree between the multiple preset chords and the respective target segment is completed; the backtracking subunit is used for self-sorting in the melody segment The last target segment goes backward to determine the target chord corresponding to each target segment.
在一实施例中,所述生成模块903,包括:目标确定单元,用于确定所述旋律片段中一小节被划分成至少两个及以上的目标片段;合并单元,用于在构成所述旋律片段一小节的至少两个及以上的目标片段分别对应的目标和弦中,将相同且相邻的目标和弦的时值进行合并;生成单元,用于基于合并时值后的目标和弦生成与所述旋律片段搭配的和声片段。In an embodiment, the generating module 903 includes: a target determining unit, configured to determine that a measure in the melody segment is divided into at least two or more target segments; a merging unit, configured to compose the melody Among the target chords corresponding to at least two or more target segments in one measure of the segment, the timing values of the same and adjacent target chords are merged; the generating unit is used to generate and the said chords based on the merged timing values of the target chords. Harmony clips with melody clips.
本申请实施例的搭配和声的装置可执行本申请的实施例所提供的一种搭配和声的方法,其实现原理相类似,本申请各实施例中的搭配和声的装置中的各模块所执行的动作是与本申请各实施例中的搭配和声的方法中的步骤相对应的,对于搭配和声的装置的各模块的详细功能描述具体可以参见前文中所示的对应的搭配和声的方法中的描述,此处不再赘述。The device with harmony in the embodiments of this application can execute a method of harmony with the method provided in the embodiments of this application, and its implementation principle is similar. Each module in the device with harmony in each embodiment of this application The actions performed correspond to the steps in the method for matching harmony in each embodiment of the present application. For the detailed function description of each module of the device with harmony, please refer to the corresponding combination and harmony shown in the preceding text. The description in the sound method will not be repeated here.
下面参考图10,其示出了适于用来实现本申请实施例的电子设备(例如移动终端)600的结构示意图。本申请实施例中的移动终端可以包括但不限于诸如计算机等的设备。图10示出的电子设备仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。10, which shows a schematic structural diagram of an electronic device (such as a mobile terminal) 600 suitable for implementing the embodiments of the present application. The mobile terminal in the embodiment of the present application may include, but is not limited to, a device such as a computer. The electronic device shown in FIG. 10 is only an example, and should not bring any limitation to the function and scope of use of the embodiments of the present application.
电子设备包括:存储器以及处理器,其中,这里的处理器可以称为下文的处理装置601,存储器可以包括下文中的只读存储器(ROM)602、随机访问存储器(RAM)603以及存储装置608中的至少一项,具体如下所示:The electronic device includes a memory and a processor. The processor here may be referred to as the processing device 601 below, and the memory may include a read-only memory (ROM) 602, a random access memory (RAM) 603, and a storage device 608 below. At least one item of, as follows:
如图10所示,电子设备600可以包括处理装置(例如中央处理器、图形处理器等) 601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储装置608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有电子设备600操作所需的各种程序和数据。处理装置601、ROM 602以及RAM603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。As shown in FIG. 10, the electronic device 600 may include a processing device (such as a central processing unit, a graphics processor, etc.) 601, which may be loaded into a random access device according to a program stored in a read-only memory (ROM) 602 or from a storage device 608. The program in the memory (RAM) 603 executes various appropriate actions and processing. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to the bus 604.
通常,以下装置可以连接至I/O接口605:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置606;包括例如液晶显示器(LCD)、扬声器、振动器等的输出装置607;包括例如磁带、硬盘等的存储装置608;以及通信装置609。通信装置609可以允许电子设备600与其他设备进行无线或有线通信以交换数据。虽然图10示出了具有各种装置的电子设备600,但是应理解的是,并不要求实施或具备所有示出的装置。可以替代地实施或具备更多或更少的装置。Generally, the following devices can be connected to the I/O interface 605: including input devices 606 such as touch screens, touch pads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; including, for example, liquid crystal displays (LCD), speakers, vibration An output device 607 such as a device; a storage device 608 such as a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to perform wireless or wired communication with other devices to exchange data. Although FIG. 10 shows an electronic device 600 having various devices, it should be understood that it is not required to implement or have all of the illustrated devices. It may be implemented alternatively or provided with more or fewer devices.
特别地,根据本申请的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本申请的实施例包括一种计算机程序产品,其包括承载在非暂态计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置609从网络上被下载和安装,或者从存储装置608被安装,或者从ROM 602被安装。在该计算机程序被处理装置601执行时,执行本申请实施例的方法中限定的上述功能。In particular, according to the embodiments of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments of the present application include a computer program product, which includes a computer program carried on a non-transitory computer readable medium, and the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program may be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, it executes the above-mentioned functions defined in the method of the embodiment of the present application.
本申请实施例还提供了一种计算机可读(存储)介质,其上存储有计算机程序,计算机程序被处理器执行时实现上述实施例中方法的步骤,或者,计算机程序被处理器执行时实现上述实施例中装置的各模块/单元的功能,这里不再赘述。可选的,本申请涉及的介质如计算机可读介质可以是非易失性的,也可以是易失性的。The embodiments of the present application also provide a computer-readable (storage) medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the method in the above embodiments are realized, or when the computer program is executed by the processor, the steps of the method in the above embodiments are realized. The function of each module/unit of the device in the above embodiment will not be repeated here. Optionally, the media involved in this application, such as computer-readable media, may be non-volatile or volatile.
需要说明的是,本申请上述的计算机可读介质可以是计算机可读信号介质或者计算机可读介质或者是上述两者的任意组合。计算机可读介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,计算机可读介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。It should be noted that the above-mentioned computer-readable medium in the present application may be a computer-readable signal medium or a computer-readable medium or any combination of the two. The computer-readable medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination of the above. More specific examples of computer-readable media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable Read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In this application, the computer-readable medium can be any tangible medium that contains or stores a program, and the program can be used by or in combination with an instruction execution system, apparatus, or device. In this application, the computer-readable signal medium may include a data signal propagated in baseband or as a part of a carrier wave, and computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable medium, and the computer-readable signal medium may send, propagate, or transmit the program for use by or in combination with the instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wire, optical cable, RF (Radio Frequency), etc., or any suitable combination of the above.
在一些实施方式中,客户端、服务器可以利用诸如HTTP(HyperText Transfer Protocol,超文本传输协议)之类的任何当前已知或未来研发的网络协议进行通信,并且可以与任意形式或介质的数字数据通信(例如,通信网络)互连。通信网络的示例包括局域网(“LAN”),广域网(“WAN”),网际网(例如,互联网)以及端对端网络(例如,ad hoc端对端网络),以及任何当前已知或未来研发的网络。In some embodiments, the client and server can communicate with any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and can communicate with digital data in any form or medium. Communication (e.g., communication network) interconnects. Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet (for example, the Internet), and end-to-end networks (for example, ad hoc end-to-end networks), as well as any currently known or future research and development network of.
上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。The above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist alone without being assembled into the electronic device.
上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该电 子设备执行时,使得该电子设备执行以下步骤:基于旋律片段的节拍将所述旋律片段划分成多个目标片段;基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦;基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段。The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the electronic device, the electronic device is caused to perform the following steps: divide the melody segment into multiple targets based on the beat of the melody segment Segment; calculate the matching degree of multiple preset chords with the target segment based on the note sequence of each target segment, and for each target segment, use the preset chord with the highest matching degree as the target chord of the corresponding target segment ; Generate a harmony segment matched with the melody segment based on the target chords respectively corresponding to the multiple target segments.
可以以一种或多种程序设计语言或其组合来编写用于执行本申请的操作的计算机程序代码,上述程序设计语言包括但不限于面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。The computer program code used to perform the operations of the present application can be written in one or more programming languages or a combination thereof. The above-mentioned programming languages include but are not limited to object-oriented programming languages—such as Java, Smalltalk, C++, etc. Including conventional procedural programming languages-such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partly on the user's computer, executed as an independent software package, partly on the user's computer and partly executed on a remote computer, or entirely executed on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, using an Internet service provider to pass Internet connection).
附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation of the system architecture, functions, and operations of the system, method, and computer program product according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram can represent a module, program segment, or part of code, and the module, program segment, or part of code contains one or more for realizing the specified logic function. Executable instructions. It should also be noted that, in some alternative implementations, the functions marked in the block may also occur in a different order from the order marked in the drawings. For example, two blocks shown one after another can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and/or flowchart, and the combination of the blocks in the block diagram and/or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations Or it can be realized by a combination of dedicated hardware and computer instructions.
描述于本申请实施例中所涉及到的模块或单元可以通过软件的方式实现,也可以通过硬件的方式来实现。其中,模块或单元的名称在某种情况下并不构成对该单元本身的限定,例如,生成模块还可以被描述为“基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段的模块”。The modules or units involved in the embodiments described in this application can be implemented in software or hardware. Wherein, the name of the module or unit does not constitute a limitation on the unit itself under certain circumstances. For example, the generating module can also be described as "generating the melody segment based on the target chords corresponding to the multiple target segments. Harmony clips with matching modules".
本文中以上描述的功能可以至少部分地由一个或多个硬件逻辑部件来执行。例如,非限制性地,可以使用的示范类型的硬件逻辑部件包括:现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、片上系统(SOC)、复杂可编程逻辑设备(CPLD)等等。The functions described above in this document may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: Field Programmable Gate Array (FPGA), Application Specific Integrated Circuit (ASIC), Application Specific Standard Product (ASSP), System on Chip (SOC), Complex Programmable Logical device (CPLD) and so on.
本申请所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。The blockchain referred to in this application is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain, essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information for verification. The validity of the information (anti-counterfeiting) and the generation of the next block. The blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
在本申请的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。In the context of the present application, a machine-readable medium may be a tangible medium, which may contain or store a program for use by the instruction execution system, apparatus, or device or in combination with the instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
以上描述仅为本申请的较佳实施例以及对所运用技术原理的说明。本领域技术人 员应当理解,本申请中所涉及的公开范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述公开构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本申请中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a preferred embodiment of the present application and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in this application is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover the above technical features or technical solutions without departing from the above disclosed concept. Other technical solutions formed by arbitrarily combining the equivalent features. For example, the above-mentioned features and the technical features disclosed in this application (but not limited to) with similar functions are mutually replaced to form a technical solution.
此外,虽然采用特定次序描绘了各操作,但是这不应当理解为要求这些操作以所示出的特定次序或以顺序次序执行来执行。在一定环境下,多任务和并行处理可能是有利的。同样地,虽然在上面论述中包含了若干具体实现细节,但是这些不应当被解释为对本申请的范围的限制。在单独的实施例的上下文中描述的某些特征还可以组合地实现在单个实施例中。相反地,在单个实施例的上下文中描述的各种特征也可以单独地或以任何合适的子组合的方式实现在多个实施例中。尽管已经采用特定于结构特征和/或方法逻辑动作的语言描述了本主题,但是应当理解所附权利要求书中所限定的主题未必局限于上面描述的特定特征或动作。相反,上面所描述的特定特征和动作仅仅是实现权利要求书的示例形式。In addition, although the operations are depicted in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or performed in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present application. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable subcombination. Although the subject matter has been described in language specific to structural features and/or logical actions of the method, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely exemplary forms of implementing the claims.

Claims (20)

  1. 一种搭配和声的方法,其中,包括:A method of matching harmony, which includes:
    基于旋律片段的节拍将所述旋律片段划分成多个目标片段;Dividing the melody segment into multiple target segments based on the beat of the melody segment;
    基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦;Calculate the matching degree between a plurality of preset chords and each target segment based on the note sequence of each target segment, and for each target segment, use the preset chord with the highest matching degree as the target chord of the corresponding target segment;
    基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段。Based on the target chords respectively corresponding to the multiple target segments, a harmony segment matched with the melody segment is generated.
  2. 根据权利要求1所述的方法,其中,所述基于旋律片段的节拍将所述旋律片段划分成多个目标片段,包括:The method according to claim 1, wherein the dividing the melody segment into a plurality of target segments based on the beat of the melody segment comprises:
    基于旋律片段的节拍确定可变参数;其中,所述可变参数为预设值或用户基于所述旋律片段的节拍设定的和弦密度;Determining a variable parameter based on the beat of the melody segment; wherein the variable parameter is a preset value or a chord density set by the user based on the beat of the melody segment;
    基于所述可变参数将所述旋律片段划分成多个目标片段。The melody segment is divided into a plurality of target segments based on the variable parameter.
  3. 根据权利要求1所述的方法,其中,所述基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦,包括:The method according to claim 1, wherein the matching degree between a plurality of preset chords and each target segment is calculated based on the note sequence of each target segment, and for each target segment, the matching degree is the highest The preset chord of as the target chord of the corresponding target segment, including:
    基于各个目标片段的音符序列与多个预设和弦确定目标参数;Determine the target parameters based on the note sequence of each target segment and multiple preset chords;
    采用隐马尔可夫模型基于所述目标参数分别计算多个预设和弦与所述各个目标片段的匹配度,获得所述各个目标片段分别对应的目标和弦,所述目标和弦为与相应目标片段匹配度最高的预设和弦。The Hidden Markov Model is used to calculate the matching degree between multiple preset chords and the respective target segments based on the target parameters, and the target chords corresponding to the respective target segments are obtained, and the target chords are matched with the corresponding target segments The preset chord with the highest degree.
  4. 根据权利要求3所述的方法,其中,所述基于各个目标片段的音符序列与多个预设和弦确定目标参数,包括:The method according to claim 3, wherein the determining the target parameter based on the note sequence of each target segment and a plurality of preset chords comprises:
    基于各个目标片段的音符序列确定多个预设和弦与所述各个目标片段的搭配概率;Determining the collocation probabilities of multiple preset chords and each target segment based on the note sequence of each target segment;
    基于所述旋律片段中的多个调号与每个预设和弦的音程关系确定多个预设和弦在各个调号中的概率分布;Determining the probability distribution of the multiple preset chords in each key signature based on the interval relationship between the multiple key signatures in the melody segment and each preset chord;
    基于预设变化概率计算多个预设和弦与各个调号组合的状态转移概率;其中,所述预设变化概率包括调号变化概率和预设和弦变化概率;Calculate the state transition probability of a combination of multiple preset chords and each key signature based on the preset change probability; wherein, the preset change probability includes the key signature change probability and the preset chord change probability;
    基于所述各个目标片段的音符序列、搭配概率、概率分布及状态转移概率生成目标参数。The target parameter is generated based on the note sequence, collocation probability, probability distribution, and state transition probability of each target segment.
  5. 根据权利要求4所述的方法,其中,所述基于各个目标片段的音符序列确定多个预设和弦与所述各个目标片段的搭配概率,包括:The method according to claim 4, wherein the determining the collocation probability of a plurality of preset chords and the respective target fragments based on the note sequence of each target fragment comprises:
    基于各个目标片段的音符序列确定各个音名在所述各个目标片段中的时长向量;Determining the duration vector of each note name in each target segment based on the note sequence of each target segment;
    基于所述时长向量确定多个预设和弦与所述各个目标片段的搭配概率。The collocation probabilities of a plurality of preset chords and the respective target segments are determined based on the duration vector.
  6. 根据权利要求3所述的方法,其中,所述基于所述目标参数分别计算多个预设和弦与所述各个目标片段的匹配度,获得所述各个目标片段分别对应的目标和弦,包括:The method according to claim 3, wherein the calculating the matching degree between a plurality of preset chords and the respective target segments based on the target parameters, to obtain the target chords corresponding to the respective target segments, comprises:
    基于所述目标参数分别计算多个预设和弦与排序在所述旋律片段首位的目标片段的匹配度;Respectively calculating the matching degree between a plurality of preset chords and the target segment ranked first in the melody segment based on the target parameter;
    若当前计算的目标片段排序在所述旋律片段的首位之后,确定当前计算的目标片段为第一目标片段,执行计算多个预设和弦与第一目标片段的匹配度的步骤:基于所述目标参数、及多个预设和弦与前序目标片段的匹配度,分别计算多个预设和弦与所述第一目标片段的匹配度,将排序在所述第一目标片段之后的下一目标片段,作为第一目标片段;其中,所述前序目标片段为在所述旋律片段中排序在所述第一目标片段之前的前一目标片段;If the currently calculated target segment is sorted after the first of the melody segment, it is determined that the currently calculated target segment is the first target segment, and the step of calculating the matching degree between a plurality of preset chords and the first target segment is performed: based on the target Parameters, and the matching degree between multiple preset chords and the previous target segment, respectively calculating the matching degree between multiple preset chords and the first target segment, and sorting the next target segment after the first target segment , As the first target segment; wherein the preamble target segment is the previous target segment sorted before the first target segment in the melody segment;
    重新执行计算多个预设和弦与第一目标片段的匹配度的步骤,直至完成多个预设和弦与所述各个目标片段的匹配度计算;Re-execute the step of calculating the matching degree between the multiple preset chords and the first target segment until the calculation of the matching degree between the multiple preset chords and the respective target segment is completed;
    自排序在所述旋律片段末位的目标片段向前回溯确定所述各个目标片段分别对应的目标和弦。The target segment that is at the end of the melody segment is automatically sorted forward and backward to determine the target chord corresponding to each of the target segments.
  7. 根据权利要求1所述的方法,其中,所述旋律片段存储于区块链中,所述基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段,包括:The method according to claim 1, wherein the melody segment is stored in a blockchain, and the generating a harmony segment matched with the melody segment based on the target chords respectively corresponding to the multiple target segments comprises:
    确定所述旋律片段中一小节被划分成至少两个及以上的目标片段;Determining that a section in the melody segment is divided into at least two or more target segments;
    在构成所述旋律片段一小节的至少两个及以上的目标片段分别对应的目标和弦中,将相同且相邻的目标和弦的时值进行合并;Combining the time values of the same and adjacent target chords in the target chords respectively corresponding to at least two or more target segments constituting a measure of the melody segment;
    基于合并时值后的目标和弦生成与所述旋律片段搭配的和声片段。Based on the combined time value of the target chord, a harmony segment matched with the melody segment is generated.
  8. 一种搭配和声的装置,其中,包括:A device with harmony, including:
    划分模块,用于基于旋律片段的节拍将所述旋律片段划分成多个目标片段;A dividing module for dividing the melody segment into multiple target segments based on the beat of the melody segment;
    匹配模块,用于基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦;The matching module is used to calculate the matching degree between multiple preset chords and each target segment based on the note sequence of each target segment, and for each target segment, use the preset chord with the highest matching degree as the corresponding target segment The target chord;
    生成模块,用于基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段。The generating module is configured to generate a harmony segment matched with the melody segment based on the target chords respectively corresponding to the multiple target segments.
  9. 一种电子设备,其中,包括:存储器和处理器;An electronic device, including: a memory and a processor;
    所述存储器中存储有计算机程序;A computer program is stored in the memory;
    所述处理器,用于在运行所述计算机程序时执行以下方法:The processor is configured to execute the following method when running the computer program:
    基于旋律片段的节拍将所述旋律片段划分成多个目标片段;Dividing the melody segment into multiple target segments based on the beat of the melody segment;
    基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦;Calculate the matching degree between a plurality of preset chords and each target segment based on the note sequence of each target segment, and for each target segment, use the preset chord with the highest matching degree as the target chord of the corresponding target segment;
    基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段。Based on the target chords respectively corresponding to the multiple target segments, a harmony segment matched with the melody segment is generated.
  10. 根据权利要求9所述的电子设备,其中,所述处理器在执行所述基于旋律片段的节拍将所述旋律片段划分成多个目标片段时,具体执行:The electronic device according to claim 9, wherein the processor, when executing the melody segment-based beat to divide the melody segment into a plurality of target segments, specifically executes:
    基于旋律片段的节拍确定可变参数;其中,所述可变参数为预设值或用户基于所述旋律片段的节拍设定的和弦密度;Determining a variable parameter based on the beat of the melody segment; wherein the variable parameter is a preset value or a chord density set by the user based on the beat of the melody segment;
    基于所述可变参数将所述旋律片段划分成多个目标片段。The melody segment is divided into a plurality of target segments based on the variable parameter.
  11. 根据权利要求9所述的电子设备,其中,所述处理器在所述基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦时,具体执行:9. The electronic device according to claim 9, wherein the processor respectively calculates the matching degree between a plurality of preset chords and the respective target segments in the note sequence based on each target segment, and for each target segment, When the preset chord with the highest matching degree is used as the target chord of the corresponding target segment, specifically execute:
    基于各个目标片段的音符序列与多个预设和弦确定目标参数;Determine the target parameters based on the note sequence of each target segment and multiple preset chords;
    采用隐马尔可夫模型基于所述目标参数分别计算多个预设和弦与所述各个目标片段的匹配度,获得所述各个目标片段分别对应的目标和弦,所述目标和弦为与相应目标片段匹配度最高的预设和弦。The Hidden Markov Model is used to calculate the matching degree between multiple preset chords and the respective target segments based on the target parameters, and the target chords corresponding to the respective target segments are obtained, and the target chords are matched with the corresponding target segments The preset chord with the highest degree.
  12. 根据权利要求11所述的电子设备,其中,所述处理器在所述基于各个目标片段的音符序列与多个预设和弦确定目标参数时,具体执行:11. The electronic device according to claim 11, wherein the processor specifically executes when the target parameter is determined based on the note sequence of each target segment and a plurality of preset chords:
    基于各个目标片段的音符序列确定多个预设和弦与所述各个目标片段的搭配概率;Determining the collocation probabilities of multiple preset chords and each target segment based on the note sequence of each target segment;
    基于所述旋律片段中的多个调号与每个预设和弦的音程关系确定多个预设和弦在各个调号中的概率分布;Determining the probability distribution of the multiple preset chords in each key signature based on the interval relationship between the multiple key signatures in the melody segment and each preset chord;
    基于预设变化概率计算多个预设和弦与各个调号组合的状态转移概率;其中,所述预设变化概率包括调号变化概率和预设和弦变化概率;Calculate the state transition probability of a combination of multiple preset chords and each key signature based on the preset change probability; wherein, the preset change probability includes the key signature change probability and the preset chord change probability;
    基于所述各个目标片段的音符序列、搭配概率、概率分布及状态转移概率生成目标参数。The target parameter is generated based on the note sequence, collocation probability, probability distribution, and state transition probability of each target segment.
  13. 根据权利要求11所述的电子设备,其中,所述处理器在所述基于所述目标参数分别计算多个预设和弦与所述各个目标片段的匹配度,获得所述各个目标片段分别对应的目标和弦时,具体执行:The electronic device according to claim 11, wherein the processor calculates the matching degree between a plurality of preset chords and the respective target segments based on the target parameters, and obtains the corresponding corresponding to the respective target segments. When the target chord, the specific implementation:
    基于所述目标参数分别计算多个预设和弦与排序在所述旋律片段首位的目标片段的匹配度;Respectively calculating the matching degree between a plurality of preset chords and the target segment ranked first in the melody segment based on the target parameter;
    若当前计算的目标片段排序在所述旋律片段的首位之后,确定当前计算的目标片段为第一目标片段,执行计算多个预设和弦与第一目标片段的匹配度的步骤:基于所述目标参数、及多个预设和弦与前序目标片段的匹配度,分别计算多个预设和弦与所述第一目标片段的匹配度,将排序在所述第一目标片段之后的下一目标片段,作为第一目标片段;其中,所述前序目标片段为在所述旋律片段中排序在所述第一目标片段之前的前一目标片段;If the currently calculated target segment is sorted after the first of the melody segment, it is determined that the currently calculated target segment is the first target segment, and the step of calculating the matching degree between a plurality of preset chords and the first target segment is performed: based on the target Parameters, and the matching degree between multiple preset chords and the previous target segment, respectively calculating the matching degree between multiple preset chords and the first target segment, and sorting the next target segment after the first target segment , As the first target segment; wherein the preamble target segment is the previous target segment sorted before the first target segment in the melody segment;
    重新执行计算多个预设和弦与第一目标片段的匹配度的步骤,直至完成多个预设和弦与所述各个目标片段的匹配度计算;Re-execute the step of calculating the matching degree between the multiple preset chords and the first target segment until the calculation of the matching degree between the multiple preset chords and the respective target segment is completed;
    自排序在所述旋律片段末位的目标片段向前回溯确定所述各个目标片段分别对应的目标和弦。The target segment that is at the end of the melody segment is automatically sorted forward and backward to determine the target chord corresponding to each of the target segments.
  14. 根据权利要求9所述的电子设备,其中,所述旋律片段存储于区块链中,所述处理器在所述基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段时,具体执行:The electronic device according to claim 9, wherein the melody segment is stored in a blockchain, and the processor generates a matching chord matching the melody segment based on the target chords corresponding to the multiple target segments. When harmonizing segments, the specific implementation:
    确定所述旋律片段中一小节被划分成至少两个及以上的目标片段;Determining that a section in the melody segment is divided into at least two or more target segments;
    在构成所述旋律片段一小节的至少两个及以上的目标片段分别对应的目标和弦中,将相同且相邻的目标和弦的时值进行合并;Combining the time values of the same and adjacent target chords in the target chords respectively corresponding to at least two or more target segments constituting a measure of the melody segment;
    基于合并时值后的目标和弦生成与所述旋律片段搭配的和声片段。Based on the combined time value of the target chord, a harmony segment matched with the melody segment is generated.
  15. 一种计算机可读介质,其上存储有计算机程序,其中,所述计算机程序被处理器执行时实现以下方法:A computer-readable medium having a computer program stored thereon, wherein the computer program implements the following method when executed by a processor:
    基于旋律片段的节拍将所述旋律片段划分成多个目标片段;Dividing the melody segment into multiple target segments based on the beat of the melody segment;
    基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦;Calculate the matching degree between a plurality of preset chords and each target segment based on the note sequence of each target segment, and for each target segment, use the preset chord with the highest matching degree as the target chord of the corresponding target segment;
    基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段。Based on the target chords respectively corresponding to the multiple target segments, a harmony segment matched with the melody segment is generated.
  16. 根据权利要求15所述的计算机可读介质,其中,所述基于旋律片段的节拍将所述旋律片段划分成多个目标片段时,具体实现:The computer-readable medium according to claim 15, wherein when the melody segment is divided into a plurality of target segments based on the beat of the melody segment, the specific realization is achieved:
    基于旋律片段的节拍确定可变参数;其中,所述可变参数为预设值或用户基于所述旋律片段的节拍设定的和弦密度;Determining a variable parameter based on the beat of the melody segment; wherein the variable parameter is a preset value or a chord density set by the user based on the beat of the melody segment;
    基于所述可变参数将所述旋律片段划分成多个目标片段。The melody segment is divided into a plurality of target segments based on the variable parameter.
  17. 根据权利要求15所述的计算机可读介质,其中,所述基于各个目标片段的音符序列分别计算多个预设和弦与所述各个目标片段的匹配度,并针对每个目标片段,将所述匹配度最高的预设和弦作为相应目标片段的目标和弦时,具体实现:The computer-readable medium according to claim 15, wherein the matching degree between a plurality of preset chords and the respective target segments is calculated based on the note sequence of each target segment, and for each target segment, the When the preset chord with the highest matching degree is used as the target chord of the corresponding target segment, the specific realization is as follows:
    基于各个目标片段的音符序列与多个预设和弦确定目标参数;Determine the target parameters based on the note sequence of each target segment and multiple preset chords;
    采用隐马尔可夫模型基于所述目标参数分别计算多个预设和弦与所述各个目标片段的匹配度,获得所述各个目标片段分别对应的目标和弦,所述目标和弦为与相应目标片段匹配度最高的预设和弦。The Hidden Markov Model is used to calculate the matching degree between multiple preset chords and the respective target segments based on the target parameters, and the target chords corresponding to the respective target segments are obtained, and the target chords are matched with the corresponding target segments The preset chord with the highest degree.
  18. 根据权利要求17所述的计算机可读介质,其中,所述基于各个目标片段的音符序列与多个预设和弦确定目标参数时,具体实现:18. The computer-readable medium according to claim 17, wherein when the target parameter is determined based on the note sequence of each target segment and a plurality of preset chords, the specific realization is achieved:
    基于各个目标片段的音符序列确定多个预设和弦与所述各个目标片段的搭配概率;Determining the collocation probabilities of multiple preset chords and each target segment based on the note sequence of each target segment;
    基于所述旋律片段中的多个调号与每个预设和弦的音程关系确定多个预设和弦在各个调号中的概率分布;Determining the probability distribution of the multiple preset chords in each key signature based on the interval relationship between the multiple key signatures in the melody segment and each preset chord;
    基于预设变化概率计算多个预设和弦与各个调号组合的状态转移概率;其中,所述预设变化概率包括调号变化概率和预设和弦变化概率;Calculate the state transition probability of a combination of multiple preset chords and each key signature based on the preset change probability; wherein, the preset change probability includes the key signature change probability and the preset chord change probability;
    基于所述各个目标片段的音符序列、搭配概率、概率分布及状态转移概率生成目标参数。The target parameter is generated based on the note sequence, collocation probability, probability distribution, and state transition probability of each target segment.
  19. 根据权利要求17所述的计算机可读介质,其中,所述基于所述目标参数分别计算多个预设和弦与所述各个目标片段的匹配度,获得所述各个目标片段分别对应的目标和弦时,具体实现:The computer-readable medium according to claim 17, wherein the matching degree between a plurality of preset chords and the respective target segments is calculated based on the target parameters, and the target chord time corresponding to the respective target segments is obtained. ,Implementation:
    基于所述目标参数分别计算多个预设和弦与排序在所述旋律片段首位的目标片段的匹配度;Respectively calculating the matching degree between a plurality of preset chords and the target segment ranked first in the melody segment based on the target parameter;
    若当前计算的目标片段排序在所述旋律片段的首位之后,确定当前计算的目标片段为第一目标片段,执行计算多个预设和弦与第一目标片段的匹配度的步骤:基于所述目标参数、及多个预设和弦与前序目标片段的匹配度,分别计算多个预设和弦与所述第一目标片段的匹配度,将排序在所述第一目标片段之后的下一目标片段,作为第一目标片段;其中,所述前序目标片段为在所述旋律片段中排序在所述第一目标片段之前的前一目标片段;If the currently calculated target segment is sorted after the first of the melody segment, it is determined that the currently calculated target segment is the first target segment, and the step of calculating the matching degree between a plurality of preset chords and the first target segment is performed: based on the target Parameters, and the matching degree between multiple preset chords and the previous target segment, respectively calculating the matching degree between multiple preset chords and the first target segment, and sorting the next target segment after the first target segment , As the first target segment; wherein the preamble target segment is the previous target segment sorted before the first target segment in the melody segment;
    重新执行计算多个预设和弦与第一目标片段的匹配度的步骤,直至完成多个预设和弦与所述各个目标片段的匹配度计算;Re-execute the step of calculating the matching degree between the multiple preset chords and the first target segment until the calculation of the matching degree between the multiple preset chords and the respective target segment is completed;
    自排序在所述旋律片段末位的目标片段向前回溯确定所述各个目标片段分别对应的目标和弦。The target segment at the end of the self-sorting melody segment goes backward to determine the target chord corresponding to each target segment.
  20. 根据权利要求15所述的计算机可读介质,其中,所述旋律片段存储于区块链中,所述基于所述多个目标片段分别对应的目标和弦生成与所述旋律片段搭配的和声片段时,具体实现:The computer-readable medium according to claim 15, wherein the melody segment is stored in a blockchain, and the harmony segment matched with the melody segment is generated based on the target chords respectively corresponding to the plurality of target segments When, the specific realization:
    确定所述旋律片段中一小节被划分成至少两个及以上的目标片段;Determining that a section in the melody segment is divided into at least two or more target segments;
    在构成所述旋律片段一小节的至少两个及以上的目标片段分别对应的目标和弦中,将相同且相邻的目标和弦的时值进行合并;Combining the time values of the same and adjacent target chords in the target chords respectively corresponding to at least two or more target segments constituting a measure of the melody segment;
    基于合并时值后的目标和弦生成与所述旋律片段搭配的和声片段。Based on the combined time value of the target chord, a harmony segment matched with the melody segment is generated.
PCT/CN2020/134894 2020-04-30 2020-12-09 Harmony matching method and apparatus, electronic device, and computer readable medium WO2021218158A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010364461.2 2020-04-30
CN202010364461.2A CN111681631B (en) 2020-04-30 2020-04-30 Collocation harmony method, collocation harmony device, electronic equipment and computer readable medium

Publications (1)

Publication Number Publication Date
WO2021218158A1 true WO2021218158A1 (en) 2021-11-04

Family

ID=72452461

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/134894 WO2021218158A1 (en) 2020-04-30 2020-12-09 Harmony matching method and apparatus, electronic device, and computer readable medium

Country Status (2)

Country Link
CN (1) CN111681631B (en)
WO (1) WO2021218158A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102358876B1 (en) * 2020-02-19 2022-02-08 (주)주스 Learning system and method for theory of harmony
CN111681631B (en) * 2020-04-30 2024-05-10 平安科技(深圳)有限公司 Collocation harmony method, collocation harmony device, electronic equipment and computer readable medium
CN112331170B (en) * 2020-10-28 2023-09-15 平安科技(深圳)有限公司 Method, device, equipment and storage medium for analyzing Buddha music melody similarity
CN114970651A (en) * 2021-02-26 2022-08-30 北京达佳互联信息技术有限公司 Training method of chord generation model, chord generation method, device and equipment
CN113744763B (en) * 2021-08-18 2024-02-23 北京达佳互联信息技术有限公司 Method and device for determining similar melodies

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103093748A (en) * 2013-01-31 2013-05-08 成都玉禾鼎数字娱乐有限公司 Method of automatically matching chord for known melody
US20140053711A1 (en) * 2009-06-01 2014-02-27 Music Mastermind, Inc. System and method creating harmonizing tracks for an audio input
CN105161087A (en) * 2015-09-18 2015-12-16 努比亚技术有限公司 Automatic harmony method, device, and terminal automatic harmony operation method
CN109841203A (en) * 2019-01-25 2019-06-04 得理乐器(珠海)有限公司 A kind of electronic musical instrument music harmony determines method and system
US20200105294A1 (en) * 2018-08-28 2020-04-02 Roland Corporation Harmony generation device and storage medium
CN111681631A (en) * 2020-04-30 2020-09-18 平安科技(深圳)有限公司 Method and device for matching harmony, electronic equipment and computer readable medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2759110B2 (en) * 1996-11-05 1998-05-28 カシオ計算機株式会社 Automatic composer
US6366885B1 (en) * 1999-08-27 2002-04-02 International Business Machines Corporation Speech driven lip synthesis using viseme based hidden markov models
FI20041173A (en) * 2004-09-09 2006-03-10 Saundi Oy Data processing means and method for producing music by means of data processing means
US7705231B2 (en) * 2007-09-07 2010-04-27 Microsoft Corporation Automatic accompaniment for vocal melodies
CN109859739B (en) * 2019-01-04 2023-12-22 平安科技(深圳)有限公司 Melody generation method and device based on voice synthesis and terminal equipment
CN109545177B (en) * 2019-01-04 2023-08-22 平安科技(深圳)有限公司 Melody matching method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140053711A1 (en) * 2009-06-01 2014-02-27 Music Mastermind, Inc. System and method creating harmonizing tracks for an audio input
CN103093748A (en) * 2013-01-31 2013-05-08 成都玉禾鼎数字娱乐有限公司 Method of automatically matching chord for known melody
CN105161087A (en) * 2015-09-18 2015-12-16 努比亚技术有限公司 Automatic harmony method, device, and terminal automatic harmony operation method
US20200105294A1 (en) * 2018-08-28 2020-04-02 Roland Corporation Harmony generation device and storage medium
CN109841203A (en) * 2019-01-25 2019-06-04 得理乐器(珠海)有限公司 A kind of electronic musical instrument music harmony determines method and system
CN111681631A (en) * 2020-04-30 2020-09-18 平安科技(深圳)有限公司 Method and device for matching harmony, electronic equipment and computer readable medium

Also Published As

Publication number Publication date
CN111681631A (en) 2020-09-18
CN111681631B (en) 2024-05-10

Similar Documents

Publication Publication Date Title
WO2021218158A1 (en) Harmony matching method and apparatus, electronic device, and computer readable medium
CN103902642B (en) Utilize the music composition system of the correlation between the lyrics and melody
US8987574B2 (en) System and method for analysis and creation of music
Raczyński et al. Melody harmonization with interpolated probabilistic models
US11568244B2 (en) Information processing method and apparatus
US9171530B2 (en) Methods and apparatus for creating music melodies using validated characters
US11948542B2 (en) Systems, devices, and methods for computer-generated musical note sequences
WO2020151150A1 (en) Dcgan-based music generation method, and music generation apparatus
WO2022111242A1 (en) Melody generation method, apparatus, readable medium, and electronic device
WO2021115311A1 (en) Song generation method, apparatus, electronic device, and storage medium
US10629176B1 (en) Systems, devices, and methods for digital representations of music
US12014708B2 (en) Systems, devices, and methods for harmonic structure in digital representations of music
WO2020029382A1 (en) Method, system and apparatus for building music composition model, and storage medium
CN111554267A (en) Audio synthesis method and device, electronic equipment and computer readable medium
EP3979241B1 (en) Audio clip matching method and apparatus, computer-readable medium and electronic device
Garani et al. An algorithmic approach to South Indian classical music
CN111863030A (en) Audio detection method and device
US6984781B2 (en) Music formulation
JP5093806B2 (en) Similar music search system
US10115380B1 (en) Providing feedback on musical performance
McVicar et al. Using online chord databases to enhance chord recognition
CN110517655B (en) Melody generation method and system
Gómez-Martín et al. Interlocking and Euclidean rhythms
WO2022202297A1 (en) Text providing method, program, and text providing device
US11727906B1 (en) System for generating and implementing digital music tuning files

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20932925

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20932925

Country of ref document: EP

Kind code of ref document: A1