A music generation method based on sports movements and a sports bracelet
By collecting motion data and generating beat velocity and melody lines, combining inertial sensors and MIDI formats, the problem of difficulty in directly connecting music generation in the prior art is solved, and music generation in response to motion movements is realized in real time.
Patent Information
- Application Number
- CN202111641264.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2041-12-29
AI Technical Summary
The existing musical melody-based generation methods are difficult to directly connect with people, and are difficult to break out of the database framework, and are unable to truly respond to movements in real time.
The user's motion data is collected through the six-axis inertial sensor, the beat velocity and melody lines of the music are generated, the rhythm array is randomly generated, and the corresponding melody lines are generated based on the three-axis angular velocity data, and the MIDI song is generated through the standard MIDI format.
It realizes the real-time generation of musical melodies that follow the movement during the movement process, and users can become natural composers without storing a large amount of musical melodies data.
Smart Images

Figure CN114299900B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of music technology, and in particular to a music generation method based on sports movements and a sports bracelet. Background Art
[0002] Sports and music are two elements that are often linked together in people's leisure activities. Listening to music while exercising has become a routine for many sports enthusiasts. If music melodies related to sports movements can be generated during exercise, it will bring more fun to people. At present, many people in the field of digital music are studying the algorithm of artificial intelligence to generate music. The commonly used algorithm is generally a pre-selected music style, which is composed of appropriate fragments selected by random number generation from a huge music melody database. The melodies generated in this way are difficult to directly connect with people, and it is difficult to jump out of the framework of the database. Summary of the invention
[0003] In view of the above problems, the present application provides a music generation method based on sports movements and a sports bracelet to solve the problem that the existing music melody generation is difficult to directly connect with people and difficult to jump out of the database framework.
[0004] To achieve the above object, the inventor provides a method for generating music based on sports movements, comprising the following steps:
[0005] Motion data collection: The user's motion data is collected through a six-axis inertial sensor, and the motion data includes three-axis acceleration data and three-axis angular velocity data;
[0006] Music tempo generation: Generate the tempo of the music based on the collected three-axis acceleration data;
[0007] Rhythm generation: randomly generate a preset number of integers as the rhythm of a preset number of measures;
[0008] Melody generation: read the collected three-axis angular velocity data according to the generated rhythm, convert the acquired three-axis angular velocity data into the corresponding scale, and generate the corresponding melody line;
[0009] Music generation: Generate MIDI music in standard MIDI format based on the generated melody line and beat tempo.
[0010] Further optimization, the music tempo generating step specifically includes the following steps:
[0011] Read the three-axis acceleration data within a preset time at a preset frequency;
[0012] Calculate the absolute value A(t) of the read three-axis acceleration data;
[0013] The calculated absolute value A(t) is transformed through Fourier discrete transformation to obtain the frequency domain data of the three-axis acceleration data A'(f)=DFT[A(t)];
[0014] The frequency f0 at which the peak value is located is obtained by fitting the frequency domain data A'(f) with a Gaussian function;
[0015] The tempo of the music is calculated based on the obtained frequency f0 as 60*f0 bpm.
[0016] Further optimization, the step rhythm generation step specifically includes the following steps:
[0017] Generate a preset number of positive integers, the positive integer is within a preset range, the preset number is a preset number of measures, the preset range is two to the power of m, and m is the number of beats in the preset beat * duration;
[0018] Convert the generated positive integer into a binary number, where the number of bits of the binary number is m;
[0019] The generated preset number of binary numbers constitutes the rhythm array of the music.
[0020] Further optimization, the melody generation step specifically includes the following steps
[0021] Establish a correspondence table between triaxial angular velocity data and natural scale;
[0022] Read the value of each bit in the binary system according to the preset beat time period to determine whether a new note needs to be generated;
[0023] If the value on the bit is 1, a new note is generated;
[0024] If the value on the digit is 0, the previous note continues;
[0025] When a new note is generated, the three-axis angular velocity data is read.
[0026] The notes corresponding to the three-axis angular velocity data are read and added to the corresponding melody line to generate a melody line including time points and notes.
[0027] Further optimization, the music generation specifically includes the following steps:
[0028] Generate a MIDI file header of a MIDI music, and add the tempo of the music as a key parameter to the MIDI file header;
[0029] The generated melody line generates MIDI note switch messages according to the MIDI standard specification and is added to the MIDI file to form a MIDI music.
[0030] Another technical solution is also provided: a sports bracelet with a music generation function, including a bracelet body, a single-chip microcomputer and a six-axis inertial sensor;
[0031] The six-axis inertial sensor and the single-chip microcomputer are arranged in the wristband body;
[0032] The bracelet body is used to be worn on the user's hand;
[0033] The six-axis inertial sensor is used to collect the user's motion data, and the motion data includes three-axis acceleration data and three-axis angular velocity data;
[0034] The single-chip microcomputer is used to generate the beat speed of the music according to the collected three-axis acceleration data, randomly generate a preset number of integers as the rhythm of a preset number of measures, read the collected three-axis angular velocity data according to the generated rhythm, convert the acquired three-axis angular velocity data into a corresponding scale, and generate a corresponding melody line, and generate a MIDI music according to the generated melody line and beat speed through the standard MIDI format.
[0035] Further optimization, the single chip microcomputer is also used for:
[0036] Calculate the absolute value A(t) of the read three-axis acceleration data;
[0037] The calculated absolute value A(t) is transformed through Fourier discrete transformation to obtain the frequency domain data of the three-axis acceleration data A'(f)=DFT[A(t)];
[0038] The frequency f0 at which the peak value is located is obtained by fitting the frequency domain data A'(f) with a Gaussian function;
[0039] The tempo of the music is calculated based on the obtained frequency f0 as 60*f0 bpm.
[0040] Further optimization, the single chip microcomputer is also used for:
[0041] Generate a preset number of positive integers, the positive integer is within a preset range, the preset number is a preset number of measures, the preset range is two to the power of m, and m is the number of beats in the preset beat * duration;
[0042] Convert the generated positive integer into a binary number, where the number of bits of the binary number is m;
[0043] The generated preset number of binary numbers constitutes the rhythm array of the music.
[0044] Further optimization, the single chip microcomputer is also used for:
[0045] Establish a correspondence table between triaxial angular velocity data and natural scale;
[0046] Read the value of each bit in the binary system according to the preset beat time period to determine whether a new note needs to be generated;
[0047] If the value on the bit is 1, a new note is generated;
[0048] If the value on the digit is 0, the previous note continues;
[0049] When a new note is generated, the three-axis angular velocity data is read.
[0050] The notes corresponding to the three-axis angular velocity data are read and added to the corresponding melody line to generate a melody line including time points and notes.
[0051] Further optimization, the single chip microcomputer is also used for:
[0052] Generate a MIDI file header of a MIDI music, and add the tempo of the music as a key parameter to the MIDI file header;
[0053] The generated melody line generates MIDI note switch messages according to the MIDI standard specification and is added to the MIDI file to form a MIDI music.
[0054] Different from the prior art, the above technical solution collects the user's motion data through a six-axis inertial sensor when a person is exercising, wherein the motion data includes three-axis acceleration data and three-axis angular velocity data, and generates the beat speed of the music through the collected three-axis acceleration data, and then randomly generates a preset number of whole seats as the rhythm of the preset number of measures, and then reads the collected three-axis angular velocity data according to the generated rhythm, and then converts the acquired three-axis acceleration data into a corresponding scale to generate a corresponding melody line, and then generates MIDI music through the standard MIDI format according to the generated melody line and the beat speed of the music, thereby combining the user's motion data with the generation of music, and there is no need to store a large amount of music melody data, so that everyone can become a natural composer.
[0055] The above-mentioned records related to the invention content are only an overview of the technical solution of the present application. In order to enable ordinary technicians in the field to more clearly understand the technical solution of the present application, and then implement it according to the text of the specification and the contents recorded in the drawings, and to make the above-mentioned purpose and other purposes, features and advantages of the present application easier to understand, the following is an explanation in combination with the specific implementation mode and drawings of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The drawings are only used to illustrate the principles, implementation methods, applications, characteristics and effects of the specific embodiments of the present application and other related contents, and shall not be considered as limitations of the present application.
[0057] In the drawings of the specification:
[0058] Figure 1 A schematic diagram of the structure of a sports bracelet with a music generation function according to a specific implementation method;
[0059] Figure 2 A flowchart of a method for generating music based on sports movements described in a specific implementation method.
[0060] Figure 3 Another schematic flow chart of the method for generating music based on sports movements described in the specific implementation method;
[0061] Figure 4 A schematic flow chart of a music tempo generating step described in a specific implementation method;
[0062] Figure 5 A schematic flow chart of the rhythm generation step described in the specific implementation method;
[0063] Figure 6 A schematic flow chart of the melody generation step described in the specific implementation method.
[0064] The reference numerals in the above drawings are described as follows:
[0065] 100. Sports bracelet,
[0066] 110. Six-axis inertial sensor,
[0067] 120. Single chip microcomputer. DETAILED DESCRIPTION
[0068] In order to explain in detail the possible application scenarios, technical principles, specific schemes that can be implemented, and the purposes and effects that can be achieved, the following is a detailed description of the specific embodiments listed in conjunction with the accompanying drawings. The embodiments described herein are only used to more clearly illustrate the technical solutions of the present application, and are therefore only used as examples, and cannot be used to limit the scope of protection of the present application.
[0069] Reference to "embodiment" herein means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present application. The term "embodiment" appearing in various places in the specification does not necessarily refer to the same embodiment, nor does it particularly limit its independence or association with other embodiments. In principle, in the present application, as long as there is no technical contradiction or conflict, the various technical features mentioned in the embodiments can be combined in any way to form a corresponding implementable technical solution.
[0070] Unless otherwise defined, the technical terms used in this document have the same meanings as those generally understood by those skilled in the art to which this application belongs; the use of relevant terms in this document is only for describing specific embodiments and is not intended to limit this application.
[0071] In the description of this application, the term "and / or" is an expression used to describe the logical relationship between objects, indicating that three relationships may exist, for example, A and / or B, which means: A exists, B exists, and A and B exist at the same time. In addition, the character " / " in this article generally indicates that the objects before and after are in an "or" logical relationship.
[0072] In the present application, terms such as “first” and “second” are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship of quantity, priority or sequence between these entities or operations.
[0073] Without further limitations, in this application, the words "include", "comprises", "has" or other similar expressions used in the sentences are intended to cover non-exclusive inclusion. These expressions do not exclude the presence of additional elements in the process, method or product including the elements, so that the process, method or product including a series of elements may include not only those limited elements, but also other elements not explicitly listed, or also include elements inherent to such process, method or product.
[0074] Similar to the understanding in the Examination Guidelines, in this application, expressions such as "greater than", "less than", "exceed" and the like are understood to exclude the number itself; expressions such as "above", "below", "within" and the like are understood to include the number itself. In addition, in the description of the embodiments of this application, "multiple" means more than two (including two), and similar expressions related to "multiple" are also understood in this way, such as "multiple groups", "multiple times", etc., unless otherwise clearly and specifically limited.
[0075] In the description of the embodiments of the present application, space-related expressions used, such as "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "vertical", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential", etc., indicate the orientation or position relationship based on the orientation or position relationship shown in the specific embodiments or drawings, and are only for the convenience of describing the specific embodiments of the present application or facilitating the reader's understanding, and do not indicate or imply that the referred device or component must have a specific position, a specific orientation, or be constructed or operated in a specific orientation, and therefore cannot be understood as a limitation on the embodiments of the present application.
[0076] Unless otherwise expressly specified or limited, in the description of the embodiments of the present application, the terms such as "install", "connect", "connect", "fix", "set", etc. used should be understood in a broad sense. For example, the "connection" can be a fixed connection, a detachable connection, or an integrated setting; it can be a mechanical connection, an electrical connection, or a communication connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium; it can be the internal connection of two elements or the interaction relationship between two elements. For technicians in the technical field to which the present application belongs, the specific meanings of the above terms in the embodiments of the present application can be understood according to the specific circumstances.
[0077] See also Figure 1 , this embodiment provides a sports bracelet 100 with a music generation function, including a bracelet body, a single-chip computer 120 and a six-axis inertial sensor 110;
[0078] The six-axis inertial sensor 110 and the single-chip microcomputer 120 are arranged in the wristband body;
[0079] The bracelet body is used to be worn on the user's hand;
[0080] The six-axis inertial sensor 110 is used to collect the user's motion data, and the motion data includes three-axis acceleration data and three-axis angular velocity data;
[0081] The single-chip computer 120 is used to generate the beat speed of the music according to the collected three-axis acceleration data, randomly generate a preset number of integers as the rhythm of a preset number of measures, read the collected three-axis angular velocity data according to the generated rhythm, convert the acquired three-axis angular velocity data into a corresponding scale, and generate a corresponding melody line, and generate a MIDI music according to the generated melody line and beat speed through the standard MIDI format.
[0082] An inertial sensor is a sensor that mainly detects and measures acceleration, tilt, shock, vibration, rotation, and multi-degree-of-freedom (DoF) motion. It is an important component for solving navigation, orientation, and motion carrier control. An inertial sensor includes an accelerometer (or acceleration sensor) and an angular velocity sensor (gyroscope). The six-axis inertial sensor 110 includes a three-axis gyroscope and a three-axis acceleration sensor.
[0083] Single-Chip Microcomputer 120 is an integrated circuit chip. It uses ultra-large-scale integrated circuit technology to integrate the central processing unit CPU with data processing capabilities, random access memory RAM, read-only memory ROM, multiple I / O ports and interrupt systems, timer / counter and other functions (may also include display drive circuit, pulse width modulation circuit, analog multiplexer, A / D converter and other circuits) on a silicon chip to form a small and complete microcomputer system. It is widely used in the field of industrial control. Since the 1980s, it has developed from the 4-bit and 8-bit single-chip microcomputers at that time to the current 300M high-speed single-chip microcomputers.
[0084] Beat is the unit of rhythm. Beat is the organizational form of fixed unit duration and strength in music, also known as beat. The cycle of strong beat and weak beat in each measure is called two beats; the cycle of strong beat, weak beat, weak beat is called three beats. The symbol that indicates the duration and number of basic unit beats in each measure is called time signature. The upper number of the time signature indicates the number of beats per measure, and the lower number indicates the duration of each beat. For example, 2 / 4, 4 / 4, 3 / 4, etc. In 2 / 4, 2 is the number of beats per measure, and 4 is the duration of each beat.
[0085] A musical scale is a form of mode. Its full name is modal scale. Arranging the notes in the mode in a step-like manner, from the beginning to the end of the tonic, from low to high (called ascending), or from high to low (called descending), is called a scale.
[0086] When a person is exercising, the six-axis inertial sensor 110 is used to collect the user's motion data, wherein the motion data includes three-axis acceleration data and three-axis angular velocity data. The tempo of the music is generated by the collected three-axis acceleration data, and then a preset number of whole seats are randomly generated as the rhythm of a preset number of measures. Then, the collected three-axis angular velocity data is read according to the generated rhythm, and then the acquired three-axis acceleration data is converted into a corresponding scale to generate a corresponding melody line. Then, a MIDI music is generated according to the generated melody line and the tempo of the music through the standard MIDI format, thereby combining the user's motion data with the generation of the music, and there is no need to store a large amount of music melody data, so that everyone can become a natural composer.
[0087] In some embodiments, the single chip microcomputer 120 is further used for:
[0088] Calculate the absolute value A(t) of the read three-axis acceleration data;
[0089] The calculated absolute value A(t) is transformed through Fourier discrete transformation to obtain the frequency domain data of the three-axis acceleration data A'(f)=DFT[A(t)];
[0090] The frequency f0 at which the peak value is located is obtained by fitting the frequency domain data A'(f) with a Gaussian function;
[0091] The tempo of the music is calculated based on the obtained frequency f0 as 60*f0 bpm.
[0092] The single-chip computer 120 continuously reads the three-axis acceleration data collected by the three-axis acceleration sensor within a preset time at a preset frequency, such as continuously reading the three-axis acceleration data collected for tens of seconds at a sampling rate of 10-100Hz, and then obtains the absolute value of the three-axis acceleration A(t) by the three-axis square sum; then the three-axis acceleration data in the frequency domain A'(f)=DFT[A(t)] is calculated by discrete Fourier transform, and then the frequency f0 of the peak value is obtained by fitting A'(f) with a Gaussian function, and then the beat speed of the music is obtained as 60*f0 bpm. bpm is the abbreviation of Beat Per Minute, and its Chinese name is beat number, which means the unit of beats per minute.
[0093] In some embodiments, the single chip microcomputer 120 is further used for:
[0094] Generate a preset number of positive integers, the positive integer is within a preset range, the preset number is a preset number of measures, the preset range is two to the power of m, and m is the number of beats in the preset beat * duration;
[0095] Convert the generated positive integer into a binary number, where the number of bits of the binary number is m;
[0096] The generated preset number of binary numbers constitutes the rhythm array of the music.
[0097] When the single-chip microcomputer 120 generates rhythm, the single-chip microcomputer 120 generates corresponding positive integers according to the preset beat and the preset number of measures. For example, when a 4 / 4 beat melody of N measures needs to be generated, the 4 / 4 beat is four-quarter beat, with a quarter note as one beat, four beats per measure, and the rule of strength is: strong---weak---second strong---weak; then N positive integers D1-DN within 65535 (2^16-1) are randomly generated, and then converted into 16-bit binary numbers; one bit of each binary number indicates whether the 16 sixteenth notes have scale changes. For example, the binary number 1000101011110001 means that the measure consists of a quarter note (1000), two eighth notes (1010), three sixteenth notes (111), a quarter note (1000), and a sixteenth note (1), in sequence. That is, the first digit of the binary number 1000101011110001 is 1, indicating that there is a scale change, and the last three digits 000 indicate a change, that is, 1000 represents a quarter note. Similarly, 10 represents an eighth note, so 1010 represents two eighth notes, and 111 represents three consecutive scale changes, that is, three sixteenth notes. Then 1000 represents a quarter note, and 1 represents a sixteenth note. The rhythm of the whole piece of music consists of a section consisting of N bars that repeats M times (M depends on the duration of the movement or the preset duration of the music). Usually N is between 2-8, and the 4 / 4 beat music is constructed into an array R[16*N*M] to correspond to the rhythm of the music. When generating a 2 / 4 beat composition, the randomly generated positive integer is within 255 (2^8-1), and if a 3 / 4 beat composition is used, the randomly generated positive integer is within 4095 (2^12-1).
[0098] In some embodiments, the single chip microcomputer 120 is further used for:
[0099] Establish a correspondence table between triaxial angular velocity data and natural scale;
[0100] Read the value of each bit in the binary system according to the preset beat time period to determine whether a new note needs to be generated;
[0101] If the value on the bit is 1, a new note is generated;
[0102] If the value on the digit is 0, the previous note continues;
[0103] When a new note is generated, the three-axis angular velocity data is read.
[0104] The notes corresponding to the three-axis angular velocity data are read and added to the corresponding melody line to generate a melody line including time points and notes.
[0105] Establish a natural syllable correspondence table of angular velocity. The single-chip microcomputer 120 reads the values of each bit in the binary of the rhythm array according to the time period of the preset beat to determine whether a new note needs to be generated. For example, if 60*f0 bpm is used as the beat speed of the music, the single-chip microcomputer 120 sets a timer interrupt, and triggers every 1 / 4f0 time. When the single-chip microcomputer 120 is triggered for the i-th time, it checks the value of R(i) from the rhythm array. If it is 1, it is determined that this trigger will generate a new note. Otherwise, the previous note is continued. If a new note needs to be generated, the single-chip microcomputer 120 reads the three-axis angular velocity data from the three-axis angular velocity, and obtains the absolute value G[i] of the angular velocity data through the sum of the three-axis squares. The note corresponding to the absolute value G[i] of the angular velocity data is obtained from the correspondence table between the three-axis angular velocity and the natural scale, and is added to the melody line, thereby generating a melody line containing time points and notes.
[0106] In some embodiments, the single chip microcomputer 120 is further used for:
[0107] Generate a MIDI file header of a MIDI music, and add the tempo of the music as a key parameter to the MIDI file header;
[0108] The generated melody line generates MIDI note switch messages according to the MIDI standard specification and is added to the MIDI file to form a MIDI music.
[0109] First, a MIDI file header is generated, and the tempo of the music is added as a key parameter to the MIDI file header; secondly, the melody line generates a MIDI note switch message according to the MIDI standard specification and adds it to the MIDI file. The entire MIDI music is completed. The MIDI music can be played through the MIDI sound source of the sports bracelet 100 or transmitted to a mobile phone or PC via Bluetooth to play or edit it using music software.
[0110] In some embodiments, the sports bracelet 100 is provided with a MIDI sound source, and when the single-chip microcomputer 120 generates a MIDI music, the generated MIDI music can be played through the MIDI sound source. In other embodiments, the sports bracelet 100 is provided with a Bluetooth module, which can be connected to a mobile terminal, such as a mobile phone, by Bluetooth. When the single-chip microcomputer 120 generates a MIDI music, it is sent to the mobile phone through the Bluetooth module, and the generated MIDI music is played through the mobile phone.
[0111] See also Figure 2-3 This embodiment provides a music generation method based on sports movements, which is applied to the sports bracelet 100 described in the above embodiment. The music generation method specifically includes the following steps:
[0112] Step S210: Motion data collection: collecting the user's motion data through a six-axis inertial sensor, the motion data including three-axis acceleration data and three-axis angular velocity data;
[0113] Step S220: generating music tempo: generating the tempo of the music according to the collected three-axis acceleration data;
[0114] Step S230: rhythm generation: randomly generating a preset number of integers as the rhythm of the preset number of measures;
[0115] Step S240: Melody generation: reading the collected three-axis angular velocity data according to the generated rhythm, converting the acquired three-axis angular velocity data into corresponding scales, and generating a corresponding melody line;
[0116] Step S250: Music generation: Generate MIDI music in a standard MIDI format according to the generated melody line and beat tempo.
[0117] An inertial sensor is a sensor that mainly detects and measures acceleration, tilt, shock, vibration, rotation, and multi-degree-of-freedom (DoF) motion. It is an important component for solving navigation, orientation, and motion carrier control. Inertial sensors include accelerometers (or acceleration sensors) and angular velocity sensors (gyroscopes). Six-axis inertial sensors include three-axis gyroscopes and three-axis acceleration sensors.
[0118] Meter is a unit of rhythm. In music, a series of beats with certain strengths and weaknesses are repeated at regular intervals. For example, 2 / 4, 4 / 4, 3 / 4, etc. Meter is an organizational form that represents a fixed unit of time and strength in music.
[0119] A musical scale is a form of mode. Its full name is modal scale. Arranging the notes in the mode in a step-like manner, from the beginning to the end of the tonic, from low to high (called ascending), or from high to low (called descending), is called a scale.
[0120] When a person is exercising, the six-axis inertial sensor is used to collect the user's motion data, wherein the motion data includes three-axis acceleration data and three-axis angular velocity data. The tempo of the music is generated through the collected three-axis acceleration data, and then a preset number of whole seats are randomly generated as the rhythm of the preset number of measures. Then, the collected three-axis angular velocity data is read according to the generated rhythm, and then the acquired three-axis acceleration data is converted into a corresponding scale to generate a corresponding melody line. Then, a MIDI music is generated according to the generated melody line and the tempo of the music through the standard MIDI format, thereby combining the user's motion data with the generation of the music, and there is no need to store a large amount of music melody data, so that everyone can become a natural composer.
[0121] See also Figure 4 In this embodiment, the music tempo generating step specifically includes the following steps:
[0122] Step S410: reading the three-axis acceleration data within a preset time at a preset frequency;
[0123] Step S420: Calculate the absolute value A(t) of the read three-axis acceleration data;
[0124] Step S430: The calculated absolute value A(t) is subjected to Fourier discrete transformation to obtain frequency domain data A'(f)=DFT[A(t)] of the three-axis acceleration data;
[0125] Step S440: Obtain the peak frequency f0 by performing Gaussian function fitting on the frequency domain data A'(f);
[0126] Step S450: Calculate the music tempo as 60*f0 bpm based on the obtained frequency f0.
[0127] The three-axis acceleration data collected by the three-axis acceleration sensor within a preset time is continuously read at a preset frequency, such as continuously reading the three-axis acceleration data collected for tens of seconds at a sampling rate of 10-100Hz, and then the absolute value of the three-axis acceleration A(t) is obtained by the three-axis square sum; then the three-axis acceleration data in the frequency domain A'(f)=DFT[A(t)] is calculated using discrete Fourier transform, and then the frequency f0 of the peak value is obtained by fitting A'(f) with a Gaussian function, and then the beat speed of the music is obtained as 60*f0 bpm. bpm is the abbreviation of Beat Per Minute, and its Chinese name is beat number, which means the unit of beats per minute.
[0128] See also Figure 5 In some embodiments, the rhythm generating step specifically includes the following steps:
[0129] Step S510: Generate a preset number of positive integers, the positive integer is within a preset range, the preset number is a preset number of measures, the preset range is two to the power of m - 1, m is the number of beats in the preset beat * duration;
[0130] Step S520: converting the generated positive integer into a binary number, wherein the number of bits of the binary number is m;
[0131] Step S530: The generated preset number of binary numbers constitutes a rhythm array of the music.
[0132] When generating a rhythm, a corresponding positive integer is generated according to a preset beat and a preset number of measures. For example, when a 4 / 4 beat melody of N measures needs to be generated, 4 / 4 beat is four-quarter beat, with a quarter note as one beat, four beats per measure, and a strong-weak rule: strong---weak---second strong---weak; then N positive integers D1-DN within 65535 (2^16-1) are randomly generated and then converted into 16-bit binary numbers; one bit of each binary number indicates whether the 16 sixteenth notes have a scale change. For example, the binary number 1000101011110001 means that the measure consists of a quarter note (1000), two eighth notes (1010), three sixteenth notes (111), a quarter note (1000), and a sixteenth note (1), in sequence. That is, the first digit of the binary number 1000101011110001 is 1, indicating that there is a scale change, and the last three digits 000 indicate a change, that is, 1000 represents a quarter note. Similarly, 10 represents an eighth note, so 1010 represents two eighth notes, and 111 represents three consecutive scale changes, that is, three sixteenth notes. Then 1000 represents a quarter note, and 1 represents a sixteenth note. The rhythm of the whole piece of music consists of a section consisting of N bars that repeats M times (M depends on the duration of the movement or the preset duration of the music). Usually N is between 2-8, and the 4 / 4 beat music is constructed into an array R[16*N*M] to correspond to the rhythm of the music. When generating a 2 / 4 beat composition, the randomly generated positive integer is within 255 (2^8-1), and if a 3 / 4 beat composition is used, the randomly generated positive integer is within 4095 (2^12-1).
[0133] See also Figure 6 In some embodiments, the melody generation step specifically includes the following steps:
[0134] Step S610: establishing a correspondence table between triaxial angular velocity data and natural scales;
[0135] Step S620: Read the value of each bit in the binary system according to the time period of the preset beat to determine whether a new note needs to be generated;
[0136] If the value on the bit is 1, then step S630: generate a new note;
[0137] If the value on the digit is 0, then step S640: continue the previous note;
[0138] When a new note is generated, step S650 is executed: read the three-axis angular velocity data,
[0139] Step S660: Read the notes corresponding to the three-axis angular velocity data, add them to the corresponding melody line, and generate a melody line including time points and notes.
[0140] Establish a natural syllable correspondence table of angular velocity, read the values of each bit in the binary of the rhythm array according to the preset beat time period to determine whether a new note needs to be generated. For example, if 60*f0 bpm is used as the beat speed of the music, the timer interrupt is set by the single-chip microcomputer, and it is triggered every 1 / 4f0 time. When the single-chip microcomputer is triggered for the i-th time, the value of R(i) is checked from the rhythm array. If it is 1, it is determined that this trigger will generate a new note. Otherwise, the previous note is continued. If a new note needs to be generated, the single-chip microcomputer reads the three-axis angular velocity data from the three-axis angular velocity, and obtains the absolute value G[i] of the angular velocity data through the square sum of the three axes. The note corresponding to the absolute value G[i] of the angular velocity data is obtained from the correspondence table between the three-axis angular velocity and the natural scale, and added to the melody line, thereby generating a melody line containing time points and notes.
[0141] In some embodiments, the music generation specifically includes the following steps:
[0142] Generate a MIDI file header of a MIDI music, and add the tempo of the music as a key parameter to the MIDI file header;
[0143] The generated melody line generates MIDI note switch messages according to the MIDI standard specification and is added to the MIDI file to form a MIDI music.
[0144] First, generate a MIDI file header and add the tempo of the music as a key parameter to the MIDI file header; secondly, generate MIDI note switch messages for the melody line according to the MIDI standard specification and add them to the MIDI file. This completes the entire MIDI music. The MIDI music can be played through the MIDI sound source of the sports bracelet or transmitted to a mobile phone or PC via Bluetooth to play or edit it using music software.
[0145] Finally, it should be noted that although the above embodiments have been described in the specification and drawings of this application, this does not limit the scope of patent protection of this application. All technical solutions generated by replacing or modifying equivalent structures or equivalent processes based on the essential concept of this application using the contents recorded in the specification and drawings of this application, as well as directly or indirectly implementing the technical solutions of the above embodiments in other related technical fields, are included in the scope of patent protection of this application.
Claims
1. A method for generating music based on sports movements, characterized in that: The following steps are involved: Motion data collection: The user's motion data is collected through a six-axis inertial sensor, and the motion data includes three-axis acceleration data and three-axis angular velocity data; Music tempo generation: Generate the tempo of the music based on the collected three-axis acceleration data; Rhythm generation: randomly generate a preset number of integers as the rhythm of a preset number of measures; Melody generation: read the collected three-axis angular velocity data according to the generated rhythm, convert the acquired three-axis angular velocity data into the corresponding scale, and generate the corresponding melody line; Music generation: Generate MIDI music in standard MIDI format based on the generated melody line and beat tempo.
2. The method for generating music based on sports actions according to claim 1, characterized in that: The music tempo generating step specifically comprises the following steps: Read the three-axis acceleration data within a preset time at a preset frequency; Calculate the absolute value A(t) of the three-axis acceleration data according to the sum of the three-axis squares; The calculated absolute value A(t) is transformed through Fourier discrete transformation to obtain the frequency domain data of the three-axis acceleration data A'(f)=DFT[A(t)]; The frequency f0 at which the peak value is located is obtained by fitting the frequency domain data A'(f) with a Gaussian function; The tempo of the music is calculated based on the obtained frequency f0 as 60*f0 bpm.
3. The method for generating music based on sports actions according to claim 1, characterized in that: The rhythm generation step specifically includes the following steps: Generate a preset number of positive integers, the positive integer is within a preset range, the preset number is a preset number of measures, the preset range is two to the power of m - 1, m is the number of beats in the preset beat * duration; Convert the generated positive integer into a binary number, where the number of bits of the binary number is m; The generated preset number of binary numbers constitutes the rhythm array of the music.
4. The method for generating music for sports actions according to claim 3, characterized in that: The melody generation step specifically includes the following steps Establish a correspondence table between triaxial angular velocity data and natural scale; Read the value of each bit in the binary system according to the preset beat time period to determine whether a new note needs to be generated; If the value on the bit is 1, a new note is generated; If the value on the digit is 0, the previous note continues; When a new note is generated, the three-axis angular velocity data is read. The notes corresponding to the three-axis angular velocity data are read and added to the corresponding melody line to generate a melody line including time points and notes.
5. The method for generating music based on sports actions according to claim 1, characterized in that: The music generation specifically comprises the following steps: Generate a MIDI file header of a MIDI music, and add the tempo of the music as a key parameter to the MIDI file header; The generated melody line generates MIDI note switch messages according to the MIDI standard specification and is added to the MIDI file to form a MIDI music.
6. A sports bracelet with music generation function, characterized in that: Including the bracelet body, single-chip microcomputer and six-axis inertial sensor; The six-axis inertial sensor and the single-chip microcomputer are arranged in the wristband body; The bracelet body is used to be worn on the user's hand; The six-axis inertial sensor is used to collect the user's motion data, and the motion data includes three-axis acceleration data and three-axis angular velocity data; The single-chip microcomputer is used to generate the beat speed of the music according to the collected three-axis acceleration data, randomly generate a preset number of integers as the rhythm of a preset number of measures, read the collected three-axis angular velocity data according to the generated rhythm, convert the acquired three-axis angular velocity data into a corresponding scale, and generate a corresponding melody line, and generate a MIDI music according to the generated melody line and beat speed through the standard MIDI format.
7. The sports bracelet with music generation function according to claim 6, characterized in that: The single chip microcomputer is also used for: Calculate the absolute value A(t) of the read three-axis acceleration data; The calculated absolute value A(t) is transformed through Fourier discrete transformation to obtain the frequency domain data of the three-axis acceleration data A'(f)=DFT[A(t)]; The frequency f0 at which the peak value is located is obtained by fitting the frequency domain data A'(f) with a Gaussian function; The tempo of the music is calculated based on the obtained frequency f0 as 60*f0 bpm.
8. The sports bracelet with music generation function according to claim 6, characterized in that: The single chip microcomputer is also used for: Generate a preset number of positive integers, the positive integer is within a preset range, the preset number is a preset number of measures, the preset range is two to the power of m - 1, m is the number of beats in the preset beat * duration; Convert the generated positive integer into a binary number, where the number of bits of the binary number is m; The generated preset number of binary numbers constitutes the rhythm array of the music.
9. The sports bracelet with music generation function according to claim 8, characterized in that: The single chip microcomputer is also used for: Establish a correspondence table between triaxial angular velocity data and natural scale; Read the value of each bit in the binary system according to the preset beat time period to determine whether a new note needs to be generated; If the value on the bit is 1, a new note is generated; If the value on the digit is 0, the previous note continues; When a new note is generated, the three-axis angular velocity data is read. The notes corresponding to the three-axis angular velocity data are read and added to the corresponding melody line to generate a melody line including time points and notes.
10. The sports bracelet with music generation function according to claim 6, characterized in that: The single chip microcomputer is also used for: Generate a MIDI file header of a MIDI music, and add the tempo of the music as a key parameter to the MIDI file header; The generated melody line generates MIDI note switch messages according to the MIDI standard specification and is added to the MIDI file to form a MIDI music.
Citation Information
Patent Citations
Method of automatic recognition of music melody key signatures
CN103035253A
Motion-sensing music wearable device and playing motion recognition method thereof
CN105867656A