A music therapy response method and system combined with real-time optimization of heart rate variability

By constructing a millisecond-level closed-loop control mechanism for real-time perception and dynamic decision-making, and using electrocardiogram signals to extract HRV multidimensional features and autonomic nervous system balance index, music parameters are updated in real time. This solves the problem of slow response in existing music therapy systems and achieves personalized and rapid music intervention effects.

CN122272969APending Publication Date: 2026-06-26SHANGHAI TENTH PEOPLES HOSPITAL
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANGHAI TENTH PEOPLES HOSPITAL
Filing Date
2026-03-30
Publication Date
2026-06-26

Smart Images

  • Figure CN122272969A_ABST
    Figure CN122272969A_ABST
Patent Text Reader

Abstract

This invention discloses a music therapy response method and system that combines real-time optimization of heart rate variability (HRV), comprising: acquiring electrocardiogram signals through a wearable ECG sensor to construct a multidimensional dynamic representation vector of HRV; identifying the sensitive window for emotion regulation using sliding window covariance analysis; driving the HRV-music feature mapping network to output optimal music parameters at 100ms intervals within the window period, and generating intervention audio in real time by a hybrid synthesis engine; synchronously recording the HRV convergence slope to quantify the intervention effect and storing it in a log database; and constructing a context-response mapping map for subsequent intervention optimization by clustering intervention segments through an autoencoder. The system includes signal acquisition, feature extraction, window detection, parameter generation, audio synthesis, effect recording, and strategy optimization units. This invention achieves dynamic closed-loop control of music parameters driven by physiological signals, improving the response speed and regulation accuracy of music therapy during acute emotional fluctuations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of health intervention and digital healthcare technology, specifically to a music therapy response method and system that incorporates real-time optimization of heart rate variability. Background Technology

[0002] Music therapy, as a non-pharmacological and non-invasive emotional intervention, has been widely proven effective. It influences the listener's autonomic nervous system activity, brain electrical rhythms, and hormone secretion through specific sound stimuli, thereby helping to regulate emotional states and alleviate stress and anxiety. Currently, common music regulation systems mainly rely on two methods: one is to recommend music based on user subjective questionnaire feedback or static characteristics (such as age and gender); the other is to combine some physiological indicators (such as heart rate variability and skin conductance) for emotion recognition and then match them with a pre-set music library. While these methods have achieved personalized intervention to some extent, they still belong to an open-loop model of "assessment first, then playback," and cannot dynamically adjust according to the user's real-time physiological state during the intervention process.

[0003] With the development of wearable devices and artificial intelligence technology, music intervention systems are gradually shifting from rule-driven to data-driven approaches. For example, by continuously monitoring indicators such as heart rate variability (HRV), the system can identify whether a user is under stress or experiencing emotional fluctuations. Existing technologies, such as CN120661812A, disclose a personalized emotion regulation system and method based on music therapy, which predicts the emotional perturbation index and generates a set of intervention music parameters by collecting users' circadian rhythm parameters and real-time emotion indicators.

[0004] However, this system still has the following shortcomings: First, its calculation of the emotional perturbation index relies on a simple function transformation of the heart rate variability sequence, failing to deeply analyze the multidimensional dynamic characteristics of the autonomic nervous system in the time domain, frequency domain, and nonlinear dimensions, especially lacking the quantification of nonlinear complexity indicators such as sample entropy and approximate entropy; second, its intervention window identification is based on the instantaneous threshold judgment of the emotional perturbation index, failing to capture the continuous shift process of the sympathetic-parasympathetic neural coupling relationship; third, its music parameter update cycle is fixed, failing to dynamically switch to a millisecond-level response mode within the intervention window according to the closed-loop control requirements; finally, its intervention effect evaluation uses a static scoring function, and the evaluation result is not used as a feedback signal for closed-loop optimization of system parameters. These shortcomings collectively limit the response speed, adjustment accuracy, and long-term applicability of the music therapy system in real-world applications, especially when facing acute emotional fluctuations, where existing methods often appear sluggish and rigid. Summary of the Invention

[0005] To address the problems of inaccurate intervention timing, static parameter adjustments, and lack of closed-loop evaluation and self-learning capabilities in existing technologies, this invention provides a music therapy response method and system that combines real-time optimization based on heart rate variability. Its core lies in constructing a millisecond-level closed-loop control mechanism of "real-time perception - dynamic decision-making - immediate recording - continuous optimization" to achieve rapid, precise, and personalized intervention in music therapy during acute emotional fluctuations.

[0006] To achieve the above objectives, the present invention provides the following technical solution:

[0007] A music therapy response method incorporating real-time optimization of heart rate variability includes the following steps:

[0008] S1. The user's electrocardiogram signal is continuously collected through a wearable physiological sensing unit, and the time-domain, frequency-domain and nonlinear feature parameters of heart rate variability are extracted to construct a multidimensional dynamic representation vector of HRV; wherein, the nonlinear feature parameters include at least sample entropy and approximate entropy, which are used to quantify the complexity of the autonomic nervous system.

[0009] S2. Based on the low-frequency power LF and high-frequency power HF sequences in the HRV multidimensional dynamic representation vector, the autonomic nervous balance index representing the sympathetic-parasympathetic nerve coupling relationship is calculated using the sliding window covariance analysis method. When the autonomic nervous balance index is lower than the preset individualized threshold for three consecutive sliding windows, it is determined that the user has entered the emotion regulation sensitive window. The individualized threshold is set based on the distribution of HRV data in the user's historical resting state.

[0010] S3. Within the sensitive window of emotion regulation, the sampling and update period of the HRV multidimensional dynamic representation vector is switched to 100ms. After continuous updating, it is input into the pre-trained HRV-music feature mapping network to output the currently recommended rhythm rate, mode type, timbre distribution and sound field width parameters.

[0011] S4. Based on the output music parameters, the audio synthesis engine generates or adjusts the intervention audio stream that is playing in real time, and simultaneously records the RR interval sequence from the 1st to the 6th second after the opening of the emotion regulation sensitive window as the HRV response trajectory.

[0012] S5. Calculate the RMSSD value for the HRV response trajectory every second to form an RMSSD time-series curve. Use the least squares method to fit the HRV convergence slope. Associate the HRV convergence slope with the music parameters used in the current intervention and the initial HRV state, and store it in the intervention log database as a quantitative indicator of the intervention effect.

[0013] S6. Periodically extract intervention segments from the intervention log database, concatenate the initial HRV state, corresponding music parameters, and HRV convergence slope into a joint vector, compress it into the latent space through an autoencoder, perform weighted clustering with the HRV convergence slope as the clustering weight, and construct a context-response mapping map, which is used for parameter initialization and fast convergence guidance of the HRV-music feature mapping network in the next round of intervention.

[0014] Preferably, the HRV multidimensional dynamic representation vector includes the following eight features: root mean square (RMSSD) of the difference between adjacent RR intervals, standard deviation (SDNN) of all RR intervals, low-frequency power (LF), high-frequency power (HF), LF / HF ratio, standard deviations (SD1 and SD2) of the Poincaré scatter plot, sample entropy, and approximate entropy.

[0015] The wearable physiological sensing unit is a three-lead ECG patch sensor that acquires raw electrocardiogram signals at a sampling rate of 1000Hz and performs R-wave detection and RR interval sequence extraction through an embedded microcontroller.

[0016] Preferably, the sliding window covariance analysis method uses a sliding window with a length of 60 seconds and a step size of 5 seconds to calculate the covariance of the LF power and HF power sequences to obtain the autonomic nervous system balance index.

[0017] Preferably, the HRV-music feature mapping network is a three-layer fully connected neural network. The input layer receives 8-dimensional HRV features, the hidden layer contains 64 ReLU activation units, and the output layer contains four independent sub-output layers, corresponding to four types of parameters: tempo, mode type, timbre distribution, and sound field width. Each sub-output layer is normalized by the Softmax function to obtain the discrete level probability distribution of the corresponding parameter, wherein:

[0018] The tempo rate is divided into four levels: 40 BPM, 60 BPM, 80 BPM, and 100 BPM; the mode type is divided into two levels: pentatonic scale and natural major scale; the timbre distribution is divided into three levels: piano-dominant, string-dominant, and ambient white noise-dominant; and the sound field width is divided into two levels: narrow sound field and wide sound field.

[0019] The HRV-music feature mapping network employs a transfer learning strategy before deployment, pre-training on a public HRV-emotion dataset. Within 72 hours of the user's first use, the weights of the hidden and output layers are fine-tuned based on individual physiological response data to achieve personalized adaptation.

[0020] Preferably, the audio synthesis engine adopts a hybrid architecture that combines physical modeling synthesis with wavetable sampling playback. It adjusts the beat interval according to the input rhythm rate, switches between pentatonic scales or natural major scales according to the mode type, mixes the audio output of piano, string and ambient white noise sound primitives according to timbre distribution weights, and dynamically adjusts the sound field width through the head-related transfer function (HRTF) algorithm.

[0021] Preferably, the HRV response trajectory refers to the RR interval sequence from the 1st to the 6th second after the opening of the emotion regulation sensitivity window; the HRV convergence slope is calculated through the following steps: based on the HRV response trajectory, the RMSSD value is calculated once per second to obtain the RMSSD time series curve containing 6 time points; the least squares method is used to linearly fit the time series curve, and the slope of the fitted line is the HRV convergence slope.

[0022] Preferably, the intervention log database is indexed by timestamps and stores the start time of each intervention, the initial value of the HRV multidimensional dynamic representation vector, the four types of music parameters output, the HRV convergence slope, and the duration.

[0023] Preferably, the autoencoder includes an encoder and a decoder. The encoder consists of three fully connected layers that compress the HRV-music parameter-convergence slope joint vector into an 8-dimensional latent space representation. The decoder consists of three fully connected layers that reconstruct the original joint vector through fully connected operations.

[0024] The context-response mapping map forms multiple high-density regions by weighted clustering of intervention fragments in the latent space, with each region center corresponding to a combination of music parameters under a typical HRV context.

[0025] This invention also discloses a music therapy response system that incorporates real-time optimization based on heart rate variability, comprising:

[0026] The physiological signal acquisition unit is configured to acquire the user's electrocardiogram signal at a sampling rate of 1000Hz through a three-lead ECG patch sensor and output the RR interval sequence;

[0027] The HRV feature extraction unit is connected to the physiological signal acquisition unit and is used to calculate eight HRV features, including RMSSD, SDNN, LF power, HF power, LF / HF ratio, SD1 and SD2 of Poincaré scatter plot, sample entropy and approximate entropy, to form a multidimensional dynamic representation vector of HRV.

[0028] The emotion window detection unit, connected to the HRV feature extraction unit, is used to calculate the autonomic nervous balance index from the LF power and HF power sequences using the sliding window covariance analysis method, and to trigger the emotion regulation sensitive window signal when the sliding window is lower than the preset individualized threshold for three consecutive sliding windows.

[0029] The music parameter generation unit has a built-in HRV-music feature mapping network and is connected to the emotion window detection unit and the HRV feature extraction unit. It is used to receive the HRV multidimensional dynamic representation vector with a period of 100ms after receiving the emotion regulation sensitive window signal and output the rhythm rate, mode type, timbre distribution and sound field width parameters.

[0030] The real-time audio synthesis unit is connected to the music parameter generation unit and is used to generate or adjust the intervention audio stream according to the music parameters using a hybrid architecture of physical modeling and wavetable synthesis.

[0031] The intervention effect recording unit is connected to the physiological signal acquisition unit and the audio real-time synthesis unit. It is used to record the RR interval sequence from the 1st to the 6th second after the opening of the emotion regulation sensitive window, calculate the HRV convergence slope, and store the intervention start time, HRV initial vector, output music parameters, HRV convergence slope and duration as structured records in the intervention log database.

[0032] An intervention log database, connected to the intervention effect recording unit, is used to store the intervention start time, the initial value of the HRV multidimensional dynamic representation vector, music parameters, HRV convergence slope, and duration.

[0033] The strategy optimization unit, connected to the intervention log database and the music parameter generation unit, is used to periodically extract intervention segments, compress the joint vector of HRV initial vector, music parameters and HRV convergence slope into the latent space through an autoencoder, perform weighted clustering with HRV convergence slope as the clustering weight, construct a context-response mapping map, and feed it back to the music parameter generation unit to optimize subsequent intervention parameters.

[0034] Preferably, a simplified version of the HRV feature extraction unit and the emotion window detection unit is deployed on a wearable device for real-time calculation of HRV features and preliminary window detection; when a potential emotion regulation sensitive window is detected, high-frequency HRV data is uploaded to a mobile terminal or cloud server.

[0035] The music parameter generation unit, real-time audio synthesis unit, intervention effect recording unit, and strategy optimization unit are deployed on mobile terminals or cloud servers.

[0036] This invention provides a music therapy response method and system that combines real-time optimization of heart rate variability (HRV), offering the following advantages: By deeply analyzing the dynamic coupling relationship of HRV frequency domain features through sliding window covariance analysis, it can keenly capture the critical point of a sustained shift in autonomic nervous system balance, thereby accurately identifying the sensitive window for emotion regulation. Once this window is entered, the HRV feature sampling and music parameter update cycle is immediately shortened to the 100-millisecond level, and the audio synthesis engine is driven to make real-time adjustments. This allows music intervention to closely follow the instantaneous fluctuations in the user's physiological state, achieving a fundamental shift from "static matching" to "dynamic companionship," significantly improving the timeliness and biological relevance of the intervention.

[0037] By employing an HRV-music feature mapping network that combines pre-training with personalized fine-tuning, the system not only learns basic patterns using general data but also quickly adapts to the unique physiological response characteristics of each user in the early stages of use. Through unsupervised learning and weighted clustering of historical intervention segments using an autoencoder, the system can automatically extract and solidify music parameter combinations under different HRV scenarios in the latent space, forming an ever-evolving scenario-response mapping map. This enables the system to continuously self-optimize, and as usage time increases, its recommended music parameters will increasingly align with the user's personal preferences and physiological responses.

[0038] By explicitly defining HRV convergence slope as the core quantitative indicator, the response characteristics of the autonomic nervous system during intervention are quantified by comparing the short-term RMSSD change trends before and after intervention. This indicator is not used to "verify" the effectiveness of the current intervention, but rather as an effect feature label. It is stored in the log database along with the initial HRV state at the time of intervention and the music parameters used, and is used as sample weights in subsequent clustering learning, so that intervention segments with better effects have a higher contribution to strategy optimization. This feedback directly participates in the autoencoder clustering learning of the strategy optimization stage, ensuring that every intervention attempt, regardless of its effect, provides valuable data input for the iteration of the system strategy, forming a virtuous cycle of "record-driven optimization".

[0039] By adopting a distributed system architecture, the entire intervention process is fully automated, requiring no active reporting or operation from the user. The system initiates precise intervention before the user even notices their emotional fluctuations, achieving seamless health support. For scenarios involving emotional fluctuations such as anxiety and acute stress, the system demonstrates advantages in rapid response and stable regulation, effectively compensating for the shortcomings of traditional methods in such scenarios, such as slow response and rigid adaptation. This greatly expands the universality and reliability of music therapy in real-world scenarios such as daily life, the workplace, and medical assistance. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in this invention or the prior art, the accompanying drawings used in the description of this invention or the prior art will be briefly introduced below.

[0041] Figure 1 This is a flowchart of the steps of the music therapy response method of the present invention;

[0042] Figure 2 This is a schematic diagram of the overall architecture of the music therapy response system of the present invention;

[0043] Figure 3 This is a flowchart of the construction of the HRV multidimensional dynamic representation vector and the calculation of the autonomic nervous balance index in this invention;

[0044] Figure 4 This is a schematic diagram of the HRV-music feature mapping network structure in this invention. Detailed Implementation

[0045] To make the objectives, technical solutions, and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings.

[0046] Example 1, as Figures 1 to 4 As shown, a music therapy response method incorporating real-time optimization of heart rate variability includes the following steps:

[0047] S1: Physiological signal acquisition and HRV feature extraction

[0048] The user wears an ECG patch sensor (such as a medical-grade patch applied to the chest) with integrated three-lead flexible electrodes. This sensor continuously acquires raw ECG signals at a sampling frequency of 1000Hz. The acquired signals are processed in real time by a built-in embedded microcontroller (e.g., a low-power chip based on an ARM Cortex-M4 core). The microcontroller runs an R-wave detection algorithm (such as the Pan-Tompkins algorithm) to accurately identify the peak value of the R wave in each cardiac cycle and calculate the time interval between adjacent R waves, thereby outputting a high-precision RR interval sequence.

[0049] Subsequently, based on this RR interval sequence, a set of eight heart rate variability features were calculated in real time, forming an 8-dimensional HRV multidimensional dynamic representation vector. Specific features include:

[0050] Temporal characteristics: root mean square of the difference between adjacent RR intervals (RMSSD) and standard deviation of all RR intervals (SDNN).

[0051] Frequency domain characteristics: The Lomb-Scargle periodogram analysis method, which is applicable to short-time, non-stationary signals, is used to calculate the low-frequency power (LF, 0.04–0.15 Hz), the high-frequency power (HF, 0.15–0.4 Hz), and the ratio between the two.

[0052] Nonlinear characteristics: The standard deviation of the minor axis (SD1) and the standard deviation of the major axis (SD2) were calculated based on the Poincaré scatter plot; and the sample entropy and approximate entropy, which characterize the complexity of heart rate rhythm, were calculated. The calculation methods for sample entropy and approximate entropy are existing technologies and will not be described in detail here.

[0053] The feature vector is updated and output once per second, providing a real-time data source for subsequent analysis.

[0054] S2: Sensitive Window Recognition for Emotion Regulation

[0055] The system continuously receives the aforementioned HRV multidimensional dynamic representation vector and extracts the LF power sequence and HF power sequence from it. A sliding window covariance analysis method is used to perform dynamic analysis on these two sequences, specifically including:

[0056] (1) Set a sliding window with a length of 60 seconds and a step size of 5 seconds.

[0057] (2) Within each window, the covariance between the LF power sequence and the HF power sequence is calculated. This value is defined as the "autonomic balance index" and is used to quantify the instantaneous coupling and balance between sympathetic and parasympathetic nerve activities.

[0058] The system presets an individualized threshold for each user, based on statistical analysis of the user's historical HRV data at rest. Specifically, the threshold is the 10th percentile of the distribution of the user's autonomic nervous system balance index at rest over the past 7 days. When the real-time calculated autonomic nervous system balance index is below this individualized threshold for three consecutive sliding windows (i.e., for 15 seconds), the system determines that the user's autonomic nervous system is in a state of persistent imbalance, marking the opening of the "sensitive window for emotion regulation." The system records this trigger moment and activates subsequent high-frequency intervention procedures.

[0059] S3: Real-time dynamic generation of music parameters

[0060] Upon entering the emotion regulation sensitive window, the system switches to a high-speed closed-loop operating mode. The sampling frequency for HRV feature extraction is increased to 10Hz (i.e., the HRV multidimensional dynamic representation vector is updated every 100ms). Within the window period, the HRV features employ a rolling window update strategy, calculating eight features in real time based on the RR interval sequence of the previous 30 seconds, ensuring a balance between the stability and timeliness of the frequency domain features. The updated vector is then input in real time into a pre-trained HRV-music feature mapping network. This network has a three-layer fully connected structure, specifically including:

[0061] (1) Input layer: Receives the above 8-dimensional HRV feature vector.

[0062] (2) Hidden layer: contains 64 neurons, uses ReLU function as activation function, and performs nonlinear feature transformation.

[0063] (3) Output layer: Corresponding to four music parameter dimensions, each dimension is divided into several discrete levels, as follows:

[0064] Pace / rate: 40 BPM, 60 BPM, 80 BPM, and 100 BPM (four levels);

[0065] Mode types: two levels: pentatonic scale and natural major scale;

[0066] Tonal distribution: three levels: piano-dominant, string-dominant, and ambient white noise-dominant;

[0067] Sound field width: Two levels: narrow sound field and wide sound field.

[0068] The raw values ​​of the output layer are normalized using the Softmax function, and the level with the highest probability is selected as the current recommended output.

[0069] Before system deployment, the HRV-music feature mapping network was pre-trained on a publicly available HRV-emotion association dataset (such as the DEAP or WESAD dataset) to learn a general physiological-music response pattern. Within 72 hours of a user's first use of the system, the system will use the collected physiological response data unique to that user to fine-tune the weights of the hidden and output layers of the network (freezing the input layer weights), thereby completing the adaptation from a general model to a personalized model.

[0070] S4, Real-time Audio Synthesis and Response Recording

[0071] The music parameter generation network outputs a set of four types of parameters every 100ms, specifically including:

[0072] (1) Rhythm and speed: control the speed of the music beat.

[0073] (2) Mode type: determines which scale library to use. For example, "soothing" corresponds to the pentatonic scale library, and "activating" corresponds to the natural major scale library.

[0074] (3) Timbre distribution: The mixing ratio of various sound elements such as piano, strings, and ambient white noise is specified in the form of weights.

[0075] (4) Sound field width: determines the spatial width of the sound.

[0076] After receiving the four types of parameters mentioned above, the audio synthesis engine employs a hybrid architecture combining physical modeling synthesis and wavetable sampling playback to generate or dynamically adjust the intervention audio stream within an extremely short latency (typically less than 20ms), and then plays it to the user in real time through headphones or speakers. Simultaneously, the system begins recording the RR interval sequence from the opening moment of the emotion regulation sensitive window, from second 1 to second 6, as the subsequent HRV response trajectory.

[0077] S5. Real-time quantitative assessment of intervention effects

[0078] The intervention effect recording unit works synchronously after the intervention is initiated, specifically including:

[0079] S501: Baseline HRV status acquisition: Take the RR interval sequence within 30 seconds before the opening of the emotion regulation sensitivity window, calculate its mean, and use it as the baseline reference for assessment.

[0080] S502: HRV response trajectory extraction: Extract the RR interval sequence from the 1st to the 6th second after the opening of the emotion regulation sensitivity window as the HRV response trajectory after intervention.

[0081] S503: Quantitative Calculation of Effect: For the HRV response trajectory, the RMSSD value is calculated once per second, forming an RMSSD time-series curve containing 6 time points. The curve is then linearly fitted using the least squares method, and the slope of the resulting fitted line is the "HRV convergence slope". The formula for the least squares method is:

[0082]

[0083] in, For time points (1, 2, ..., 6 seconds). The slope represents the RMSSD value in seconds, n=6. This slope characterizes the speed of recovery of autonomic nervous system (especially parasympathetic activity) after intervention.

[0084] S504: Record Storage: Store the complete information of this intervention, including timestamp, initial HRV vector, output music parameters, calculated HRV convergence slope, and intervention duration, as a structured record in the intervention log database.

[0085] It's important to note that the "recommended" music parameters output by the HRV-music feature mapping network refer to the probabilistically optimal recommendations based on the user's historical data and the pre-trained model under the current physiological state. This does not guarantee that every intervention will produce an ideal physiological response. Due to the instantaneous fluctuations in individual physiological states, environmental interference, and the nonlinear response characteristics of the autonomic nervous system, the actual intervention effects may vary. Therefore, this system calculates the HRV convergence slope not to "verify" the effectiveness of the intervention, but rather to use this indicator as a feature label of the intervention effect, storing it along with the initial HRV state and the music parameters used in the log database. This data will be used in subsequent strategy optimization stages for the autoencoder to cluster the effects of different intervention strategies, thereby continuously optimizing the output accuracy of the HRV-music feature mapping network. In other words, the calculation of the HRV convergence slope serves the long-term self-evolution of the system, rather than an immediate evaluation of the current intervention.

[0086] S6. Self-learning and optimization of long-term strategies

[0087] The system periodically (e.g., daily when the system is idle) starts a policy optimization process, which includes:

[0088] S601: Data Extraction: Extract all intervention record fragments from the intervention log database.

[0089] S602: Joint Space Construction: The initial HRV state vector (8-dimensional), the corresponding music parameter vector (4-dimensional), and the HRV convergence slope (1-dimensional) of each intervention segment are concatenated to form a 13-dimensional "HRV-music parameter-effect joint vector".

[0090] S603: Feature Learning and Clustering: All joint vectors are input into a pre-trained autoencoder. This autoencoder consists of an encoder and a decoder. The encoder consists of three fully connected layers, compressing the 12-dimensional vector into an 8-dimensional latent space representation. The decoder consists of three fully connected layers, reconstructing the original joint vector. The autoencoder uses effect-weighted mean squared error as the loss function, giving higher weights to samples with larger absolute values ​​of HRV convergence slopes during training. An Adam optimizer is used with a learning rate of 0.001, and training is performed for 100 epochs until the reconstruction error stabilizes. In the latent space, the K-means algorithm is used to perform weighted clustering of the representations of all intervention segments, using the HRV convergence slope as the sample weight, to identify several "high-density regions".

[0091] S604: Graph Construction and Application: The center point of each high-density region is mapped back to the original HRV-music parameter-effect joint space through the decoder. The HRV state and music parameter components are extracted, representing a music parameter combination recorded under a specific HRV context. All such combinations constitute a "context-response mapping graph." This graph is fed back to the music parameter generation unit. When the system detects again that the user's HRV state falls into or is close to a predefined context in the graph, it can directly use the parameter combination corresponding to that context as a strong initialization guide for the generation network, thereby significantly reducing parameter search time and achieving "rapid convergence" and continuous personalized optimization of the intervention strategy.

[0092] Through the cyclical execution of the above six steps, this embodiment achieves real-time and accurate perception of the user's emotional and physiological state, personalized music intervention with millisecond-level response, instant effect recording, and intelligent evolution based on historical data, forming a complete, efficient, and adaptive closed-loop music therapy response system.

[0093] Example 2: This invention also discloses a music therapy response system that incorporates real-time optimization of heart rate variability (HRV), comprising: a physiological signal acquisition unit 1, an HRV feature extraction unit 2, an emotion window detection unit 3, a music parameter generation unit 4, a real-time audio synthesis unit 5, an intervention effect recording unit 6, a strategy optimization unit 7, and an intervention log database 8. The units are connected via wired or wireless communication protocols (such as Bluetooth, Wi-Fi, or mobile networks) to form a closed-loop data processing and feedback control architecture. The physiological signal acquisition unit 1 is connected to the input of the HRV feature extraction unit 2. The output of the HRV feature extraction unit 2 is connected to the emotion window detection unit 3 and the intervention effect recording unit 6, respectively. The output of the emotion window detection unit 3 is connected to the music parameter generation unit 4. The output of the music parameter generation unit 4 is connected to the real-time audio synthesis unit 5. The output of the real-time audio synthesis unit 5 is used to play the intervention audio stream to the user, and its control signal is also fed back to the intervention effect recording unit 6. The output of the intervention effect recording unit 6 is connected to the intervention log database 8. The strategy optimization unit 7 reads historical intervention data from the intervention log database 8 and feeds back the optimized parameter mapping results to the music parameter generation unit 4 for the initialization of the next round of intervention.

[0094] Specifically:

[0095] Physiological signal acquisition unit 1: The core is a three-lead ECG patch sensor that meets medical safety standards. This sensor continuously acquires the user's analog ECG signals at a high sampling rate of 1000Hz. The integrated analog-to-digital converter digitizes the analog signals and transmits the raw digital ECG signal stream to the HRV feature extraction unit 2 within the same device via Bluetooth Low Energy or a proprietary wireless protocol.

[0096] HRV Feature Extraction Unit 2: This unit is integrated into the embedded microcontroller (such as the ARM Cortex-M series) of the wearable device. It receives the raw ECG signal in real time and first runs a lightweight real-time R-wave detection algorithm to generate an accurate RR interval sequence. Subsequently, based on the data from the previous sliding window (e.g., 5 seconds), it calculates eight HRV features in real time, including RMSSD, SDNN, LF power, HF power, LF / HF ratio, SD1 and SD2 of the Poincaré scatter plot, sample entropy, and approximate entropy, and packages them into a multidimensional dynamic representation vector of HRV. The design focus of this unit is algorithm optimization to ensure low-latency, high-energy-efficiency real-time computation in resource-constrained embedded environments.

[0097] Emotion Window Detection Unit 3: This unit, deployed on a mobile terminal or cloud server, receives the HRV multidimensional dynamic representation vector stream from the wearable device. It maintains a sliding window buffer with a length of 60 seconds and a step size of 5 seconds, performing a complete covariance calculation on the LF and HF power sequences within the window to derive the autonomic nervous system balance index. This unit continuously compares this index with a user-preset individualized threshold. Once the condition of "three consecutive windows below the threshold" is met, a high-priority "emotion regulation sensitive window" trigger signal is immediately generated. To reduce the data load of wireless transmission and further improve response speed, a simplified preprocessing module can be deployed on the wearable device, uploading high-frequency HRV data or trigger signals to the cloud for complete covariance calculation only when potential emotion window trigger signs are detected.

[0098] Music Parameter Generation Unit 4: This unit is the core decision-making module of the system, containing a pre-trained HRV-music feature mapping neural network that can be fine-tuned based on user data. Upon receiving a trigger signal, this unit begins to receive the latest HRV multidimensional dynamic representation vector from the wearable device at a high speed with a period of 100ms. The neural network performs forward propagation calculations on this vector, outputting four-dimensional music parameters (rhythm, mode, timbre, and sound field). This unit includes a parameter caching mechanism to ensure a smooth transition in audio synthesis.

[0099] Audio Real-Time Synthesis Unit 5: This unit is a professional digital audio processing module. It receives instructions from the music parameter generation unit and invokes its internal physical modeling and wavetable synthesis mixing engine. The physical modeling part is used to generate the timbres of certain instruments in real time (such as wind instruments), while the wavetable part calls pre-recorded high-quality instrument samples (such as piano and strings). This unit controls the note timing according to the "rhythm rate" parameter, limits the pitch set according to the "mode type" parameter, mixes different sound sources according to the weights according to the "timbre distribution" parameter, and calls the HRTF filter for spatial audio rendering according to the "sound field width" parameter, ultimately generating a stereo or multi-channel interference audio stream, which is output to the user's headphones or speakers through the audio interface.

[0100] Intervention Effect Recording Unit 6: This unit starts synchronously after the emotional window opens. It subscribes to high temporal resolution RR interval data from the physiological signal acquisition unit (via a wearable device). A baseline is calculated using data from the 30 seconds before the window opens, and data from the 1st to 6th seconds after opening is continuously analyzed to form the HRV response trajectory. By calculating the fitted slope of the RMSSD change curve (HRV convergence slope), this unit obtains a quantitative indicator of the effect of the current intervention round and stores the intervention start time, initial HRV vector, output music parameters, HRV convergence slope, and duration as structured records in the intervention log database.

[0101] Strategy Optimization Unit 7: This unit is the system's self-learning engine, typically running in the background with low priority on a set schedule (e.g., daily). It accesses the intervention log database and extracts all intervention records. The "state-action-outcome" data pairs (i.e., HRV initial vector, music parameter vector, and HRV convergence slope) from these records are input into the autoencoder neural network. The autoencoder uses effect-weighted mean squared error as the loss function, an Adam optimizer, and a learning rate of 0.001, training for 100 epochs until the reconstruction error stabilizes. Through encoding, latent space weighted clustering (using the K-means algorithm, with the HRV convergence slope as the sample weight), and decoding processes, this unit abstracts and refines intervention strategies for different typical physiological situations, forming a "situation-response mapping map." This map is fed back to the music parameter generation unit to optimize its network parameters or as a priority strategy library for future interventions, thereby achieving continuous evolution of the system's intervention capabilities.

[0102] Intervention Log Database 8: This is a structured data storage module that can be in the form of SQLite (local) or MongoDB (cloud). It uses timestamps as the primary key to systematically record the complete "medical record" of each intervention attempt, including the trigger time, initial physiological state, music intervention prescription adopted, real-time physiological response trajectory, calculated effect score (HRV convergence slope), and intervention duration.

[0103] In actual operation, data flow and control flow are transmitted along the following paths:

[0104] Perception Flow: The electrocardiogram signal is acquired by the physiological signal acquisition unit, converted into a feature vector by the HRV feature extraction unit, and sent to the emotion window detection unit.

[0105] Decision flow: When the emotion window detection unit determines that the sensitive window is open, it immediately notifies the music parameter generation unit. The latter generates music parameters based on real-time HRV features and sends them to the real-time audio synthesis unit.

[0106] Execution and Recording Stream: The real-time audio synthesis unit generates sound to intervene with the user. Simultaneously, the intervention effect recording unit monitors the user's physiological response, calculates effect indicators, and archives the entire intervention process data into the intervention log database.

[0107] Optimization Flow: The strategy optimization unit periodically analyzes historical intervention data in the database, updates the knowledge graph, and feeds the optimization results back to the music parameter generation unit, completing a complete "perception-decision-execution-recording-learning" closed loop.

[0108] In a real-world application scenario, for example, an anxiety patient experiences increased heart rate and decreased HRV under work stress. The patient's physiological signal acquisition unit 1 continuously monitors the electrocardiogram (ECG) signal, while the HRV feature extraction unit 2 detects a continuously increasing LF / HF ratio and a decreasing RMSSD. The emotion window detection unit 3, through sliding window covariance analysis, finds that the autonomic nervous balance index is below the individual's threshold for three consecutive windows (this threshold is set based on the patient's resting HRV data from the past week), thus triggering the start of the emotion regulation sensitive window at t=0. Subsequently, the system updates the HRV features at 100ms intervals and outputs a parameter combination of a soothing rhythm (60 BPM), pentatonic scale, high piano timbre weight, and narrow soundstage width through the HRV-music feature mapping network. The real-time audio synthesis unit 5 generates an intervention audio clip with a soothing rhythm, pentatonic scale, predominantly piano timbre, and narrow soundstage based on this. The intervention effect recording unit 6 monitors the RMSSD rising from 12ms to 18ms over the next 6 seconds, with a fitting slope of -1.2ms / s, and stores the complete intervention data in the intervention log database 8. After repeated use, a high-density region corresponding to the "high sympathetic activation" situation is formed in the situation-response mapping constructed by the strategy optimization unit 7, enabling the system to output matching music parameters faster in similar situations and reduce the trial and error process.

[0109] Throughout the system's operation, all data streams are transmitted between units via wired or wireless communication protocols, ensuring millisecond-level response latency. The physiological signal acquisition unit 1 and HRV feature extraction unit 2 are deployed on wearable devices for low-power real-time processing; the emotion window detection unit 3, music parameter generation unit 4, real-time audio synthesis unit 5, intervention effect recording unit 6, and strategy optimization unit 7 are deployed on mobile terminals or cloud servers, flexibly configured according to computing power requirements. The intervention log database 8 is stored in SQLite or MongoDB format, supporting indexed queries by fields such as time and user ID. The autoencoder training uses the mean squared error loss function, with Adam as the optimizer, a learning rate of 0.001, and 100 training epochs until the reconstruction error stabilizes. The fine-tuning phase of the HRV-music feature mapping network uses the user's intervention data from the previous 72 hours as the training set, freezing the input layer weights and fine-tuning only the hidden and output layers to retain general features while adapting to individual response patterns.

[0110] Through the collaborative work of the above units, this system realizes a complete closed-loop process from physiological signal acquisition, HRV in-depth analysis, accurate identification of emotional windows, millisecond-level dynamic adjustment of music parameters, quantitative recording of intervention effects, to long-term strategy self-optimization. This ensures that when a user is in a sensitive window for emotional regulation, a music intervention plan that is adapted to their current autonomic nervous system state can be generated in real time, and the intervention efficiency and personalization level can be continuously improved through continuous learning.

[0111] This invention utilizes sliding window covariance analysis to deeply analyze the dynamic coupling relationship of HRV frequency domain features (LF / HF power sequences), enabling it to keenly capture the critical point of a sustained shift in autonomic nervous system balance, thereby accurately identifying the sensitive window for emotion regulation. Once this window is entered, the sampling period for HRV features and the update cycle for music parameters are immediately shortened to the 100-millisecond level, driving the audio synthesis engine to make real-time adjustments. This allows music intervention to closely follow the instantaneous fluctuations in the user's physiological state, achieving a fundamental shift from "static matching" to "dynamic companionship," significantly improving the timeliness and biological relevance of the intervention.

[0112] By employing an HRV-music feature mapping network that combines pre-training with personalized fine-tuning, the system not only learns basic patterns using general data but also quickly adapts to the unique physiological response characteristics of users in the early stages of use. Through weighted clustering learning of historical intervention segments using an autoencoder, the system can automatically extract and solidify music parameter combinations under different HRV scenarios in the latent space, forming an ever-evolving scenario-response mapping map. This enables the system to continuously self-optimize; as usage time increases, its recommended music parameters will increasingly align with the user's personal preferences and physiological feedback, truly achieving a personalized experience that becomes more accurate with use.

[0113] By explicitly defining HRV convergence slope as the core quantitative indicator, the response characteristics of the autonomic nervous system during intervention are quantified by comparing the short-term RMSSD change trends before and after intervention. This indicator is not used to "verify" the effectiveness of the current intervention, but rather as an effect feature label. It is stored in the log database along with the initial HRV state at the time of intervention and the music parameters used, and is used as sample weights in subsequent clustering learning, so that intervention segments with better effects have a higher contribution to strategy optimization. This feedback directly participates in the autoencoder clustering learning of the strategy optimization stage, ensuring that every intervention attempt, regardless of its effect, provides valuable data input for the iteration of the system strategy, forming a virtuous cycle of "record-driven optimization".

[0114] By adopting a distributed system architecture, the entire intervention process is fully automated, requiring no active reporting or operation from the user. The system initiates precise intervention before the user even notices their emotional fluctuations, achieving seamless health support. For scenarios involving emotional fluctuations such as anxiety and acute stress, the system demonstrates advantages in rapid response and stable regulation, effectively compensating for the shortcomings of traditional methods in such scenarios, such as slow response and rigid adaptation. This greatly expands the universality and reliability of music therapy in real-world scenarios such as daily life, the workplace, and medical assistance.

[0115] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A music therapy response method incorporating real-time optimization of heart rate variability, characterized in that, Includes the following steps: S1. The user's electrocardiogram signal is continuously collected through a wearable physiological sensing unit, and the time-domain, frequency-domain and nonlinear feature parameters of heart rate variability are extracted to construct a multidimensional dynamic representation vector of HRV; wherein, the nonlinear feature parameters include at least sample entropy and approximate entropy, which are used to quantify the complexity of the autonomic nervous system. S2. Based on the low-frequency power LF and high-frequency power HF sequences in the HRV multidimensional dynamic representation vector, the autonomic nervous balance index representing the sympathetic-parasympathetic nerve coupling relationship is calculated using the sliding window covariance analysis method. When the autonomic nervous balance index is lower than the preset individualized threshold for three consecutive sliding windows, it is determined that the user has entered the emotion regulation sensitive window. The individualized threshold is set based on the distribution of HRV data in the user's historical resting state. S3. Within the sensitive window of emotion regulation, the sampling and update period of the HRV multidimensional dynamic representation vector is switched to 100ms. After continuous updating, it is input into the pre-trained HRV-music feature mapping network to output the currently recommended rhythm rate, mode type, timbre distribution and sound field width parameters. S4. Based on the output music parameters, the audio synthesis engine generates or adjusts the intervention audio stream that is playing in real time, and simultaneously records the RR interval sequence from the 1st to the 6th second after the opening of the emotion regulation sensitive window as the HRV response trajectory. S5. Calculate the RMSSD value for the HRV response trajectory every second to form an RMSSD time-series curve. Use the least squares method to fit the HRV convergence slope. Associate the HRV convergence slope with the music parameters used in the current intervention and the initial HRV state, and store it in the intervention log database as a quantitative indicator of the intervention effect. S6. Periodically extract intervention segments from the intervention log database, concatenate the initial HRV state, corresponding music parameters, and HRV convergence slope into a joint vector, compress it into the latent space through an autoencoder, perform weighted clustering with the HRV convergence slope as the clustering weight, and construct a context-response mapping map, which is used for parameter initialization and fast convergence guidance of the HRV-music feature mapping network in the next round of intervention.

2. The music therapy response method combining real-time optimization of heart rate variability according to claim 1, characterized in that: The HRV multidimensional dynamic representation vector includes the following eight features: The root mean square (RMSSD) of the difference between adjacent RR intervals, the standard deviation (SDNN) of all RR intervals, low-frequency power (LF), high-frequency power (HF), LF / HF ratio, standard deviations (SD1 and SD2) of the Poincaré scatter plot, sample entropy and approximate entropy; The wearable physiological sensing unit is a three-lead ECG patch sensor that acquires raw electrocardiogram signals at a sampling rate of 1000Hz and performs R-wave detection and RR interval sequence extraction through an embedded microcontroller.

3. The music therapy response method combining real-time optimization of heart rate variability as described in claim 1, characterized in that: The sliding window covariance analysis method uses a sliding window with a length of 60 seconds and a step size of 5 seconds to calculate the covariance of the LF power and HF power sequences, thereby obtaining the autonomic nervous system balance index.

4. The music therapy response method combining real-time optimization of heart rate variability as described in claim 1, characterized in that: The HRV-music feature mapping network is a three-layer fully connected neural network. The input layer receives 8-dimensional HRV features, the hidden layer contains 64 ReLU activation units, and the output layer contains four independent sub-output layers, corresponding to four types of parameters: tempo, mode type, timbre distribution, and soundstage width. Each sub-output layer is normalized using the Softmax function to obtain a discrete level probability distribution of the corresponding parameter, where: The tempo rate is divided into four levels: 40 BPM, 60 BPM, 80 BPM, and 100 BPM; the mode type is divided into two levels: pentatonic scale and natural major scale; the timbre distribution is divided into three levels: piano-dominant, string-dominant, and ambient white noise-dominant; and the sound field width is divided into two levels: narrow sound field and wide sound field. The HRV-music feature mapping network employs a transfer learning strategy before deployment, pre-training on a public HRV-emotion dataset. Within 72 hours of the user's first use, the weights of the hidden and output layers are fine-tuned based on individual physiological response data to achieve personalized adaptation.

5. The music therapy response method combining real-time optimization of heart rate variability according to claim 1, characterized in that: The audio synthesis engine adopts a hybrid architecture that combines physical modeling synthesis with wavetable sampling playback. It adjusts the beat interval according to the input rhythm rate, switches between pentatonic scales or natural major scales according to the mode type, mixes the audio output of piano, string and ambient white noise sound primitives according to timbre distribution weights, and dynamically adjusts the sound field width through the head-related transfer function (HRTF) algorithm.

6. The music therapy response method combining real-time optimization of heart rate variability according to claim 1, characterized in that: The HRV response trajectory refers to the RR interval sequence from the 1st to the 6th second after the opening of the emotion regulation sensitivity window; the HRV convergence slope is calculated through the following steps: based on the HRV response trajectory, the RMSSD value is calculated once per second to obtain the RMSSD time series curve containing 6 time points; the least squares method is used to linearly fit the time series curve, and the slope of the fitted line is the HRV convergence slope.

7. A music therapy response method combining real-time optimization of heart rate variability according to claim 6, characterized in that: The intervention log database is indexed by timestamps and stores the start time of each intervention, the initial value of the HRV multidimensional dynamic representation vector, the four types of music parameters output, the HRV convergence slope, and the duration.

8. The music therapy response method combining real-time optimization of heart rate variability according to claim 1, characterized in that: The autoencoder includes an encoder and a decoder. The encoder consists of three fully connected layers that compress the HRV-music parameter-convergence slope joint vector into an 8-dimensional latent space representation. The decoder consists of three fully connected layers that reconstruct the original joint vector through fully connected operations. The context-response mapping map forms multiple high-density regions by weighted clustering of intervention fragments in the latent space, with each region center corresponding to a combination of music parameters under a typical HRV context.

9. A music therapy response system that incorporates real-time optimization based on heart rate variability, characterized in that, include: The physiological signal acquisition unit is configured to acquire the user's electrocardiogram signal at a sampling rate of 1000Hz through a three-lead ECG patch sensor and output the RR interval sequence; The HRV feature extraction unit is connected to the physiological signal acquisition unit and is used to calculate eight HRV features, including RMSSD, SDNN, LF power, HF power, LF / HF ratio, SD1 and SD2 of Poincaré scatter plot, sample entropy and approximate entropy, to form a multidimensional dynamic representation vector of HRV. The emotion window detection unit, connected to the HRV feature extraction unit, is used to calculate the autonomic nervous balance index from the LF power and HF power sequences using the sliding window covariance analysis method, and to trigger the emotion regulation sensitive window signal when the sliding window is lower than the preset individualized threshold for three consecutive sliding windows. The music parameter generation unit has a built-in HRV-music feature mapping network and is connected to the emotion window detection unit and the HRV feature extraction unit. It is used to receive the HRV multidimensional dynamic representation vector with a period of 100ms after receiving the emotion regulation sensitive window signal and output the rhythm rate, mode type, timbre distribution and sound field width parameters. The real-time audio synthesis unit is connected to the music parameter generation unit and is used to generate or adjust the intervention audio stream according to the music parameters using a hybrid architecture of physical modeling and wavetable synthesis. The intervention effect recording unit is connected to the physiological signal acquisition unit and the audio real-time synthesis unit. It is used to record the RR interval sequence from the 1st to the 6th second after the opening of the emotion regulation sensitive window, calculate the HRV convergence slope, and store the intervention start time, HRV initial vector, output music parameters, HRV convergence slope and duration as structured records in the intervention log database. An intervention log database, connected to the intervention effect recording unit, is used to store the intervention start time, the initial value of the HRV multidimensional dynamic representation vector, music parameters, HRV convergence slope, and duration. The strategy optimization unit, connected to the intervention log database and the music parameter generation unit, is used to periodically extract intervention segments, compress the joint vector of HRV initial vector, music parameters and HRV convergence slope into the latent space through an autoencoder, perform weighted clustering with HRV convergence slope as the clustering weight, construct a context-response mapping map, and feed it back to the music parameter generation unit to optimize subsequent intervention parameters.

10. A music therapy response system combining real-time optimization of heart rate variability according to claim 9, characterized in that: The simplified version of the HRV feature extraction unit and emotion window detection unit is deployed on the wearable device to calculate HRV features in real time and perform preliminary window detection; when a potential emotion regulation sensitive window is detected, high-frequency HRV data is uploaded to the mobile terminal or cloud server. The music parameter generation unit, real-time audio synthesis unit, intervention effect recording unit, and strategy optimization unit are deployed on mobile terminals or cloud servers.