Method for Mobile Client to Control Bluetooth Lamp to Flash Consistently Following Music Frequency

By using ffmpeg and fast Fourier transform technology, music frequency information is obtained and processed, and brightness values ​​are calculated and sent to control the flashing of Bluetooth lights, the problem of poor control of Bluetooth lights by existing mobile clients is solved, and the consistency between music frequency and Bluetooth lights is achieved.

CN115002990BActive Publication Date: 2025-06-17SHENZHEN XINZHONGXIN TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210626892.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-06
Publication Date
2025-06-17
Estimated Expiration
2042-06-06

AI Technical Summary

Technical Problem

When existing mobile clients control Bluetooth lights, the flashing effects are inconsistent due to the different music information provided by Android and Apple systems. The fragmentation problem of Android system makes it impossible to extract music frequency information, and the flashing of Bluetooth lights cannot be controlled.

Method used

The pcm information of music is obtained through ffmpeg, the frequency information of music is obtained using fast Fourier transform, the decibel value of the frequency in the selected range is calculated, and the decibel value is converted into brightness value after smoothing, and sent to the Bluetooth light through BLE or SPP protocol to control its flashing.

Benefits of technology

The mobile client controls the flash consistency of the Bluetooth light following the music frequency, solves the problem of inconsistent flickering caused by different systems, and avoids the problem of uncontrollable flashing of Bluetooth lights caused by Android system modifications, and improves the control effect of Bluetooth lights.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115002990B_ABST
    Figure CN115002990B_ABST
Patent Text Reader

Abstract

The present invention provides a method for a mobile client to control the consistent flashing of a Bluetooth lamp following the music frequency, including the following steps: S1. Obtain the PCM information of the music through ffmpeg; S2. Obtain the frequency information of the music through fast Fourier transform; S3. Calculate the decibel value of the frequency within the selected range; S4. Smooth the decibel value; S5. Convert the smoothed decibel value into a brightness value and send it to the Bluetooth lamp to control the flashing of the Bluetooth lamp; which solves the problem of different Bluetooth lamp control effects caused by different mobile client systems, and at the same time avoids the problem of inability to control the Bluetooth lamp flashing caused by the modification of the Android system, effectively improving the control effect of the Bluetooth lamp.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Bluetooth lamp control, and particularly to a method for a mobile client to control the consistency of Bluetooth lamp flashing following the music frequency. Background Art

[0002] The Bluetooth lamp establishes a connection with the mobile client through Bluetooth. When the mobile client plays music, it can extract the music frequency and control the flashing of the Bluetooth lamp through Bluetooth, bringing a visual enjoyment to the user.

[0003] Currently, the mobile client is generally an Android APP and an Apple APP. The Android APP and the Apple APP respectively calculate the brightness value for controlling the Bluetooth lamp flashing independently by using their own methods based on the interfaces provided by the system for obtaining music information. Since the music information provided by the Android system and the Apple system is different, such as the Android system provides the frequency information of the music, and the Apple system provides the amplitude information of the music, the calculation methods used are also different. This results in that the brightness values calculated by the same piece of music through the Android APP and the Apple APP at the same moment are not necessarily the same, causing inconsistent flashing effects of the Bluetooth lamp. Moreover, due to the serious fragmentation of the Android system, each manufacturer has made modifications, and it is not certain that the music frequency information can be extracted through the system method, resulting in the inability to calculate the brightness value, making the Android APP unable to control the flashing of the Bluetooth lamp.

[0004] Therefore, there is an urgent need for a method for a mobile client to control the consistency of Bluetooth lamp flashing following the music frequency, which can solve the problem of poor control effect of the existing mobile client on the Bluetooth lamp. Summary of the Invention

[0005] The purpose of the present invention is to provide a method for a mobile client to control the consistency of Bluetooth lamp flashing following the music frequency, so as to solve the problem of poor control effect of the existing mobile client on the Bluetooth lamp.

[0006] To achieve the above purpose, the present invention provides the following solutions:

[0007] The present invention provides a method for a mobile client to control the consistency of Bluetooth lamp flashing following the music frequency, including the following steps:

[0008] S1. Obtain the pcm information of the music through ffmpeg;

[0009] S2. Obtain the frequency information of the music through fast Fourier transform;

[0010] S3. Calculate the decibel value of the frequency within the selected range;

[0011] S4. Smooth the decibel value;

[0012] S5. Convert the smoothed decibel value into a brightness value and send it to the Bluetooth lamp to control the blinking of the Bluetooth lamp.

[0013] Preferably, step S1 is specifically as follows: Call the ffmpeg method to read the music file, and according to different encapsulation formats, use different decoders to decode the music file to obtain the original sampling rate fs, number of channels, pcm bit length, and pcm data of the music.

[0014] Preferably, step S2 is specifically as follows: Take 128 pcm data every 100 milliseconds, obtain frequency information through fast Fourier transform, and according to the characteristics of Fourier transform, calculate and return half of the size of the frequency points, and the calculated frequency information result is a 64-byte array.

[0015] Preferably, step S3 is specifically as follows: Calculate the decibel value within a certain range of frequency information according to the selected music effect, and the decibel value db = 20log 10 A, where A is the cumulative amplitude obtained by accumulating the moduli of the frequency points within the range of the minimum frequency f min and the maximum frequency f max in.

[0016] Preferably, in step S5, the brightness value is transmitted through BLE or SPP.

[0017] The present invention has achieved the following beneficial technical effects compared with the prior art:

[0018] A method for a mobile client to control the blinking consistency of a Bluetooth lamp following the music frequency provided by the present invention includes the following steps: S1. Obtain the pcm information of the music through ffmpeg; S2. Obtain the frequency information of the music through fast Fourier transform; S3. Calculate the decibel value of the selected frequency range; S4. Smooth the decibel value; S5. Convert the smoothed decibel value into a brightness value and send it to the Bluetooth lamp to control the blinking of the Bluetooth lamp; It solves the problem that the control effect of the Bluetooth lamp is different due to different mobile client systems, and at the same time avoids the problem that the Bluetooth lamp cannot be controlled to blink due to the modification of the Android system, effectively improving the control effect of the Bluetooth lamp. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0020] Figure 1Flow chart of the method for the mobile client to control the Bluetooth lamp to blink consistently following the music frequency provided by the present invention; Detailed implementation mode

[0021] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0022] The purpose of the present invention is to provide a method for the mobile client to control the Bluetooth lamp to blink consistently following the music frequency, so as to solve the problem of poor control effect of the existing mobile client on the Bluetooth lamp.

[0023] To make the above objects, features and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below in conjunction with the drawings and specific implementation modes.

[0024] Embodiment 1:

[0025] This embodiment provides a method for the mobile client to control the Bluetooth lamp to blink consistently following the music frequency. As Figure 1 shown, it includes the following steps:

[0026] S1. Obtain the pcm information of the music through ffmpeg;

[0027] Call the ffmpeg method, read the music file, and according to different encapsulation formats, use different decoders to decode the music file to obtain the original sampling rate fs, the number of channels, the pcm bit length, the pcm data, etc. of the music, and separate the pcm data of one channel (such as the left channel) for calculation;

[0028] S2. Obtain the frequency information of the music through the fast Fourier transform;

[0029] At intervals of 100 milliseconds, take 128 pcm data, and obtain the frequency information through the fast Fourier transform. According to the characteristics of the Fourier transform, when all the inputs are real numbers, the output result satisfies conjugate symmetry, so calculate and return half the size of the frequency points.

[0030] The calculated frequency information result is a 64-byte array;

[0031] Among them, byte0 is the value of DC (direct current component),

[0032] byte1 is the value of the fs / 2 frequency,

[0033] byte2 is the real part value of the first frequency point,

[0034] byte3 is the imaginary part value of the first frequency point,

[0035] byte4 is the real part value of the second frequency point,

[0036] byte5 is the imaginary part value of the second frequency point,

[0037] ......And so on,

[0038] byte124 is the real part value of the 62nd frequency point,

[0039] byte125 is the imaginary part value of the 62nd frequency point,

[0040] byte126 is the real part value of the 63rd frequency point,

[0041] byte127 is the imaginary part value of the 63rd frequency point;

[0042] If the real part and the imaginary part corresponding to the output of one frequency are re and im, its modulus

[0043] Perform normalization processing on the modulus, and the normalized modulus N = M / 255;

[0044] S3. Calculate the decibel value of the frequency within the selected range;

[0045] Through S2, the music frequency information from 0 to fs / 2 has been calculated. At this time, according to the music effect selected by the user, such as rock or brisk, etc., select the frequency information within a certain range for calculation. Assume that the selected minimum frequency is f min , and the selected maximum frequency is f max , and accumulate the moduli of the frequency points within the frequency range of f min and f max in S102 to obtain the cumulative amplitude A;

[0046] Decibel db = 20log 10 A;

[0047] S4. Smooth the decibel value;

[0048] Smooth the decibel value to make the flicker effect softer, remove the abrupt jumps, and achieve a better visual effect;

[0049] The formula adopted is as follows: Y i =(1 / 35)(-3Y i-2 +12Y i-1 +17Y i +12Y i+1 -3Yi+2 )

[0050] S5. Convert the smoothed decibel value into a brightness value and then send it to the Bluetooth lamp to control the blinking of the Bluetooth lamp;

[0051] Use the following formula to convert the decibel value smoothed in S104 into a brightness value;

[0052] smoothdb represents the decibel value smoothed in S4, and brightness represents the brightness value;

[0053]

[0054]

[0055] The converted brightness value is transmitted to the Bluetooth lamp through BLE (Bluetooth Low Energy) or SPP (Bluetooth Serial Port Profile) to control the blinking of the lamp.

[0056] The present invention uses specific examples to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.

Claims

1. A method for a mobile client to control the consistent flashing of a Bluetooth light following the music frequency, characterized in that: It includes the following steps: S1. Obtain the PCM information of the music through ffmpeg. Specifically: Call the ffmpeg method to read the music file. According to different encapsulation formats, use different decoders to decode the music file to obtain the original sampling rate fs, the number of channels, the PCM bit length, and the PCM data of the music. S2. Obtain the frequency information of the music through the fast Fourier transform. Specifically: Take 128 PCM data at intervals of 100 milliseconds, and obtain the frequency information through the fast Fourier transform. According to the characteristics of the Fourier transform, when all inputs are real numbers, the output result satisfies conjugate symmetry. Calculate and return half of the size of the frequency points. The calculated frequency information result is a 64-byte array. The 64-byte array includes the real part value and the imaginary part value of the frequency points. The real part value and imaginary part value corresponding to the output of a frequency point are re and im, and its modulus M = ; perform normalization processing on the modulus, and the normalized modulus N = M / 255; S3. Calculate the decibel value of the frequency within the selected range. Specifically: Calculate the decibel value according to the frequency information within a certain range selected according to the music effect selected by the user. The decibel value db = 20log10A, where A is the cumulative amplitude obtained by accumulating the modulus of the frequency points within the minimum frequency fmin and the maximum frequency fmax in the frequency range. S4. Smooth the decibel value. S5. Convert the smoothed decibel value into a brightness value and send it to the Bluetooth lamp to control the blinking of the Bluetooth lamp.

2. The method for a mobile client to control the consistent flashing of a Bluetooth light following the music frequency according to claim 1, characterized in that: In step S5, the brightness value is transmitted through BLE or SPP.

Citation Information

Patent Citations

  • Method for controlling light brightness and color height matching change through sound change

    CN114466495A