LED light bar rhythm control method based on audio frequency spectrum analysis

The LED light strip rhythm control method based on audio spectrum analysis solves the problems of weak correlation between light response and music rhythm and insufficient natural dynamic aesthetics in existing technologies, and realizes the natural mapping of light and music emotions and visual smoothness.

CN122069618APending Publication Date: 2026-05-19SHENZHEN RELIGHT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN RELIGHT TECH CO LTD
Filing Date
2026-04-14
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

Existing LED light strip music rhythm control technology cannot adapt to music content with different dynamic ranges. The light response has a weak correlation with the music rhythm, lacks natural dynamic aesthetics, and the color mapping rules are simple and fixed, failing to effectively reflect the emotions of the music.

Method used

An audio spectrum analysis-based method is used to collect audio signals through a microphone, divide them into multiple short-time audio frames, perform windowing and normalization processing, and then perform a fast Fourier transform. The Barker scale is used to divide non-uniform frequency bands, calculate the frequency band energy and transient enhancement factor, and generate LED control commands to control the brightness and color of the lights.

Benefits of technology

It achieves a lighting response that better matches human auditory perception, sensitively captures rhythmic impacts and adaptively enhances brightness according to transient intensity, resulting in layered lighting performance, natural emotions, elimination of flickering, and improved visual smoothness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122069618A_ABST
    Figure CN122069618A_ABST
Patent Text Reader

Abstract

The invention discloses an LED light bar rhythm control method based on audio frequency spectrum analysis, and relates to the technical field of LED light rhythm control, and the method comprises the steps: 1, collecting an original audio signal through a microphone at a preset sampling frequency, dividing the original audio signal into a plurality of short-time audio frames with a preset frame length, performing windowing processing, normalization processing and fast Fourier transform on each short-time audio frame in sequence to obtain an amplitude spectrum corresponding to each short-time audio frame; by adopting the non-uniform frequency band division based on the barker scale, the light response is more in line with the auditory perception of human ears; half-wave rectification spectrum flux is combined with an adaptive threshold to realize high-precision transient detection, rhythm impact such as drumbeat can be sensitively captured, and light brightness can be adaptively enhanced according to transient intensity; through spatial mapping of one-to-one correspondence of frequency bands and light bar areas and color distribution of low-frequency warm colors and high-frequency cold colors, light expression is more layered.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of LED light rhythm control technology, specifically an LED light strip rhythm control method based on audio spectrum analysis. Background Technology

[0002] With the rapid development of smart home and ambient lighting technologies, LED light strip music rhythm control has become an important means to enhance entertainment experiences and environmental ambiance, and is widely used in home theaters, bars, stage performances, game rooms, and other scenarios. Existing LED light strip music rhythm control technologies mainly include the following types of solutions: The first type is a simple threshold control scheme based on single-frequency energy. This scheme collects audio signals and extracts the energy value of a single frequency band. When the energy value exceeds a fixed threshold, it triggers a change in LED brightness. However, this scheme has the drawback that the fixed threshold cannot adapt to music content with different dynamic ranges. The light may have no response at all during quiet passages, and may remain saturated during intense passages. Furthermore, single-frequency information cannot reflect the rich frequency layers of music, resulting in a weak correlation between the light response and the music rhythm. The second type is a beat recognition control scheme based on deep learning. This scheme trains a neural network model to recognize music beats and emotions. The first type is a multi-channel control scheme based on fixed frequency spectrum segmentation. This scheme divides the audio spectrum into several frequency bands according to fixed boundaries, and each frequency band independently controls the corresponding LED area. However, the fixed frequency division boundary adopts a linear uniform division method, which does not take into account the nonlinear characteristics of the human auditory system's ability to distinguish different frequencies of sound. This results in the low frequency band being divided too coarsely and the high frequency band being divided too finely, which does not match the actual perception of the human ear. At the same time, each frequency band is independent and lacks overall coordination, and the light changes are abrupt and lack a natural sense of transition.

[0003] The lack of an effective detection mechanism for audio transient features makes it impossible to distinguish between steady-state continuous tones and transient impact tones, resulting in the lights failing to respond sensitively to rhythmic impacts such as drumbeats and percussion. Light brightness changes directly follow energy values, lacking physical inertia simulation and smooth transition processing, leading to overly mechanical and rigid light responses with noticeable flickering and a lack of natural dynamic aesthetics. Furthermore, the color mapping rules are simple and fixed, failing to establish an intuitive connection between frequency characteristics and color perception, resulting in insufficient correlation between color changes and musical mood. Based on these shortcomings, an LED light strip rhythm control method based on audio spectrum analysis is proposed. Summary of the Invention

[0004] The purpose of this invention is to provide an LED light bar rhythm control method based on audio spectrum analysis to solve the problems mentioned in the background art.

[0005] An LED light strip rhythm control method based on audio spectrum analysis includes: Step 1: Acquire the original audio signal through the microphone at a preset sampling frequency, divide the original audio signal into multiple short audio frames with a preset frame length, and perform windowing, normalization and fast Fourier transform on each short audio frame in sequence to obtain the amplitude spectrum corresponding to each short audio frame. Step 2: Divide the amplitude spectrum of each short-time audio frame into multiple non-uniform frequency bands according to the Buck scale, and calculate the energy value of each frequency band; Step 3: Calculate the spectral flux between the amplitude spectra of two adjacent short-time audio frames, determine whether each short-time audio frame is a transient frame based on the comparison result of the spectral flux and the adaptive threshold, and calculate the transient enhancement factor of each short-time audio frame. Step 4: Divide the LED light strip into multiple control areas that correspond one-to-one with the frequency band. Calculate the brightness value and color parameters of each control area based on the frequency band energy value and transient enhancement factor of each short-time audio frame, generate LED control commands, and output them to the LED light strip driver module.

[0006] As a further aspect of the present invention: the specific method for dividing the original audio signal into multiple short-time audio frames is as follows: The sampling frequency is set to 44,100 samples per second, and each short audio frame contains 1,024 samples, with a duration of approximately 23 milliseconds. A 50% overlap rate is set between two adjacent short audio frames, meaning that the next frame is captured starting from the 512th sample point of the current frame.

[0007] As a further aspect of the present invention, the specific method for obtaining the amplitude spectrum corresponding to each short-time audio frame is as follows: For a sample point with index n in a short audio frame, where n ranges from 0 to 1023, the Hanning window function value for this sample point is equal to 0.5 multiplied by 1 minus the cosine value. The cosine value is calculated by multiplying 2 by pi, then by n, and finally dividing by 1023. The original sample value of each sample point is multiplied by the corresponding Hanning window function value to obtain the windowed sample value. All windowed sample points are iterated through to find the maximum absolute value, denoted as Amax. The minimum effective amplitude threshold Amin is set to 0.001. When Amax is less than or equal to Amin, the frame is determined to be a silent frame. When Amax is greater than Amin, each windowed sample value is divided by Amax to obtain a normalized sample value. A fast Fourier transform is performed on the normalized short audio frame and the first 513 frequency points are retained. For the m-th frequency point, its amplitude value is equal to the square root of the sum of the square of the real part and the square of the imaginary part of the complex result of that frequency point. The actual frequency corresponding to the m-th frequency point is equal to m multiplied by 44100 and then divided by 1024.

[0008] As a further aspect of the present invention: the specific method for dividing the amplitude spectrum of each short-time audio frame into multiple non-uniform frequency bands according to the Buck scale is as follows: The amplitude spectrum of each short-time audio frame is divided into 8 non-uniform frequency bands according to the Barker scale. For a given linear frequency value f, the corresponding Barker scale frequency value b is calculated as follows: First, calculate 0.00076 multiplied by f, take the arctangent of this result, and multiply by 13 to obtain the first term. Then, calculate f divided by 7500, square this result, take the arctangent, and multiply by 3.5 to obtain the second term. Finally, add the two terms together to obtain the Barker scale frequency value b. The 8 non-uniform frequency bands... The corresponding linear frequency ranges are as follows: Band 0 is 20 Hz to 300 Hz, Band 1 is 300 Hz to 700 Hz, Band 2 is 700 Hz to 1200 Hz, Band 3 is 1200 Hz to 1900 Hz, Band 4 is 1900 Hz to 2800 Hz, Band 5 is 2800 Hz to 4200 Hz, Band 6 is 4200 Hz to 6500 Hz, and Band 7 is 6500 Hz to 12000 Hz.

[0009] As a further aspect of the present invention, the specific method for calculating the energy value of each frequency band is as follows: For a single frequency band, firstly, determine the corresponding start and end frequency indexes based on the linear frequency boundaries of the band. The frequency index corresponding to the linear frequency f is equal to f multiplied by 1024, divided by 44100, and rounded to the nearest integer. Then, traverse all frequency points within the band, square the amplitude value of each frequency point, and sum them up to obtain the original energy value of the band. Finally, divide the original energy value by the number of frequency points contained in the band to obtain the normalized energy value of the band.

[0010] As a further aspect of the present invention, the specific method for calculating the spectral flux between the amplitude spectra of two adjacent short-time audio frames is as follows: For the first short-time audio frame, the transient detection flag is set to 0, and the transient enhancement factor is set to 1.0. After processing, the amplitude spectrum of the first frame is saved as a reference amplitude spectrum for use in calculating the spectral flux of the second frame. Starting from the second frame, the amplitude values ​​of each frequency point are compared one by one with the amplitude spectrum of the current short-time audio frame and the amplitude spectrum of the previous short-time audio frame. For each frequency point, the difference between the amplitude value of the current frame and the amplitude value of the previous frame is calculated. If the difference is positive, the difference is retained; if the difference is negative or zero, the difference is set to zero. The differences after processing all frequency points are summed to obtain the original spectral flux. The original spectral flux is divided by the sum of the amplitude values ​​of all frequency points in the amplitude spectrum of the current frame and then 0.0001 is added to obtain the normalized spectral flux.

[0011] As a further aspect of the present invention, the specific method for calculating the transient enhancement factor of each short-time audio frame is as follows: If the normalized spectral flux is greater than the threshold, the current frame is determined to be a transient frame. First, the over-threshold ratio is calculated. The over-threshold ratio is equal to the difference between the normalized spectral flux and the threshold, divided by the threshold. Then, the over-threshold ratio is multiplied by the enhancement factor 2.0 and added to the base value 1.0 to obtain the transient enhancement factor. If the normalized spectral flux is less than or equal to the threshold, the current frame is determined to be a steady frame, and the transient enhancement factor is set to 1.0. The adaptive threshold and transient enhancement factor are calculated as follows: a sliding window is maintained to store the normalized spectral flux values ​​of the most recent 50 consecutive frames. When the sliding window stores less than 50 values, a fixed threshold of 0.08 is used. When the sliding window has stored 50 values, the mean and standard deviation of the normalized spectral flux values ​​in the window are calculated. The adaptive threshold is equal to the mean plus 1.5 times the standard deviation.

[0012] As a further aspect of the present invention: the specific method for calculating the brightness value of each control region based on the frequency band energy value and transient enhancement factor of each short-time audio frame is as follows: The LED light strip is divided into 8 control areas, each corresponding to one of the 8 frequency bands. For the i-th control area, where i ranges from 0 to 7, the base brightness value of the control area is equal to the energy value of the i-th frequency band of the frame multiplied by the brightness coefficient 255. Then, the base brightness value is multiplied by the transient enhancement factor of the i-th frequency band of the frame to obtain the enhanced brightness value. The enhanced brightness value is then limited to the range of 0 to 255 to obtain the final brightness value of the control area.

[0013] As a further aspect of the present invention, the specific method for calculating the color parameters of each control region is as follows: A fixed base hue is assigned according to the frequency band number. The hue values ​​corresponding to frequency bands 0 to 7 are 0 degrees, 30 degrees, 60 degrees, 120 degrees, 180 degrees, 210 degrees, 240 degrees, and 280 degrees, respectively. This makes the low-frequency region of frequency bands 0 to 2 present warm colors of red, orange, and yellow, the high-frequency region of frequency bands 5 to 7 present cool colors of blue, indigo, and purple, and the mid-frequency region of frequency bands 3 and 4 present transitional colors of green and cyan. The saturation is uniformly set to 0.8.

[0014] As a further aspect of the present invention, the specific method for generating LED control commands and outputting them to the LED strip driver module is as follows: For each control area, the red channel value, green channel value, and blue channel value are calculated according to the hue value, saturation value, and smooth brightness value of the control area, using the HSV to RGB conversion formula. The RGB values ​​of all LEDs in the control area are set to the same value, and the RGB values ​​of all LEDs are arranged sequentially according to their LED numbers to form a control data sequence. The control data sequence is then encapsulated according to the LED driving protocol and sent to the LED strip driver module via a serial port or SPI interface.

[0015] Compared with the prior art, the beneficial effects of the present invention are: This invention employs a non-uniform frequency band division based on the Buck scale to make the light response more consistent with human auditory perception; it utilizes half-wave rectified spectral flux combined with adaptive thresholding to achieve high-precision transient detection, which can sensitively capture rhythmic impacts such as drumbeats and adaptively enhance light brightness according to transient intensity; through spatial mapping of frequency bands and light strip areas in a one-to-one correspondence, and color allocation of low-frequency warm colors and high-frequency cool colors, the light performance is more layered and the mood is more natural; and exponential smoothing filtering is used to effectively eliminate flicker and improve visual smoothness. Attached Figure Description

[0016] Figure 1 This is a schematic diagram of the method framework structure of the present invention. Detailed Implementation

[0017] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0018] Example 1: Please refer to Figure 1 This application provides a method for rhythmic control of LED light strips based on audio spectrum analysis, including the following steps: Step 1: Continuous voltage signals are acquired via microphone in chronological order at a preset sampling frequency as the raw audio signal. This raw audio signal is divided into multiple short audio frames with preset frame lengths. Each short audio frame is then windowed and normalized, followed by a Fast Fourier Transform (FFT) to obtain a corresponding amplitude spectrum for each short audio frame, along with the actual frequency values ​​corresponding to different frequency points within each spectrum. This prepares the data for subsequent extraction of frequency band energy and features from each short audio frame. Each amplitude spectrum contains amplitude values ​​at 513 frequency points, each a non-negative real number reflecting the intensity of the corresponding frequency component within that short audio frame. The frequency range corresponding to these 513 frequency points is from 0 Hz to 22050 Hz, with a frequency resolution of approximately 43 Hz. Here, the sampling frequency fs is 44100 sampling points per second, meaning 44100 voltage values ​​are acquired per second. The original audio signal is divided into multiple short-time audio signals with a preset frame length, and there is a 50% overlap between any two adjacent short-time frames. That is, the next frame starts from the 512th sample point of the current frame. The purpose of this is to ensure that a sufficiently long period of audio information can be analyzed. Each short-time frame contains 1024 sample points, that is, the preset frame length is 1024 sample points, and the duration is 23 milliseconds. There is an overlap between adjacent frames, with an overlap rate of 50%. Specifically, the first frame contains the 0th to the 1023rd sample points of the original audio signal, the second frame contains the 512th to the 1535th sample points of the original audio signal, the third frame contains the 1024th to the 2047th sample points of the original audio signal, and so on. The purpose of setting 50% overlap is to ensure that a sufficiently long period of audio information can be analyzed while maintaining the continuity between adjacent frames and reducing information loss caused by frame division. Frame-by-frame processing divides continuous audio signals into segments of data that are easy to analyze independently, while a 50% overlap rate can balance the continuity of time-domain analysis with computational efficiency. For each frame of short-time audio signal that has been divided into frames, windowing is performed. Specifically, the index of each sampling point in each frame of short-time audio signal is multiplied by a Hanning window function W(n) to obtain the windowed sample value of each sampling point in each frame of short-time audio signal. The specific calculation method of the Hanning window function value is as follows: For the sampling point with index n in the short-time audio frame, where the value of n ranges from 0 to 1023, first calculate the angle parameter of the sampling point. The angle parameter is equal to 2 multiplied by pi (3.14159) and then multiplied by the sampling point index n, and then divided by the frame length minus 1, which is 1023; then calculate the cosine value of the angle parameter; finally, subtract the cosine value from 1 and multiply by 0.5 to obtain the Hanning window function value of the sampling point position. The Hanning window function is characterized by taking a value close to 1 at the center of each frame of short-time audio signal and a value close to 0 at the ends of the frame. This allows the signal amplitude at the frame boundaries to smoothly transition to zero, eliminating boundary jumps. Specifically, the Hanning window function is calculated as W(n) = 0.5 × {1 - cos[2 × π × n / (N - 1)]}, where n is the index of each sampling point in each frame of short-time audio signal, ranging from 0 to 1023; N is the frame length in each frame of short-time audio signal, i.e., the number of sampling points in each frame, 1024; and π is pi, which is 3.14159 in this case. When the sampling point index n equals 0, the angle parameter equals 2 multiplied by 3.14159 multiplied by 0 divided by 1023, resulting in 0; taking the cosine of 0 gives 1; subtracting 1 from 1 gives 0, and multiplying by 0.5 results in a Hanning window function value of 0. When the sampling point index n equals 512, the angle parameter equals 2 multiplied by 3.14159 multiplied by 512 divided by 1023, resulting in approximately 3.14159, which is pi; taking the cosine of pi gives -1; subtracting -1 from 1 gives 2, and multiplying by 0.5 results in a Hanning window function value of 1. When the sampling point index n equals 1023, the angle parameter equals 2 multiplied by 3.14159 multiplied by 1023 divided by 1023, the result is approximately 6.28318, which is twice pi. Taking the cosine of twice pi gives 1. Subtracting 1 from 1 gives 0, and multiplying by 0.5 gives a Hanning window function value of 0. It can be seen that the Hanning window function takes a value of 0 at both ends of the short audio frame, i.e., at index 0 and index 1023, and a value close to 1 in the middle of the frame, i.e., near index 512, forming a smooth bell-shaped curve overall.

[0019] Multiplying by the Hanning window function can reduce spectral leakage during subsequent frequency domain analysis. Spectral leakage can cause false high-frequency components to appear in the frequency domain. The Hanning window function has a narrow main lobe and low side lobes in the frequency domain, which concentrates the signal's energy at the frequency corresponding to the main lobe, thus allowing for more accurate analysis of the signal's frequency components.

[0020] For each short audio frame, the windowed sample values ​​of all sampling points are normalized. Specifically, for a single short audio frame, the process is as follows: First, iterate through all 1024 windowed sampling points of the short audio frame, taking the absolute value of each sampling point and finding the maximum value among all absolute values. This maximum value is recorded as the maximum amplitude Amax. Then, a minimum effective amplitude threshold Amin is set to 0.001 to determine whether the short audio frame is a silent frame. Next, the maximum amplitude Amax is compared with the minimum effective amplitude threshold Amin. If the maximum amplitude Amax is less than or equal to Amin, it indicates that the signal amplitude of the current short audio frame is extremely small, possibly indicating a silent segment or background noise. This frame is then classified as an invalid silent frame, and all output values ​​of this frame are set to zero in subsequent processing, not participating in subsequent frequency band energy calculations and lighting control.

[0021] If the maximum amplitude Amax is greater than Amin, it indicates that the current short audio frame contains a valid audio signal. Normalization is then performed on each sample point in that frame. The specific method for normalization is: divide the windowed sample value of each sample point by the maximum amplitude Amax to obtain the normalized sample value for that sample point. After normalization, the range of sample values ​​for all sample points in the short audio frame is compressed to between -1 and +1. The same normalization process is performed on each short audio frame to obtain the windowed and normalized sample values ​​for all sample points in each short audio frame. The purpose of normalization is to eliminate the influence of the overall volume difference of audio signals at different times, so that the subsequent spectrum analysis results are comparable. Perform a fast Fourier transform on each short audio frame after normalization to convert the time-domain signal into a frequency-domain signal, and obtain the amplitude spectrum corresponding to each short audio frame. For a single short audio frame (1024 sampling points), after performing a Fast Fourier Transform (FFT), each sampling point yields a corresponding complex number. This complex number contains real and imaginary components, each corresponding to a specific frequency point. Since the input signal is a real signal, according to the symmetry of the Fourier Transform for real signals, the latter half of the transform result is a conjugate symmetric repetition of the first half. Therefore, by retaining only the first 513 frequency points of the transform result, the complete frequency information of the short audio frame can be obtained. These 513 frequency points correspond to a frequency range from 0 Hz to 22050 Hz, covering the audible frequency range. Next, the amplitude value of each frequency point in the short audio frame is calculated, forming the amplitude spectrum of the short audio frame. The amplitude value is calculated as follows: For the m-th frequency point of the short audio frame, where m ranges from 0 to 512, let the real part of the complex number corresponding to this frequency point be Re and the imaginary part be Im. Then, the amplitude value of this frequency point is equal to the square root of the sum of the squares of the real and imaginary parts. The specific calculation steps are: first calculate the square of the real part Re, then calculate the square of the imaginary part Im, add the two squared values, and finally take the square root of the sum to obtain the amplitude value of this frequency point. Each frequency point in the amplitude spectrum corresponds to a specific actual frequency value. The actual frequency corresponding to the m-th frequency point is calculated as follows: multiply the frequency index m by the sampling frequency 44100, then divide by the frame length 1024 and take the integer part to obtain the frequency value corresponding to the frequency point, in Hertz. For example, the actual frequency corresponding to a frequency index m equal to 10 is 10 multiplied by 44100 divided by 1024, which is approximately 430.7 Hz. The frequency resolution is the frequency interval between two adjacent frequency points, which is equal to the sampling frequency 44100 divided by the frame length 1024, that is, 44100 divided by 1024 is approximately 43.07 Hz. This means that the spectrum analysis of this invention can distinguish two frequency components that differ by more than 43 Hz; obtain the amplitude spectrum corresponding to the short audio frame, and the actual frequency corresponding to each frequency point in the amplitude spectrum; perform the same processing on each short audio frame, and then obtain the amplitude spectrum corresponding to each short audio frame and the actual frequency value corresponding to each frequency point in the amplitude spectrum; Let's illustrate this with an example: Using a specific short audio frame as an example, let's describe the complete processing steps: Assume it's the first short audio frame, containing sample points 0 to 1023, totaling 1024 sample values. First, windowing is performed. Assume the original sample value of the 512th sample point is 0.8, and the Hanning window function value at that position is 1.0. After windowing, the sample value of that point is 0.8 multiplied by 1.0, which equals 0.8. Assume the original sample value of the 0th sample point is 0.3, and the Hanning window function value at that position is 0. After windowing, the sample value of that point is 0.3 multiplied by 0, which equals 0. Next, normalization is performed. Iterating through all 1024 windowed sample values ​​of the frame, assuming the maximum absolute value (maximum amplitude Amax) is found to be 0.8, which is greater than the minimum effective amplitude threshold of 0.001, therefore this frame is a valid frame. Normalization is performed on each sampling point. The normalized sample value of the 512th sampling point is 0.8 divided by 0.8, which equals 1.0. Finally, a spectral transform is performed. A Fast Fourier Transform is performed on the 1024 normalized sample values, resulting in 513 complex numbers. Assuming the real part of the complex number at the 10th frequency point is 0.3 and the imaginary part is 0.4, the amplitude value at this frequency point is calculated as follows: the square of the real part is 0.09, the square of the imaginary part is 0.16, and the sum of the two is 0.25. Taking the square root of 0.25 gives 0.5, which means the amplitude value of the 10th frequency point is 0.5. The actual frequency corresponding to this frequency point is 10 multiplied by 44100 divided by 1024, which is approximately 430.7 Hz. This means that the sound component with an actual frequency value of approximately 430 Hz has a relative intensity of 0.5 in this frame.

[0022] The original audio signal is processed continuously. After each short audio frame is processed, an amplitude spectrum corresponding to that frame is output. Due to the 50% overlap between adjacent frames, a new amplitude spectrum is output every 512 sampling points, or approximately 11.6 milliseconds. Each amplitude spectrum contains amplitude values ​​at 513 frequency points. Each amplitude value is a non-negative real number, reflecting the intensity of the corresponding frequency component in that short audio frame. The frequency range corresponding to the 513 frequency points is from 0 Hz to 22050 Hz, with a frequency resolution of approximately 43 Hz.

[0023] The microphone module continuously acquires ambient sound signals in chronological order. The microphone converts changes in air pressure from sound waves into continuously changing voltage signals. The sampling frequency is set to 44,100 samples per second, which meets the requirements of the Nyquist sampling theorem and can completely preserve the entire frequency range from 0 Hz to 22,050 Hz within the audible range. Then, the continuous raw audio signal is divided into multiple short audio frames with a preset frame length. Each short audio frame contains 1024 samples and has a duration of approximately 23 milliseconds. This duration is short enough to capture rapid changes in the audio signal. The frame length is sufficiently long to ensure adequate frequency resolution for spectral analysis. A 50% overlap is set between adjacent short audio frames, meaning the next frame is extracted starting from the 512th sampling point of the current frame. This overlapping framing method ensures that a sufficiently long period of audio information is analyzed while maintaining continuity between adjacent frames, reducing information loss due to framing. Next, a Hanning window is applied to each short audio frame. The Hanning window function has a value of 1 at the center of the frame and a value of 0 at both ends, forming a smooth bell-shaped curve. The original sample value of each sampling point is multiplied by the corresponding position... After applying the Hanning window function, the signal amplitude at the frame boundary can smoothly transition to zero, eliminating the boundary jump caused by truncation. This reduces spectral leakage during subsequent frequency domain analysis, concentrating the signal energy in the frequency domain more at the positions corresponding to the true frequency components. Then, the windowed sampled values ​​are normalized by finding the maximum absolute value of all sampled values ​​within the frame and dividing each sampled value by this maximum value, compressing the range of sampled values ​​within the frame to between -1 and +1. Simultaneously, a minimum effective amplitude threshold is set to determine silent frames; if the maximum amplitude is too small, the frame is determined to be an invalid silent frame. In subsequent processing, the normalization operation eliminates the influence of overall volume differences in audio signals at different time periods, making the subsequent spectrum analysis results comparable. Finally, a fast Fourier transform is performed on the normalized short audio frame to convert the time-domain signal into a frequency-domain signal. Since the input signal is a real number signal with conjugate symmetry, only the first 513 frequency points of the transform result need to be retained to obtain complete frequency information. The magnitude of the complex result of each frequency point is calculated as the amplitude value of that frequency point, forming the amplitude spectrum of the short audio frame. The amplitude spectrum reflects the intensity distribution of each frequency component in the short audio frame.The beneficial effects of step one are as follows: Through the processing flow of frame-by-frame windowing and fast Fourier transform, this step can efficiently and accurately convert continuous time-domain audio signals into frequency-domain amplitude spectrum representations, providing a reliable data foundation for subsequent frequency band energy extraction and feature analysis; the combination of a 50% frame overlap rate and Hanning windowing effectively suppresses spectral leakage while ensuring the continuity of time-domain analysis, improving the accuracy of frequency analysis; normalization processing enables audio signals at different volume levels to be compared and processed on a uniform scale, enhancing the system's robustness to volume changes; the silence frame detection mechanism avoids erroneous light responses when there is no valid audio signal, reducing false triggering of the system.

[0024] Step 2: For the amplitude spectrum of each short audio frame output in Step 1, divide the frequency bands according to the nonlinear frequency perception characteristics of the human auditory system. Divide the 513 frequency points of the amplitude spectrum of each short audio frame into 8 non-uniform frequency bands according to the Buck scale. Then calculate the sum of the energy of the amplitude values ​​of all frequency points in different frequency bands of the amplitude spectrum of each short audio frame to obtain the energy value of each short audio amplitude spectrum in 8 frequency bands. In this way, subsequent steps can control different areas of the LED light strip according to these 8 frequency band energy values ​​to match the light response with the human ear's perception characteristics of sound. Because the human ear has varying abilities to distinguish different frequencies: it has high resolution for low-frequency sounds, able to differentiate between two low-frequency sounds differing by tens of hertz; and low resolution for high-frequency sounds, requiring a difference of hundreds or even thousands of hertz to distinguish between two high-frequency sounds. The Barker scale is a psychoacoustic scale that conforms to the characteristics of human hearing, reflecting the nonlinear perception of frequency. On the Barker scale, approximately one Barker unit corresponds to every 100 hertz in the low-frequency range, while approximately one Barker unit corresponds to every 1000 hertz in the high-frequency range. This invention uses the Barker scale to perform a nonlinear mapping of the frequency axis, converting physical frequencies into perceived frequencies, thus matching the frequency band division method with the characteristics of human auditory perception. The conversion relationship between linear frequency and Buck scale frequency is as follows: For any given linear frequency value f, where the unit of f is Hertz, and the range of f is the audible frequency range of 20 Hertz to 18000 Hertz, the corresponding Buck scale frequency value b is calculated as follows: First, calculate the result of multiplying 0.00076 by f, take the arctangent of the result and multiply it by 13 to obtain the first term; then calculate the result of dividing f by 7500, multiply the result by itself (square), take the arctangent of the squared result and multiply it by 3.5 to obtain the second term; finally, add the first term and the second term to obtain the Buck scale frequency value b, whose unit is Buck.

[0025] Define the boundary values ​​for the audible frequency range. The lower boundary linear frequency fmin is set to 20 Hz, and the upper boundary linear frequency fmax is set to 18000 Hz. Then, convert the boundary values ​​of the audible frequency range from linear frequencies to Barker-scale frequencies. Substituting the lower boundary linear frequency of 20 Hz into the above conversion formula, the calculated lower boundary Barker value b_min is approximately 0.2 Barkers. Substituting the upper boundary linear frequency of 18000 Hz into the above conversion formula, the calculated upper boundary Barker value b_max is approximately 22.5 Barkers. Next, divide the total range into 8 equal frequency bands on the Barker scale. The total range on the Barker scale is equal to bmax minus bmin, i.e., 22.5 minus 0.2 equals 22.3 Barkers. Dividing the total range by the number of frequency bands, 8, yields a Barker width of approximately 2.7875 Barkers for each frequency band. The lower boundary of the ith frequency band is equal to b_min plus i multiplied by the band width of the Buck, and the upper boundary of the Buck is equal to bmin plus (i+1) multiplied by the band width of the Buck, where the value of i ranges from 0 to 7. Then, the Buck scale boundary is transformed back into a linear frequency boundary. For any given Buck scale frequency value b, the approximate calculation method for its corresponding linear frequency value f is: f equals 600 multiplied by the hyperbolic sine function value, where the parameter of the hyperbolic sine function is b divided by 6. The hyperbolic sine function sinh(x) is calculated as: the natural exponent e raised to the power of x minus e raised to the power of negative x, then divided by 2. After the above conversion, the linear frequency ranges corresponding to the 8 frequency bands are as follows: Band 0 is approximately 20 Hz to 300 Hz, mainly containing the fundamental frequency components of bass drum beats and bass; Band 1 is approximately 300 Hz to 700 Hz, mainly containing the harmonics of bass and mid-to-low frequency instrument components; Band 2 is approximately 700 Hz to 1200 Hz, mainly containing the low-frequency components of mid-range instruments and vocals; Band 3 is approximately 1200 Hz to 1900 Hz, mainly containing the fundamental frequency range of vocals; Band 4 is approximately 1900 Hz to 2800 Hz, mainly containing the harmonic range of vocals; Band 5 is approximately 2800 Hz to 4200 Hz, mainly containing the high-frequency instrument components; Band 6 is approximately 4200 Hz to 6500 Hz, mainly containing ultra-high frequency components; Band 7 is approximately 6500 Hz to 12000 Hz, mainly containing cymbal and breathy components.

[0026] Finally, the linear frequency boundaries are converted into frequency point index boundaries of the amplitude spectrum. For a given linear frequency value f, the corresponding frequency point index m is calculated as follows: m equals f multiplied by the frame length 1024, divided by the sampling frequency 44100, and then rounded to the nearest integer. For example, the frequency point index corresponding to the lower boundary frequency of 20 Hz in band 0 is approximately 0.46 (20 multiplied by 1024 divided by 44100), rounded to 0; the frequency point index corresponding to the upper boundary frequency of 300 Hz is approximately 6.96 (300 multiplied by 1024 divided by 44100), rounded to 7. Therefore, band 0 corresponds to the 0th to 7th frequency points of the amplitude spectrum. The linear frequency boundaries of each band are converted using the same method to determine the frequency point index range corresponding to each of the eight bands.

[0027] For the amplitude spectrum of each short-time audio frame, the energy values ​​of each of the eight frequency bands are calculated according to the frequency band boundaries determined above.

[0028] For a single frequency band, first determine the starting and ending frequency indices; then iterate through all frequency points within the band, squaring the amplitude value of each frequency point; finally, sum all the squared values ​​to obtain the original energy value of the frequency band. The energy value is calculated using the square of the amplitude because, physically, the energy of a signal is proportional to the square of its amplitude. To eliminate the impact of bandwidth differences between different frequency bands, the original energy of each frequency band is normalized. The normalized energy of the i-th frequency band is calculated by dividing the original energy value of the band by the number of frequency points it contains. The number of frequency points is equal to the end frequency index minus the start frequency index plus 1. The normalized energy value reflects the average energy per unit frequency width of the band, ensuring comparability between different frequency bands.

[0029] The above frequency band energy calculation process is performed on the amplitude spectrum of each short-time audio frame so that each short-time audio frame can obtain the corresponding 8 frequency band normalized energy values.

[0030] Taking the amplitude spectrum of a short audio frame output in step one as an example, this section explains how to divide the amplitude spectrum into frequency bands and calculate its energy. Assume the amplitude spectrum contains amplitude values ​​at 513 frequency points. Now, to calculate the normalized energy of band 0, first determine the frequency point index range of band 0. The linear frequency range corresponding to band 0 is 20 Hz to 300 Hz. After conversion to frequency point indices, the starting index is 0, and the ending index is 7, containing a total of 8 frequency points. Assume the amplitude values ​​of the 0th to 7th frequency points in the amplitude spectrum are 0.10, 0.15, 0.25, 0.35, 0.40, 0.30, 0.20, and 0.10, respectively. Square each amplitude value and sum them. The square of 0.10 is 0.01, the square of 0.15 is 0.0225, the square of 0.25 is 0.0625, the square of 0.35 is 0.1225, the square of 0.40 is 0.16, the square of 0.30 is 0.09, the square of 0.20 is 0.04, and the square of 0.10 is 0.01. Adding these eight squared values ​​gives the original energy of 0.5175. Dividing the original energy of 0.5175 by the number of frequency points (8) yields a normalized energy of approximately 0.065. This normalized energy value of 0.065 reflects the energy value of the current short-time audio frame in band 0. A higher value indicates stronger low-frequency energy, typically corresponding to the appearance of drum beats or bass sounds. Performing the same calculation on the other seven frequency bands of the same amplitude spectrum yields the energy values ​​for the complete eight frequency bands corresponding to the short-time audio frame.

[0031] Based on the nonlinear frequency perception characteristics of the human auditory system, the Barker scale is used to divide the amplitude spectrum into non-uniform frequency bands. The human ear's ability to distinguish different frequencies varies; it has high resolution for low-frequency sounds, able to distinguish two low-frequency sounds differing by tens of hertz, while its resolution for high-frequency sounds is low, requiring a difference of hundreds or even thousands of hertz to distinguish two high-frequency sounds. The Barker scale is a psychoacoustic scale that conforms to the characteristics of human hearing, reflecting the nonlinear perception of frequency. On the Barker scale, approximately one Barker unit corresponds to every 100 hertz in the low-frequency range, while approximately one Barker unit corresponds to every 1000 hertz in the high-frequency range. This step divides the amplitude spectrum into eight non-uniform frequency bands, which are evenly spaced on the Buck scale. Due to the non-linear mapping between the Buck scale and linear frequencies, the bandwidth of each band after conversion back to linear frequencies exhibits a distribution characteristic of narrow bandwidth at low frequencies and wide bandwidth at high frequencies. Specifically, band 0, approximately 20 Hz to 300 Hz, mainly contains bass drum beats and the fundamental frequency components of the bass; band 1, approximately 300 Hz to 700 Hz, mainly contains bass harmonics and mid-to-low frequency instrument components; band 2, approximately 700 Hz to 12... The first band (00 Hz) primarily contains the low-frequency components of mid-range instruments and human voices. The second band (approximately 1200 Hz to 1900 Hz) primarily contains the fundamental frequency region of human voices. The third band (approximately 1900 Hz to 2800 Hz) primarily contains the harmonic region of human voices. The fifth band (approximately 2800 Hz to 4200 Hz) primarily contains the high-frequency instrument components. The sixth band (approximately 4200 Hz to 6500 Hz) primarily contains ultra-high frequency components. The seventh band (approximately 6500 Hz to 12000 Hz) primarily contains cymbal and aerophone components. For each band, this step first converts the linear frequency boundary into the frequency point index boundary of the amplitude spectrum. Then, it iterates through all frequency points within the band, squares the amplitude value of each frequency point, and sums them to obtain the original energy value. Finally, the original energy value is divided by the number of frequency points contained in the band to obtain the normalized energy value. The normalization process eliminates the influence of bandwidth differences between different bands, making the energy values ​​between bands comparable. The beneficial effects of step two are as follows: Using the Buck scale for non-uniform frequency band division ensures that the band division method matches the characteristics of human auditory perception. A finer division of the low-frequency band accurately captures changes in low-frequency rhythmic elements such as drum beats and bass, while a coarser division of the high-frequency band aligns with the human ear's lower resolution of high-frequency details. This allows subsequent lighting responses to accurately reflect the sound characteristics actually perceived by the human ear. The eight frequency bands not only reflect the rich layers of the music's frequency structure but also avoid excessive computational complexity or fragmented lighting effects due to too many bands, achieving a good balance between information content and visualization. The normalized calculation of frequency band energy eliminates the influence of bandwidth differences, making the energy of each band fairly comparable and avoiding the bias that broadband bands naturally have higher energy due to containing more frequency points.

[0032] Step 3: For the amplitude spectrum of each short audio frame output in Step 1, the spectral flux is obtained by calculating the difference between the amplitude spectra of every two adjacent short audio frames. It is then detected whether each short audio frame contains transient components, such as drum beats or the instant of percussion. The transient enhancement factor of each short audio frame is calculated. The transient enhancement factor will be used in subsequent steps to adjust the light response intensity corresponding to the short audio frame, so that the light can respond sensitively to the rhythmic impact in the music. The specific method for calculating the spectral flux between the amplitude spectra of each short-time audio frame is as follows: For the first short audio frame, since there is no real previous frame for comparison, its transient detection flag is set to 0, the overall transient enhancement factor is set to 1.0, and the transient enhancement factors of all 8 frequency bands are set to 1.0, indicating that the first frame is processed as a steady-state frame and no transient enhancement is performed; after processing, the amplitude spectrum of the first frame is saved as a reference amplitude spectrum for use in calculating the spectral flux of the second frame; the frame counter is incremented by 1; Starting from the second short audio frame, the spectral flux and transient enhancement factor are calculated as follows: For the amplitude spectrum of the current short-time audio frame and the amplitude spectrum of the previous short-time audio frame (i.e., the saved reference amplitude spectrum), the amplitude values ​​of 513 frequency points are compared one by one. For each frequency point, the difference between the amplitude value of that frequency point in the current frame and the amplitude value of that frequency point in the previous frame is calculated. If the difference is positive, it means that the amplitude of that frequency point has increased, so the difference is retained. If the difference is negative or zero, it means that the amplitude of that frequency point has decreased or has not changed, so the difference is set to zero. Finally, the differences of all 513 frequency points are summed to obtain the original spectral flux of the current frame. The spectral flux is used to quantify the degree of change in the spectrum between the current short-time audio frame and the previous short-time audio frame. Since transient events such as drum beats are characterized by a sudden increase in energy rather than a sudden decrease in energy, the start time of the transient can be captured more accurately by only counting positive increments. Then, the original spectral flux is divided by the sum of the amplitude values ​​of all frequency points in the amplitude spectrum of the current frame, and then 0.0001 is added. The addition of 0.0001 is to prevent division by zero. The normalized spectral flux reflects the degree of spectral change relative to the overall energy level of the current frame, eliminating the influence of volume differences. The normalized spectral flux of the current frame is stored in a sliding window. If the sliding window is full (50 values), the oldest value is removed before a new value is stored. If the sliding window contains fewer than 50 normalized spectral flux values ​​(frame counter less than 51), a fixed threshold is used for transient detection, with an adaptive threshold set to 0.08. If the sliding window contains 50 normalized spectral flux values ​​(frame counter greater than or equal to 51), the mean and standard deviation of these 50 values ​​are calculated, and the adaptive threshold is equal to the mean plus 1.5 times the standard deviation. The adaptive threshold automatically adjusts according to the overall activity level of the music: in quiet sections, the mean and standard deviation are smaller, so the threshold decreases accordingly, allowing smaller spectral changes to be detected as transients; in intense sections, the mean and standard deviation are larger, so the threshold increases accordingly, allowing only more significant spectral changes to be detected as transients.

[0033] The normalized spectral flux of the current short-time audio frame is compared with an adaptive threshold to determine whether the current frame is a transient frame, and the transient enhancement factor of the frame is calculated. The specific method is as follows: If the normalized spectral flux is greater than the threshold, the current frame is determined to be a transient frame, and the transient detection flag is set to 1. The transient enhancement factor is calculated as follows: First, calculate the over-threshold ratio, which is the difference between the normalized spectral flux and the threshold, divided by the threshold; then multiply the over-threshold ratio by the enhancement coefficient 2.0, and add the base value 1.0 to obtain the transient enhancement factor; finally, limit the transient enhancement factor to the range of 1.0 to 3.0. If the normalized spectral flux is less than or equal to the adaptive threshold, the current frame is determined to be a steady-state frame, the transient detection flag is set to 0, and the transient enhancement factor is set to 1.0. In addition, using the same calculation method as for obtaining the overall spectral flux of the current frame, the local spectral flux and local transient enhancement factor corresponding to each of the eight frequency bands of the current frame are calculated respectively, and the calculation range is limited to the frequency point index range corresponding to each frequency band. The local transient enhancement factor is used for the frequency band lighting control in subsequent steps.

[0034] After processing the current frame, the amplitude spectrum of the current frame is saved as a new reference amplitude spectrum for use in calculating the spectral flux of the next frame; the frame counter is incremented by 1; the above processing is performed on the amplitude spectrum of each short-time audio frame so that each short-time audio frame can obtain the corresponding transient detection flag, the overall transient enhancement factor and the 8 frequency band transient enhancement factors.

[0035] For example: Assume the system has just started and is processing audio signals: When processing the first frame: Since it is the first frame, the transient detection flag is set to 0, the overall transient enhancement factor is set to 1.0, and the transient enhancement factors for all 8 frequency bands are set to 1.0; the amplitude spectrum of the first frame is saved as the reference amplitude spectrum; When processing the second frame: The amplitude spectrum of the second frame is compared with the amplitude spectrum (reference amplitude spectrum) of the first frame, and the spectral flux is calculated; Assume the calculated normalized spectral flux is 0.05; Since the sliding window has not reached 50 values, a fixed threshold of 0.08 is used for judgment; 0.05 is less than 0.08, so it is determined to be a steady frame, and the transient enhancement factor is 1.0; The second frame is then processed. The amplitude spectra of the two frames are saved as a new reference amplitude spectrum. When processing the 52nd frame: the sliding window is now filled with 50 normalized spectral flux historical values, and the adaptive threshold is started. Assuming the calculated mean is 0.03 and the standard deviation is 0.02, the adaptive threshold is 0.03 plus 1.5 multiplied by 0.02, which equals 0.06. Assuming the normalized spectral flux of the 52nd frame is 0.12, which is greater than the threshold of 0.06, it is determined to be a transient frame. The over-threshold ratio is 0.12 minus 0.06 divided by 0.06, which equals 1.0. The transient enhancement factor is 1.0 plus 1.0 multiplied by 2.0, which equals 3.0. The light response of this frame will receive a 3-fold brightness enhancement.

[0036] Transient components in audio are detected by calculating the spectral flux between the amplitude spectra of two adjacent short-time audio frames. Transient components refer to sound events whose energy suddenly increases in a short period of time, such as drum beats, percussion strikes, and consonant initiations. These transient events usually correspond to rhythmic downbeats in music and are the rhythmic elements that the human ear can most easily perceive and follow. For the first short-time audio frame, since there is no previous frame for comparison, its transient detection flag is set to 0, and the transient enhancement factor is set to 1.0. After processing, the amplitude spectrum of the first frame is saved as a reference amplitude spectrum for use when calculating the spectral flux of the second frame. Starting from the second short audio frame, the amplitude values ​​of 513 frequency points are compared one by one between the amplitude spectrum of the current frame and the amplitude spectrum of the previous frame. For each frequency point, the difference between the amplitude value of that frequency point in the current frame and the amplitude value of that frequency point in the previous frame is calculated. If the difference is positive, it means that the amplitude of that frequency point has increased, and the difference is retained. If the difference is negative or zero, it means that the amplitude of that frequency point has decreased or has not changed, and the difference is set to zero. This processing method of retaining only positive increments is called half-wave rectification. Its principle is that the essential characteristic of transient events is the sudden increase of energy rather than a decrease. By only counting positive increments, the starting moment of the transient can be captured more accurately while ignoring the energy decay process. The original spectral flux is obtained by summing the differences after processing all frequency points. Then, the original spectral flux is divided by the sum of the amplitude values ​​of all frequency points in the amplitude spectrum of the current frame to obtain the normalized spectral flux. The normalization process eliminates the influence of volume differences, so that the spectral flux reflects the degree of spectral change relative to the overall energy level of the current frame. To adapt to the dynamic characteristics of different music, this step uses an adaptive threshold for transient detection. A sliding window is maintained to store the normalized spectral flux values ​​of the most recent 50 consecutive frames. When the sliding window is not full, a fixed threshold is used for transient detection. When the sliding window is full, the mean and standard deviation of the normalized spectral flux values ​​within the window are calculated. The adaptive threshold is equal to the mean plus 1.5 times the standard deviation. This adaptive threshold can automatically adjust with the overall activity level of the music. In quiet sections, the threshold is automatically lowered so that small spectral changes can be detected as transients. In intense sections, the threshold is automatically raised so that only more significant spectral changes will be detected as transients. The normalized spectral flux of the current frame is compared with an adaptive threshold. If it is greater than the threshold, it is determined to be a transient frame. The over-threshold ratio is calculated and a transient enhancement factor is calculated accordingly. The transient enhancement factor is equal to the base value of 1.0 plus the over-threshold ratio multiplied by the enhancement coefficient of 2.0, and is limited to the range of 1.0 to 3.0. If it is less than or equal to the threshold, it is determined to be a steady frame, and the transient enhancement factor is set to 1.0. In addition, local spectral flux and local transient enhancement factor are calculated for each of the eight frequency bands for frequency band lighting control.The beneficial effects of step three are as follows: The transient detection mechanism based on half-wave rectified spectral flux can accurately capture energy surge events in audio signals, effectively distinguish between steady-state continuous tones and transient impact tones, enabling the lights to produce a sharp brightness enhancement response at rhythmic heavy beats such as drumbeats and percussion, greatly improving the synchronization between the lights and the music rhythm; the adaptive threshold mechanism enables the system to automatically adapt to music of different styles and dynamic ranges, achieving good transient detection results between quiet folk music and intense rock music without manual parameter adjustment, enhancing the system's versatility and intelligence; the quantitative design of the transient enhancement factor converts transient intensity into a controllable gain coefficient, realizing a positive correlation mapping between transient response intensity and actual transient degree, making the light response more in line with human perception of rhythm strength; the calculation of local transient enhancement factors in frequency bands enables different frequency bands to independently respond to transient events within their respective frequency ranges, for example, the low-frequency region can sensitively respond to drumbeats while the high-frequency region can sensitively respond to cymbals, further enhancing the layering and expressiveness of the lighting effects.

[0037] Step 4: Based on the 8 frequency band energy values ​​of each short audio frame output in Step 2 and the transient enhancement factor of each short audio frame output in Step 3, calculate the brightness value and color parameters of each area of ​​the LED light strip corresponding to each short audio frame, generate LED control commands and output them to the LED light strip driver module to realize real-time synchronous rhythmic response of light and audio. The LED light strip is divided into 8 control zones corresponding to 8 frequency bands. Assuming the LED light strip has a total of 120 LEDs, each zone contains 15 LEDs. Zone 0 contains LEDs numbered 0 to 14, driven by frequency band 0; Zone 1 contains LEDs numbered 15 to 29, driven by frequency band 1; and so on. Zone 7 contains LEDs numbered 105 to 119, driven by frequency band 7.

[0038] For each short audio frame, the brightness values ​​of the eight control regions are calculated as follows: For the i-th control region, where i ranges from 0 to 7, the base luminance value of this control region is equal to the energy value of the i-th frequency band of the frame multiplied by a luminance coefficient of 255. The luminance coefficient of 255 is used to map the energy value from 0 to 1 to the luminance range of 0 to 255. Then, the base luminance value is multiplied by the transient enhancement factor of the i-th frequency band of the frame to obtain the enhanced luminance value. Finally, the enhanced luminance value is limited to the range of 0 to 255 to obtain the final luminance value of the region. For each short audio frame, the hue value of each of the eight control regions is calculated as follows: Fixed base hues are assigned based on frequency band numbers: band 0 corresponds to red with a hue value of 0 degrees; band 1 corresponds to orange with a hue value of 30 degrees; band 2 corresponds to yellow with a hue value of 60 degrees; band 3 corresponds to green with a hue value of 120 degrees; band 4 corresponds to cyan with a hue value of 180 degrees; band 5 corresponds to blue with a hue value of 210 degrees; band 6 corresponds to indigo with a hue value of 240 degrees; and band 7 corresponds to violet with a hue value of 280 degrees. This results in warm tones in the low-frequency range and cool tones in the high-frequency range, aligning with human intuitive associations between sound and color. Simultaneously, the saturation is uniformly set to 0.8 to ensure vibrant colors. For each short audio frame, the brightness values ​​of each control region are smoothed using a filtering process to eliminate flickering between adjacent frames. The specific method is as follows: The smoothed brightness value of the i-th control region in the current frame is equal to 0.6 multiplied by the final brightness value of the control region in the current frame plus 0.4 multiplied by the smoothed brightness value of the control region in the previous frame, where 0.6 is the weight of the current frame and 0.4 is the weight of the previous frame. This weighted average can make the brightness change smoother and more natural. For each short audio frame, the HSV color parameters of each control region are converted to RGB format, specifically as follows: For the i-th control region, the color partition it belongs to is determined based on the hue value of the region. The partition number is obtained by dividing the hue value by 60 and taking the integer part. The partition number ranges from 0 to 5. Then, based on the partition number, saturation, and smooth brightness value, the red channel value, green channel value, and blue channel value are calculated according to the standard HSV to RGB conversion formula. The value of each channel ranges from 0 to 255. For each control area, based on the hue, saturation, and smooth brightness values ​​of that control area, the red, green, and blue channel values ​​are calculated according to the HSV-to-RGB conversion formula. The RGB values ​​of all LEDs within that control area are set to the same value, and the RGB values ​​of all LEDs are arranged sequentially according to their LED numbers to form a control data sequence. This control data sequence is then encapsulated according to the LED driver protocol and sent to the LED strip driver module via a serial port or SPI interface. The RGB values ​​of 120 LEDs are arranged sequentially according to their LED numbers to form a control data sequence, which is 360 bytes long. The control data sequence is encapsulated according to the LED driving protocol, and information such as frame header identifier, data length, checksum, and frame tail identifier are added to form a complete control data frame. The control data frame is sent to the LED light strip driver module through the serial port or SPI interface. After receiving the data, the driver module controls each LED to display the corresponding color and brightness. Since the processing results of a short audio frame are output every 11.6 milliseconds from step one to step three, this step also generates and sends a control data frame every 11.6 milliseconds, corresponding to a refresh rate of about 86 frames per second, so as to realize the continuous real-time rhythmic response of the LED light strip to the audio signal. Let's take a specific short audio frame as an example to illustrate the processing procedure of this step: Assuming the energy value of band 0 in this frame is 0.65 and the transient enhancement factor of band 0 is 1.3, then the base brightness value of region 0 is 0.65 multiplied by 255, which equals 165.75. The enhanced brightness value is 165.75 multiplied by 1.3, which equals 215.5. After limiting it to the range of 0 to 255, it is rounded to 216. Assuming the smooth brightness value of region 0 in the previous frame is 180, then the smooth brightness value of region 0 in the current frame is 0.6 multiplied by 216 plus 0.4 multiplied by 180, which equals 129.6 plus 72, which equals 201.6. After rounding to 202, the hue value of region 0 is 0 degrees, i.e., red, the saturation is 0.8, and the smooth brightness value is 202. According to the HSV to RGB conversion formula, the red channel value is 202, the green channel value is 40, and the blue channel value is 40. The 15 LEDs in region 0 all display this RGB color, presenting a bright red, corresponding to the low-frequency drum sound. The same calculation is performed on the other 7 areas. The RGB values ​​of 120 LED beads are encapsulated into control data frames and sent to the LED driver module. Each area of ​​the LED strip displays different brightness colors according to the energy strength of the corresponding frequency band. The brightness enhancement is more obvious during transient moments, realizing the synchronous rhythm effect of light and music.

[0039] The LED strip is divided into eight control zones, each corresponding to one of the eight frequency bands. Assuming the LED strip has 120 LEDs, each zone contains 15 LEDs. Zone 0 is driven by frequency band 0, Zone 1 by frequency band 1, and so on, with Zone 7 driven by frequency band 7. This one-to-one correspondence between frequency bands and zones allows different spatial positions of the strip to reflect changes in different frequency components of the audio signal, forming a direct mapping from frequency to space. For each short audio frame, the brightness value of each control zone is calculated as follows: the base brightness value of the zone equals the energy value of the corresponding frequency band of that frame multiplied by a brightness coefficient of 255. This maps the energy value range from 0 to 1 to a brightness range of 0 to 255. Then, the base brightness value is multiplied by the transient enhancement factor of that frequency band to obtain the enhanced brightness value, which is then limited to the range of 0 to 255 as the final brightness value. This calculation method allows the brightness value to simultaneously reflect the absolute intensity of the frequency band energy and the relative degree of transient changes, achieving additional brightness enhancement during transient moments. The color parameters of each control area are assigned a fixed base hue according to the frequency band number. The 0th frequency band corresponds to a red hue value of 0 degrees, the 1st frequency band corresponds to an orange hue value of 30 degrees, the 2nd frequency band corresponds to a yellow hue value of 60 degrees, the 3rd frequency band corresponds to a green hue value of 120 degrees, the 4th frequency band corresponds to a cyan hue value of 180 degrees, the 5th frequency band corresponds to a blue hue value of 210 degrees, the 6th frequency band corresponds to an indigo hue value of 240 degrees, and the 7th frequency band corresponds to a violet hue value of 280 degrees. This hue allocation makes the low-frequency area present a warm tone and the high-frequency area present a cool tone, which conforms to the intuitive association between sound and color. The saturation is uniformly set to 0.8 to ensure the vividness of the colors. To eliminate flickering between adjacent frames, this step performs exponential weighted smoothing filtering on the brightness values ​​of each control area. The smoothed brightness value of the current frame is equal to the current frame weight 0.6 multiplied by the current frame's final brightness value plus the previous frame weight 0.4 multiplied by the previous frame's smoothed brightness value. This weighted average makes the brightness changes smoother and more natural, maintaining the sensitivity to energy changes while eliminating the flickering caused by rapid jumps. Finally, the hue, saturation, and smooth brightness values ​​of each control area are calculated according to the HSV to RGB conversion formula to determine the values ​​of the red, green, and blue channels. The RGB values ​​of all LEDs in the area are set to the same value. The RGB values ​​of the 120 LEDs are arranged sequentially according to their LED numbers to form a 360-byte control data sequence. After being encapsulated into a control data frame according to the LED driver protocol, the data is sent to the LED strip driver module via a serial port or SPI interface. After receiving the data, the driver module controls each LED to display the corresponding color and brightness. Since the previous steps output a short audio frame every 11.6 milliseconds, this step also generates and sends a control data frame every 11.6 milliseconds, corresponding to a refresh rate of approximately 86 frames per second.The beneficial effects of step four are as follows: The one-to-one correspondence design between LED areas and frequency bands achieves an intuitive mapping from frequency to spatial position, allowing viewers to directly perceive the changes in different frequency components at different positions of the light strip. When low-frequency energy is strong, one end of the light strip lights up; when high-frequency energy is strong, the other end lights up, forming a visual effect of frequency layering, which greatly enhances the information content and artistic expression of the lighting effect; the calculation method of brightness value combined with energy and transient enhancement factor allows the light to reflect the overall trend of audio energy change while generating additional brightness pulses at rhythmic impact moments, taking into account both smooth changes and rhythmic... The system responds to two visual needs: a hue mapping scheme with warm low-frequency and cool high-frequency colors aligns with human synesthetic association between sound and color. Deep drumbeats paired with red-orange and bright cymbals paired with blue-purple create a natural connection between color changes and musical mood, enhancing the consistency of the audiovisual experience. Exponentially weighted smoothing filters effectively eliminate light flicker caused by inter-frame energy fluctuations while maintaining sufficient response speed, ensuring that light changes are both smooth and natural without sacrificing sensitivity. A refresh rate of approximately 86 frames per second far exceeds the visual persistence threshold of the human eye, ensuring the smoothness of light changes and avoiding stuttering and ghosting.

[0040] Through multi-level signal processing and intelligent feature extraction, the core defects of existing technologies have been comprehensively solved, achieving a natural, accurate, and smooth rhythmic response of LED light strips to audio signals. By employing frequency band division methods, transient detection mechanisms, adaptive threshold strategies, spatial mapping design, and smoothing filtering, the core problems of existing LED light strip music rhythm control technologies have been systematically addressed, achieving accurate synchronization between light and music rhythm, a natural and smooth visual effect, and a frequency response that conforms to human auditory perception.

[0041] The above formulas are all dimensionless calculations. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The preset parameters and thresholds in the formulas are set by those skilled in the art according to the actual situation.

[0042] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for rhythmic control of LED light strips based on audio spectrum analysis, characterized in that, include: Step 1: Acquire the original audio signal through the microphone at a preset sampling frequency, divide the original audio signal into multiple short audio frames with a preset frame length, and perform windowing, normalization and fast Fourier transform on each short audio frame in sequence to obtain the amplitude spectrum corresponding to each short audio frame. Step 2: Divide the amplitude spectrum of each short-time audio frame into multiple non-uniform frequency bands according to the Buck scale, and calculate the energy value of each frequency band; Step 3: Calculate the spectral flux between the amplitude spectra of two adjacent short-time audio frames, determine whether each short-time audio frame is a transient frame based on the comparison result of the spectral flux and the adaptive threshold, and calculate the transient enhancement factor of each short-time audio frame. Step 4: Divide the LED light strip into multiple control areas that correspond one-to-one with the frequency band. Calculate the brightness value and color parameters of each control area based on the frequency band energy value and transient enhancement factor of each short-time audio frame, generate LED control commands, and output them to the LED light strip driver module.

2. The LED light strip rhythm control method based on audio spectrum analysis according to claim 1, characterized in that, The specific method for dividing the original audio signal into multiple short-time audio frames is as follows: The sampling frequency is set to 44,100 samples per second, and each short audio frame contains 1,024 samples, with a duration of approximately 23 milliseconds. A 50% overlap rate is set between two adjacent short audio frames, meaning that the next frame is captured starting from the 512th sample point of the current frame.

3. The LED light strip rhythm control method based on audio spectrum analysis according to claim 1, characterized in that, The specific method for obtaining the amplitude spectrum corresponding to each short audio frame is as follows: For a sample point with index n in a short audio frame, where n ranges from 0 to 1023, the Hanning window function value for this sample point is equal to 0.5 multiplied by 1 minus the cosine value. The cosine value is calculated by multiplying 2 by pi, then by n, and finally dividing by 1023. The original sample value of each sample point is multiplied by the corresponding Hanning window function value to obtain the windowed sample value. All windowed sample points are iterated through to find the maximum absolute value, denoted as Amax. The minimum effective amplitude threshold Amin is set to 0.

001. When Amax is less than or equal to Amin, the frame is determined to be a silent frame. When Amax is greater than Amin, each windowed sample value is divided by Amax to obtain a normalized sample value. A fast Fourier transform is performed on the normalized short audio frame and the first 513 frequency points are retained. For the m-th frequency point, its amplitude value is equal to the square root of the sum of the square of the real part and the square of the imaginary part of the complex result of that frequency point. The actual frequency corresponding to the m-th frequency point is equal to m multiplied by 44100 and then divided by 1024.

4. The LED light strip rhythm control method based on audio spectrum analysis according to claim 1, characterized in that, The specific method for dividing the amplitude spectrum of each short-time audio frame into multiple non-uniform frequency bands according to the Buck scale is as follows: The amplitude spectrum of each short-time audio frame is divided into 8 non-uniform frequency bands according to the Barker scale. For a given linear frequency value f, the corresponding Barker scale frequency value b is calculated as follows: First, calculate 0.00076 multiplied by f, take the arctangent of this result, and multiply by 13 to obtain the first term. Then, calculate f divided by 7500, square this result, take the arctangent, and multiply by 3.5 to obtain the second term. Finally, add the two terms together to obtain the Barker scale frequency value b. The 8 non-uniform frequency bands... The corresponding linear frequency ranges are as follows: Band 0 is 20 Hz to 300 Hz, Band 1 is 300 Hz to 700 Hz, Band 2 is 700 Hz to 1200 Hz, Band 3 is 1200 Hz to 1900 Hz, Band 4 is 1900 Hz to 2800 Hz, Band 5 is 2800 Hz to 4200 Hz, Band 6 is 4200 Hz to 6500 Hz, and Band 7 is 6500 Hz to 12000 Hz.

5. The LED light strip rhythm control method based on audio spectrum analysis according to claim 4, characterized in that, The specific method for calculating the energy value of each frequency band is as follows: For a single frequency band, firstly, determine the corresponding start and end frequency indexes based on the linear frequency boundaries of the band. The frequency index corresponding to the linear frequency f is equal to f multiplied by 1024, divided by 44100, and rounded to the nearest integer. Then, traverse all frequency points within the band, square the amplitude value of each frequency point, and sum them up to obtain the original energy value of the band. Finally, divide the original energy value by the number of frequency points contained in the band to obtain the normalized energy value of the band.

6. The LED light strip rhythm control method based on audio spectrum analysis according to claim 5, characterized in that, The specific method for calculating the spectral flux between the amplitude spectra of two adjacent short-time audio frames is as follows: For the first short-time audio frame, the transient detection flag of the first short-time audio frame is set to 0, and the transient enhancement factor is set to 1.

0. After processing, the amplitude spectrum of the first frame is saved as a reference amplitude spectrum for use when calculating the spectral flux of the second frame. Starting from the second frame, the amplitude values ​​of each frequency point are compared one by one with the amplitude spectrum of the current short-time audio frame and the amplitude spectrum of the previous short-time audio frame. For each frequency point, the difference between the amplitude value of the current frame and the amplitude value of the previous frame is calculated. If the difference is positive, the difference is retained; if the difference is negative or zero, the difference is set to zero. The original spectral flux is obtained by summing the differences after processing all frequency points; the normalized spectral flux is obtained by dividing the original spectral flux by the sum of the amplitude values ​​of all frequency points in the current frame amplitude spectrum and adding 0.0001.

7. The LED light strip rhythm control method based on audio spectrum analysis according to claim 1, characterized in that, The specific method for calculating the transient enhancement factor of each short audio frame is as follows: If the normalized spectral flux is greater than the threshold, the current frame is determined to be a transient frame. First, the over-threshold ratio is calculated. The over-threshold ratio is equal to the difference between the normalized spectral flux and the threshold, divided by the threshold. Then, the over-threshold ratio is multiplied by the enhancement factor 2.0 and added to the base value 1.0 to obtain the transient enhancement factor. If the normalized spectral flux is less than or equal to the threshold, the current frame is determined to be a steady frame, and the transient enhancement factor is set to 1.

0.

8. The LED light strip rhythm control method based on audio spectrum analysis according to claim 7, characterized in that, The specific method for calculating the brightness value of each control region based on the frequency band energy value and transient enhancement factor of each short-time audio frame is as follows: The LED light strip is divided into 8 control areas, each corresponding to one of the 8 frequency bands. For the i-th control area, where i ranges from 0 to 7, the base brightness value of the control area is equal to the energy value of the i-th frequency band of the frame multiplied by the brightness coefficient 255. Then, the base brightness value is multiplied by the transient enhancement factor of the i-th frequency band of the frame to obtain the enhanced brightness value. The enhanced brightness value is then limited to the range of 0 to 255 to obtain the final brightness value of the control area.

9. The LED light strip rhythm control method based on audio spectrum analysis according to claim 7, characterized in that, The specific method for calculating the color parameters of each control area is as follows: A fixed basic hue is assigned according to the frequency band number. The hue values ​​corresponding to the 0th to 7th frequency bands are 0 degrees, 30 degrees, 60 degrees, 120 degrees, 180 degrees, 210 degrees, 240 degrees, and 280 degrees, respectively. This makes the low-frequency region of the 0th to 2nd frequency bands present warm colors of red, orange, and yellow, the high-frequency region of the 5th to 7th frequency bands present cool colors of blue, indigo, and violet, and the mid-frequency region of the 3rd and 4th frequency bands present transitional colors of green and cyan. The saturation level is uniformly set to 0.

8.

10. The LED light strip rhythm control method based on audio spectrum analysis according to claim 9, characterized in that, The specific method for generating LED control commands and outputting them to the LED strip driver module is as follows: For each control area, the red channel value, green channel value, and blue channel value are calculated according to the hue value, saturation value, and smooth brightness value of the control area, using the HSV to RGB conversion formula. The RGB values ​​of all LEDs in the control area are set to the same value, and the RGB values ​​of all LEDs are arranged sequentially according to their LED numbers to form a control data sequence. The control data sequence is then encapsulated according to the LED driving protocol and sent to the LED strip driver module via a serial port or SPI interface.