A method, device, terminal equipment and computer storage medium for detecting music tonality
By performing frame-based and spectrum analysis of music signals, the tone of music is quickly identified, which solves the problem of high computational volume and difficulty in quickly identifying tone in the existing technology, and achieves rapid and accurate tone recognition, which improves the scientificity of performance and auditory experience.
Patent Information
- Application Number
- CN202110209096.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-24
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2041-02-24
AI Technical Summary
In the prior art, detecting music tone requires analyzing the score information of the entire song, which is very computational and difficult to quickly identify the tone of the music.
By framed the music signal, extracting the spectrum information of each frame signal, and performing real-time superposition and mean calculations. After the mean is stable, several pitch frequencies are extracted according to the spectrum amplitude from large to small, and matching it with the standard tone to determine the tone of the music signal.
It realizes the rapid identification of music tone, reduces the amount of calculation, and facilitates the performers to set, transfer and match the tone of electronic instruments, improving the scientificity of the performance and auditory experience.
Smart Images

Figure CN113012666B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of audio technology, and in particular to a method, device, terminal equipment and computer storage medium for detecting music tonality. Background Art
[0002] Tonality is the soul of music and plays a framing role in the establishment and development of music. Therefore, it is of great significance to composers in the process of music creation. For performers, tonality analysis before performance can help performers to transpose instruments with mismatched tonality in the accompaniment, which is helpful for performing performers to complete music works more scientifically. However, for those who are not very familiar with music theory, it is very difficult to distinguish the tonality of music through human ears.
[0003] The prior art (publication number CN108231046A) discloses a method and device for identifying the tonality of a song. In this patent, the score of the preset tonality at each designated position of the song is calculated by obtaining the score of the preset tonality at each position of the song and the weight of each designated position, and the matching score of the preset tonality is evaluated. The tonality of the song is determined according to the matching score of the preset tonality. Although this method can realize automatic identification of the tonality of a song, it is necessary to analyze the score information of the entire song before determining the tonality of the song, and the amount of calculation is large in actual operation.
[0004] Therefore, how to quickly identify the tonality of music is a problem that urgently needs to be solved. Summary of the invention
[0005] The purpose of the present invention is to provide a method, device, terminal equipment and computer storage medium for detecting the tonality of music, which can automatically identify the tonality of music, provide an effective reference basis for performers to analyze the work, and facilitate performers to tune, transpose and match the tonality of electronic instruments.
[0006] To achieve this purpose, the technical solution of the present invention is:
[0007] In a first aspect, an embodiment of the present invention provides a method for detecting music tonality, characterized in that the method comprises:
[0008] Divide the music signal into frames and extract the spectrum information of each frame signal;
[0009] The spectrum information extracted from each frame is superimposed in real time and the average of the historical spectrum is calculated;
[0010] After the mean value is stabilized, the first several pitch frequencies in the spectrum are extracted according to the amplitude from large to small, and matched with the standard tonality to determine the tonality of the accompaniment signal.
[0011] Furthermore, the step of dividing the music signal into frames and extracting the spectrum information of each frame of the signal specifically includes: performing Fourier transform on each frame of data to obtain the frequency components of each frame of the signal.
[0012] Furthermore, the spectrum information extracted from each frame is superimposed in real time and the historical spectrum is averaged, specifically including: using formula S k =(1 / k)·(X1+…X k ) to superimpose the spectrum information, where X k represents the spectrum information of the kth frame, S k It is the average result of the spectrum information accumulated in the previous k frames.
[0013] Furthermore, when |S k -S k-1 |<△, you can start tonality matching, where △ is a custom value.
[0014] Further, a plurality of pitch frequencies are extracted from large to small according to the spectrum amplitude, and matched with the standard tonality to determine the tonality of the accompaniment signal, specifically including:
[0015] Before matching with the standard tonality, the frequencies that are not on the standard tonality pitch among the plurality of pitch frequencies are first eliminated, and then 7 pitch frequencies are extracted from the remaining pitch frequencies according to the amplitude.
[0016] Furthermore, the extracted 7 pitch frequencies are matched with the standard tonality, and the number of scale matches is compared. The tonality with the largest number of scale matches in the standard tonality is the tonality of the music signal.
[0017] Furthermore, when the number of scale matches is the same, the sum of the amplitudes of the matched scales is compared, and the key with the larger sum of amplitudes is the tonality of the music signal.
[0018] Furthermore, when the sum of the amplitudes of the matching scales is the same, the amplitudes of the tonic are compared, and the key with the larger tonic amplitude is the tonality of the music signal.
[0019] In a second aspect, an embodiment of the present invention provides a device for detecting the tonality of an accompaniment, characterized in that the device comprises:
[0020] An extraction unit, used to divide the music signal into frames and extract the spectrum information of each frame signal;
[0021] A superposition unit, used for superimposing the spectrum information extracted from each frame in real time and calculating the average of the historical spectrum;
[0022] The matching unit is used to extract the first several pitch frequencies in the spectrum according to the amplitude from large to small after the mean value is stabilized, match them with the standard tonality, and determine the tonality of the accompaniment signal.
[0023] Furthermore, the step of dividing the music signal into frames and extracting the spectrum information of each frame of the signal specifically includes: the extraction unit performing Fourier transform on each frame of data to obtain the frequency components of each frame of the signal.
[0024] Furthermore, the spectrum information extracted from each frame is superimposed in real time and the historical spectrum is averaged, specifically including: the superposition unit uses formula S k =(1 / k)·(X1+…X k ) to superimpose the spectrum information, where X k represents the spectrum information of the kth frame, S k It is the average result of the spectrum information accumulated in the previous k frames.
[0025] Furthermore, when |S k -S k-1 |<△, you can start tonality matching, where △ is a custom value.
[0026] Further, a plurality of pitch frequencies are extracted from large to small according to the spectrum amplitude, and matched with the standard tonality to determine the tonality of the accompaniment signal, specifically including:
[0027] Before matching with the standard tonality, the frequencies that are not on the standard tonality pitch among the plurality of pitch frequencies are first eliminated, and then 7 pitch frequencies are extracted from the remaining pitch frequencies according to the amplitude.
[0028] Furthermore, the extracted 7 pitch frequencies are matched with the standard tonality, and the number of scale matches is compared. The tonality with the largest number of scale matches in the standard tonality is the tonality of the music signal.
[0029] Furthermore, when the number of scale matches is the same, the sum of the amplitudes of the matched scales is compared, and the key with the larger sum of amplitudes is the tonality of the music signal.
[0030] Furthermore, when the sum of the amplitudes of the matching scales is the same, the amplitudes of the tonic are compared, and the key with the larger tonic amplitude is the tonality of the music signal.
[0031] In a third aspect, an embodiment of the present invention provides a terminal device, characterized in that the terminal device comprises: a memory and a processor, the memory stores a computer program, and the computer program is loaded and executed by the processor to implement the method for detecting music tonality as described in the first aspect.
[0032] In a fourth aspect, an embodiment of the present invention provides a computer storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method for detecting music tonality as described in the first aspect is implemented.
[0033] Beneficial Effects
[0034] Compared with the prior art, the beneficial effects of the present invention are as follows: the method, device, terminal equipment and computer storage medium for detecting the tonality of music provided by the present invention can detect the tonality of music, thereby facilitating performers to analyze the characteristics of the performance works, and to perform relevant processing on the rhythm, timbre, pitch, emotion, phrasing, performance style, etc. according to the tonality, so as to form a comprehensive understanding of the performance works. In addition, it can facilitate performers to tune, transpose and adapt the tonality of electronic musical instruments, thereby bringing a good auditory experience to the audience. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A method flow chart of a method for detecting accompaniment tonality provided by an embodiment of the present invention.
[0036] Figure 2 A schematic diagram of the structure of a device for detecting the tonality of an accompaniment provided by an embodiment of the present invention.
[0037] Figure 3 A schematic diagram of the hardware structure of a method for detecting accompaniment tonality provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0038] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0039] Embodiment 1
[0040] Tonality includes the tonic and mode, which is the general term for the tonic pitch and mode category of the key. According to the twelve-tone equal temperament, an octave can be evenly divided into 12 equal parts according to frequency, recorded as C, C#, D, D#, E, F, F#, G, G#, A, A#, B, and the difference between adjacent notes is a semitone. Taking each of the twelve notes as the tonic of a key and combining them with the type of key (major and minor), we can get twenty-four standard tonality, including C major (CDEFGAB), C# major (C#D#FF#G#A#C), D major (DE F#GABC#), D# major (D#FGG#A#CDD#), E major (EF#G#ABC#D#), F major (FGAA#CD E), F# major (F#G#A#BC#D#E#), G major (GABCDEF#), G# major (G#A#CC#D#FG), A major (ABC#DEF#G#), A# major (A#CDD#FGA), B major (BC#D#EF#G#A#), and minor keys with the same tonic.
[0041] Among them, two modes (one major mode and one minor mode) with the same relationship between the tone group and the tone series and different tonic pitches are called relative major and minor keys, such as C major (CDEFGAB) and relative A minor (ABCDEFG), whose constituent notes are the same, only the scale arrangement order is different, and one is based on C as the tonic and the other is based on A as the tonic. In the case of most musical instrument performances, the performer does not need to distinguish between major and minor keys, but only needs to know the constituent notes of the mode, because the constituent notes of the relative major and minor keys are the same, only the arrangement order is different. In actual performance, the performance fingering of the relative major and minor keys does not change. Therefore, in actual application, since the score of a song is fixed, we only need to identify the corresponding scale under the score, that is, there is no need to distinguish whether it is a major or a minor key. The tonality of the detected music in this embodiment actually refers to the constituent notes of the detected music.
[0042] See attached Figure 1 The embodiment of the present invention provides a method for detecting music tonality, characterized in that the method comprises:
[0043] Divide the music signal into frames and extract the spectrum information of each frame signal;
[0044] The spectrum information extracted from each frame is superimposed in real time and the average of the historical spectrum is calculated;
[0045] After the mean value is stabilized, the first several pitch frequencies in the spectrum are extracted according to the amplitude from large to small, and matched with the standard tonality to determine the tonality of the accompaniment signal.
[0046] Furthermore, the step of dividing the music signal into frames and extracting the spectrum information of each frame of the signal specifically includes: performing Fourier transform on each frame of data to obtain the frequency components of each frame of the signal.
[0047] Furthermore, the spectrum information extracted from each frame is superimposed in real time and the historical spectrum is averaged, specifically including: using formula S k =(1 / k)·(X1+…X k ) to superimpose the spectrum information, where X k represents the spectrum information of the kth frame, S k It is the average result of the spectrum information accumulated in the previous k frames.
[0048] Furthermore, when |S k -S k-1 When |<△, it means that the mean of the spectrum information is stable and tonality matching can be started, where △ is a custom value.
[0049] It should be noted that the accompaniment signal can be of a single key or multiple keys. When multiple keys exist, when changing keys, |S k -S k-1 |The result starts to jump from a stable state, repeating the above steps until |S appears again k -S k-1 |The result is less than △, and the tonality matching can be performed again.
[0050] Further, a plurality of pitch frequencies are extracted from large to small according to the spectrum amplitude, and matched with the standard tonality to determine the tonality of the accompaniment signal, specifically including:
[0051] Before matching with the standard tonality, the frequencies that are not on the standard tonality pitch are first eliminated, and then 7 pitch frequencies are extracted from the remaining pitch frequencies according to the amplitude.
[0052] Furthermore, the extracted 7 pitch frequencies are matched with the standard tonality, and the number of scale matches is compared. The tonality with the largest number of scale matches in the standard tonality is the tonality of the music signal.
[0053] Furthermore, when the number of scale matches is the same, the sum of the amplitudes of the matched scales is compared, and the key with the larger sum of amplitudes is the tonality of the music signal.
[0054] Furthermore, when the sum of the amplitudes of the matching scales is the same, the amplitudes of the tonic are compared, and the key with the larger tonic amplitude is the tonality of the music signal.
[0055] Since there is no need to distinguish between major and minor keys, this embodiment takes major key as an example. Assuming that the first seven pitch frequencies extracted according to the spectrum amplitude are compared with the standard tonality, the number of matches with the scale of C major is the largest, then it is considered that the tonality of the accompaniment signal is C major.
[0056] Furthermore, assuming that after comparing with the standard tonality, the number of scale matches with C major and G major is the largest, then the sum of the amplitudes of the matching scales in C major and the sum of the amplitudes of the matching scales in G major are calculated respectively, and the larger sum of the amplitudes is the tonality of the music signal. When the sum of the amplitudes of the two is the same, the amplitudes of the tonics of the two tonality are compared, and the one with the larger tonic amplitude is the tonality of the music signal.
[0057] Through the method of this embodiment, the tonality of the music can be quickly identified, providing a reference for performers to analyze the work, and facilitating the tuning, transposition and tonality adaptation of the accompaniment instruments.
[0058] Embodiment 2
[0059] See also Figure 2 , an embodiment of the present invention provides a structural schematic diagram of a device for detecting music tonality, and the device is the execution body of the method for detecting music tonality described in Example 1.
[0060] For details, see the attached Figure 2 , characterized in that the device comprises:
[0061] An extraction unit, used to divide the music signal into frames and extract the spectrum information of each frame signal;
[0062] A superposition unit, used for superimposing the spectrum information extracted from each frame in real time and calculating the average of the historical spectrum;
[0063] The matching unit is used to extract the first several pitch frequencies in the spectrum according to the amplitude from large to small after the mean value is stabilized, match them with the standard tonality, and determine the tonality of the accompaniment signal.
[0064] Furthermore, the step of dividing the music signal into frames and extracting the spectrum information of each frame of the signal specifically includes: the extraction unit performing Fourier transform on each frame of data to obtain the frequency components of each frame of the signal.
[0065] Furthermore, the spectrum information extracted from each frame is superimposed in real time and the historical spectrum is averaged, specifically including: the superposition unit uses formula S k =(1 / k)·(X1+…X k ) to superimpose the spectrum information, where X k represents the spectrum information of the kth frame, S k It is the average result of the spectrum information accumulated in the previous k frames.
[0066] Furthermore, when |S k -S k-1 |<△, you can start tonality matching, where △ is a custom value.
[0067] Further, a plurality of pitch frequencies are extracted from large to small according to the spectrum amplitude, and matched with the standard tonality to determine the tonality of the accompaniment signal, specifically including:
[0068] Before matching with the standard tonality, the frequencies that are not on the standard tonality pitch among the plurality of pitch frequencies are first eliminated, and then 7 pitch frequencies are extracted from the remaining pitch frequencies according to the amplitude.
[0069] Furthermore, the extracted 7 pitch frequencies are matched with the standard tonality, and the number of scale matches is compared. The tonality with the largest number of scale matches in the standard tonality is the tonality of the music signal.
[0070] Furthermore, when the number of scale matches is the same, the sum of the amplitudes of the matched scales is compared, and the key with the larger sum of amplitudes is the tonality of the music signal.
[0071] Furthermore, when the sum of the amplitudes of the matching scales is the same, the amplitudes of the tonic are compared, and the key with the larger tonic amplitude is the tonality of the music signal.
[0072] Embodiment 3
[0073] In order to implement the above-mentioned method for detecting music tonality, the embodiment of the present invention further provides a hardware structure of the method for detecting music tonality. The hardware structure of the method for detecting music tonality in the embodiment of the present invention is further described below. Figure 3 It is a schematic block diagram of a terminal device provided in an embodiment of the present application.
[0074] This embodiment provides a terminal device 100, such as Figure 3 As shown, the terminal device 100 includes: a memory 110 and a processor 120, wherein the memory 110 stores a computer program, and the computer program is loaded and executed by the processor 120 to implement the steps described in Example 1. Alternatively, the computer program is loaded and executed by the processor 120 to implement the functions of each unit in Example 2.
[0075] The processor 120 may be a processor or a collective name for multiple processing elements. The memory 110 may be a read-only memory or other types of static storage devices that can store static information and instructions, a random access memory or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory, a read-only optical disc or other optical disc storage, an optical disc storage (including a compact disc, a laser disc, an optical disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.
[0076] The terminal device 100 may further include a communication interface 130 and a communication bus 140 . The communication interface 130 is used to enable the terminal device 100 to communicate with other devices, and the communication bus 140 is used to connect the processor 120 , the memory 110 and the communication interface 130 .
[0077] Embodiment 4
[0078] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program.
[0079] Therefore, an embodiment of the present invention provides a computer-readable storage medium on which an executable computer program is stored, characterized in that when the executable computer program is executed by a processor, the method for detecting the music tonality as described in the above-mentioned embodiment 1 is implemented.
[0080] The computer program includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer readable media do not include electric carrier signals and telecommunication signals.
[0081] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0082] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and units can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0083] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0084] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0085] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0086] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for detecting music tonality, characterized in that: The method includes: Divide the music signal into frames and extract the spectrum information of each frame signal; The spectrum information extracted from each frame is superimposed in real time and the average of the historical spectrum is calculated; After the mean value is stable, the first several pitch frequencies in the spectrum are extracted according to the amplitude from large to small, and matched with the standard tonality to determine the tonality of the accompaniment signal; The real-time superposition of the spectrum information extracted from each frame and the averaging of the historical spectrum specifically include: k =(1 / k)·(X1+…X k ) to superimpose the spectrum information, where X k represents the spectrum information of the kth frame, S k is the average result of the spectrum information accumulated in the previous k frames; When it continues to appear |S k -S k-1 |<△, you can start tonality matching, where △ is a custom value; Extracting a number of pitch frequencies from large to small according to the spectrum amplitude, matching them with the standard tonality, and determining the tonality of the accompaniment signal, specifically includes: Before matching with the standard tonality, first remove the frequencies that are not on the standard tonality pitch among the plurality of pitch frequencies, and then extract 7 pitch frequencies from the remaining pitch frequencies according to the amplitude; Furthermore, the extracted 7 pitch frequencies are matched with the standard tonality, and the number of scale matches is compared. The tonality with the largest number of scale matches in the standard tonality is the tonality of the music signal.
2. A method for detecting music tonality according to claim 1, characterized in that: The step of dividing the music signal into frames and extracting the spectrum information of each frame of the signal specifically includes: performing Fourier transform on each frame of data to obtain the frequency components of each frame of the signal.
3. A method for detecting music tonality according to claim 1, characterized in that: Furthermore, when the number of scale matches is the same, the sum of the amplitudes of the matched scales is compared, and the key with the larger sum of amplitudes is the tonality of the music signal.
4. A method for detecting music tonality according to claim 3, characterized in that: Furthermore, when the sum of the amplitudes of the matching scales is the same, the amplitudes of the tonic are compared, and the key with the larger tonic amplitude is the tonality of the music signal.
5. A device for detecting music tonality, characterized in that: The device includes: An extraction unit, used to divide the music signal into frames and extract the spectrum information of each frame signal; A superposition unit, used for superimposing the spectrum information extracted from each frame in real time and calculating the average of the historical spectrum; A matching unit is used to extract the first several pitch frequencies in the spectrum according to the amplitude from large to small after the mean value is stabilized, match them with the standard tonality, and determine the tonality of the accompaniment signal; The real-time superposition of the spectrum information extracted from each frame and averaging of the historical spectrum specifically includes: the superposition unit uses the formula S k =(1 / k)·(X1+…X k ) to superimpose the spectrum information, where X k represents the spectrum information of the kth frame, S k is the average result of the spectrum information accumulated in the previous k frames; When it continues to appear |S k -S k-1 |<△, you can start tonality matching, where △ is a custom value; Extracting a number of pitch frequencies from large to small according to the spectrum amplitude, matching them with the standard tonality, and determining the tonality of the accompaniment signal, specifically includes: Before matching with the standard tonality, first remove the frequencies that are not on the standard tonality pitch among the plurality of pitch frequencies, and then extract 7 pitch frequencies from the remaining pitch frequencies according to the amplitude; Furthermore, the extracted 7 pitch frequencies are matched with the standard tonality, and the number of scale matches is compared. The tonality with the largest number of scale matches in the standard tonality is the tonality of the music signal.
6. The device for detecting music tonality according to claim 5, characterized in that: The step of dividing the music signal into frames and extracting the spectrum information of each frame of the signal specifically includes: the extraction unit performing Fourier transform on each frame of data to obtain the frequency components of each frame of the signal.
7. The device for detecting music tonality according to claim 5, characterized in that: Furthermore, when the number of scale matches is the same, the sum of the amplitudes of the matched scales is compared, and the key with the larger sum of amplitudes is the tonality of the music signal.
8. The device for detecting music tonality according to claim 7, characterized in that: Furthermore, when the sum of the amplitudes of the matching scales is the same, the amplitudes of the tonic are compared, and the key with the larger tonic amplitude is the tonality of the music signal.
9. A terminal device, characterized in that: The terminal device comprises: a memory and a processor, wherein a computer program is stored in the memory, and the computer program is loaded and executed by the processor to implement the method for detecting music tonality as described in any one of claims 1-4.
10. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, a method for detecting music tonality as described in any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Song tonality identification method and device
CN108231046A
Method for extracting melody of counterpoint based on GPU
CN103247286A
Self-study effector capable of duplicating tone
CN109473086A