CN102064832A - Implementation method for changing vibration effect with music - Google Patents

Implementation method for changing vibration effect with music Download PDF

Info

Publication number
CN102064832A
CN102064832A CN2010105465505A CN201010546550A CN102064832A CN 102064832 A CN102064832 A CN 102064832A CN 2010105465505 A CN2010105465505 A CN 2010105465505A CN 201010546550 A CN201010546550 A CN 201010546550A CN 102064832 A CN102064832 A CN 102064832A
Authority
CN
China
Prior art keywords
maxv
pcm
subcount
level
amplitude
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN2010105465505A
Other languages
Chinese (zh)
Other versions
CN102064832B (en
Inventor
苏豫
杨晨鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN 201010546550 priority Critical patent/CN102064832B/en
Publication of CN102064832A publication Critical patent/CN102064832A/en
Application granted granted Critical
Publication of CN102064832B publication Critical patent/CN102064832B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Electrophonic Musical Instruments (AREA)

Abstract

一种随音乐变化振动效果的实现方法,采用分析脉码调制PCM数据的方法,根据音量的大小、变化的强弱及频率来计算马达的强弱继而驱动马达振动。由于对声音变化起主要作用的音源相同,所以一个周期内大多数声音都是同一个频率,因此用一个周期内回到原轨的个数,以及每个波形跨过原轨所用的时间,来推算当前的音源频率;过滤掉幅度不高,频率很高的杂波;最后再根据微调得出音乐的变化节奏,对人耳的影响进行最终振幅增强或者衰减,对马达特性进行细节调试,根据某个区间内的幅度进行增强、衰减或者突变,输出电压驱动马达,使得带有音乐播放功能的电子产品根据音乐节奏变化有节奏的振动,带给人们愉快的体验。

Figure 201010546550

A method for realizing the vibration effect changing with the music, adopting the method of analyzing pulse code modulation PCM data, calculating the strength of the motor according to the size of the volume, the strength of the change and the frequency, and then driving the motor to vibrate. Since the sound source that plays a major role in the sound change is the same, most of the sounds in a cycle are of the same frequency, so the number of returning to the original track in a cycle and the time it takes for each waveform to cross the original track are used to calculate Estimate the current frequency of the sound source; filter out the clutter with low amplitude and high frequency; finally obtain the changing rhythm of the music according to the fine-tuning, perform final amplitude enhancement or attenuation on the impact on the human ear, and perform detailed debugging on the motor characteristics, according to The amplitude in a certain range is enhanced, attenuated or mutated, and the output voltage drives the motor, making electronic products with music playback function vibrate rhythmically according to the rhythm of the music, bringing people a pleasant experience.

Figure 201010546550

Description

一种随音乐变化振动效果的实现方法 A Realization Method of Vibration Effect Changing with Music

技术领域technical field

本发明涉及一种振动实现方法,特别是涉及一种随音乐变化振动效果的实现方法。The invention relates to a method for realizing vibration, in particular to a method for realizing a vibration effect changing with music.

背景技术:Background technique:

目前带有播放音乐功能的电子产品,如手机、MP3、MP4等,此类电子产品的振动功能应用越来越广泛,有些振动利用音箱实现,有些振动利用马达实现,而随着技术的发展,越来越多的生产商选择采用马达代替音箱进行硬件电路的设计。At present, electronic products with the function of playing music, such as mobile phones, MP3, MP4, etc., the vibration function of such electronic products is more and more widely used. Some vibrations are realized by speakers, and some vibrations are realized by motors. With the development of technology, More and more manufacturers choose to use motors instead of speakers for hardware circuit design.

但现在用马达来驱动振动的电子产品在实现振动方面只是单纯的重复节奏的振动,并不能根据音频文件中的振动节奏驱动电子产品进行有节奏的振动,不能满足人们对于不同音乐不同振动节奏的要求。However, electronic products that use motors to drive vibrations are only simple repetitive rhythmic vibrations in terms of vibration, and cannot drive electronic products to perform rhythmic vibrations according to the vibration rhythm in audio files, and cannot satisfy people's needs for different vibration rhythms of different music. Require.

发明内容:Invention content:

本发明的目的在于克服现有技术的不足,提供一种随音乐变化振动效果的实现方法,用于所有带有播放音乐功能的电子产品,在音频文件解码之后而未进行数字/模拟转换之前对中断进行分析,采用分析脉码调制PCM(英文Pulse Code Modulation的缩写)数据的方法,根据音量的大小,以及变化的强弱和各频率给人耳带来感觉体验的不同,来计算马达的强弱继而驱动马达振动,使得电子产品根据音乐节奏变化有节奏的振动,带给人们愉快的体验。The purpose of the present invention is to overcome the deficiencies in the prior art, to provide a method for realizing the vibration effect changing with the music, which is used for all electronic products with the function of playing music, after the audio file is decoded but not before digital/analog conversion Interrupt analysis, using the method of analyzing pulse code modulation PCM (abbreviation of English Pulse Code Modulation) data, according to the size of the volume, the strength of the change and the difference in the sensory experience of each frequency to the human ear, to calculate the strength of the motor Weakness then drives the motor to vibrate, making electronic products vibrate rhythmically according to the rhythm of the music, bringing people a pleasant experience.

为了达到上述目的,本发明采用的技术方案是,一种随音乐变化振动效果的实现方法,有两种方案实现:方案一为判断PCM_Level_L大于零计数,小于零中断后开始分析一个周期的信息情况;方案二为判断PCM_Level_L小于零计数,大于零中断后开始分析一个周期的信息情况。In order to achieve the above object, the technical solution adopted in the present invention is a method for realizing the vibration effect changing with the music, and there are two kinds of schemes to realize: scheme one is to judge that PCM_Level_L is greater than zero count, and start to analyze the information situation of a period after the interruption of less than zero ; The second scheme is to judge that the count of PCM_Level_L is less than zero, and start to analyze the information of a period after the interrupt is greater than zero.

方案一的步骤如下:The steps of option one are as follows:

该方法涉及以下数据,周期为T,从PCM缓冲器中读取的PCM数据用PCM_Level_L来表示,一个周期内采样点的数量为SubCount,SubCount的最大值为MaxSubCount,一个中断中幅度最大值MaxV_tmp,幅度参考值设置为常数VLowLimit,采样点参考值设置为常数FLowLimit,一个采样周期内所有中断点幅度的最大值为MaxV,有效周期个数即频率为ICount,设幅度最小参考值为MinV_T,采样周期的时间由实现着根据产品特性设定。This method involves the following data, the cycle is T, the PCM data read from the PCM buffer is represented by PCM_Level_L, the number of sampling points in one cycle is SubCount, the maximum value of SubCount is MaxSubCount, and the maximum value of the amplitude in an interrupt is MaxV_tmp, The amplitude reference value is set to a constant VLowLimit, the sampling point reference value is set to a constant FLowLimit, the maximum value of the amplitude of all interruption points within a sampling period is MaxV, the number of effective periods is ICount, the minimum reference value of the amplitude is MinV_T, and the sampling period The time is set by the implementer according to the product characteristics.

步骤1、对音频文件解码后未在PCM数据转化成最终声音模拟波形前,截取PCM的数据,从PCM缓冲器中读每个PCM_Level_L;Step 1, after the audio file is decoded, the PCM data is intercepted before the PCM data is converted into the final sound analog waveform, and each PCM_Level_L is read from the PCM buffer;

步骤2、判断PCM_Level_L是否大于零;Step 2, determine whether PCM_Level_L is greater than zero;

步骤3、PCM_Level_L>0,则执行步骤3.1,PCM_Level_L≤0,则执行步骤3.2;Step 3, PCM_Level_L>0, then execute step 3.1, PCM_Level_L≤0, then execute step 3.2;

步骤3.1、PCM_Level_L>0,则开始计数,得到一个子周期内采样点的数量SubCount,并记下此时的幅度最大值MaxV_tmp,跳至步骤5;Step 3.1, PCM_Level_L>0, start counting, get the number of sampling points SubCount in a sub-period, and record the maximum amplitude MaxV_tmp at this time, skip to step 5;

步骤3.2、PCM_Level_L≤0,则开始分析一个中断读取PCM缓冲器中正幅度的SubCount和MaxV_tmp,并执行步骤4;Step 3.2, PCM_Level_L≤0, start to analyze an interrupt to read SubCount and MaxV_tmp with positive amplitude in the PCM buffer, and execute step 4;

步骤4、同时满足SubCount<FLowLimit,MaxV_tmp<VLowLimit的,则判断为高频噪声并过滤掉,不进行统计,为无效周期,统计出SubCount、MaxV_tmp的最大值;Step 4. If SubCount<FLowLimit and MaxV_tmp<VLowLimit are satisfied at the same time, it is judged as high-frequency noise and filtered out, no statistics are performed, it is an invalid period, and the maximum values of SubCount and MaxV_tmp are counted;

步骤5、统计出一个采样周期MaxV_tmp的最大值MaxV,SubCount中的最大值MaxSubCount,并统计出一个采样周期内的MaxV、MaxSubCount,并统计出有效周期ICount的数量;Step 5, count the maximum value MaxV of a sampling period MaxV_tmp, the maximum value MaxSubCount in SubCount, and count the MaxV and MaxSubCount in a sampling period, and count the number of valid period ICount;

步骤6、比较一个采样周期内前后两次采样得到的最大值MaxV,设差值为MaxV_L;Step 6. Comparing the maximum value MaxV obtained by two samples before and after one sampling period, and setting the difference as MaxV_L;

步骤7、判断MaxV_L是否小于-MinV_T;Step 7, judging whether MaxV_L is less than -MinV_T;

步骤8、MaxV_L<-MinV_T,则执行步骤8.1,MaxV_L≥-MinV_T,则执行步骤8.2;Step 8, MaxV_L<-MinV_T, then perform step 8.1, MaxV_L≥-MinV_T, then perform step 8.2;

步骤8.1、MaxV_L<-MinV_T,则直接设MaxV_L=0,马达停止振动;Step 8.1, MaxV_L<-MinV_T, then directly set MaxV_L=0, the motor stops vibrating;

步骤8.2、MaxV_L≥-MinV_T,则执行步骤9;Step 8.2, MaxV_L≥-MinV_T, then execute step 9;

步骤9、程序结束,继续进行下一轮判断。Step 9, the program ends, and the next round of judgment is continued.

上述步骤1中的音频文件指现有格式的音频文件,如mp3文件、wav文件、wma文件、midi文件、winamp等。The audio file in the above step 1 refers to an audio file in an existing format, such as mp3 file, wav file, wma file, midi file, winamp, etc.

方案二的步骤如下:The steps of option 2 are as follows:

该方法涉及以下数据,周期为T,从PCM缓冲器中读取的PCM数据用PCM_Level_L来表示,每当一个采样点由正转负为一个采样子周期,子周期内采样点的数量为SubCount,SubCount的最大值为MaxSubCount,一个中断中幅度最大值MaxV_tmp,幅度参考值设置为常数VLowLimit,采样点参考值设置为常数FLowLimit,一个周期内所有中断点幅度的最大值为MaxV,有效周期即频率为ICount,设幅度最小参考值为MinV_TThis method involves the following data, the period is T, and the PCM data read from the PCM buffer is represented by PCM_Level_L. Whenever a sampling point is changed from positive to negative, it is a sampling sub-period, and the number of sampling points in the sub-period is SubCount. The maximum value of SubCount is MaxSubCount, the maximum value of the amplitude in an interrupt is MaxV_tmp, the amplitude reference value is set to the constant VLowLimit, the sampling point reference value is set to the constant FLowLimit, the maximum value of the amplitude of all interrupt points in one cycle is MaxV, and the effective cycle is the frequency ICount, set the amplitude minimum reference value to MinV_T

步骤1、对音频文件解码后未在PCM数据转化成最终声音模拟波形前,截取PCM的数据,从PCM缓冲器中读每个PCM_Level_L;Step 1, after the audio file is decoded, the PCM data is intercepted before the PCM data is converted into the final sound analog waveform, and each PCM_Level_L is read from the PCM buffer;

步骤2、判断PCM_Level_L是否小于零;Step 2, judging whether PCM_Level_L is less than zero;

步骤3、PCM_Level_L<0,则执行步骤3.1,PCM_Level_L≥0,则执行步骤3.2;Step 3, PCM_Level_L<0, then execute step 3.1, PCM_Level_L≥0, then execute step 3.2;

步骤3.1、PCM_Level_L<0,则开始计数,得到一个周期内采样点的数量SubCount,并记下此时的幅度最大值MaxV_tmp,跳至步骤5;Step 3.1, PCM_Level_L<0, start counting, get the number of sampling points SubCount in one cycle, and write down the maximum amplitude MaxV_tmp at this time, skip to step 5;

步骤3.2、PCM_Level_L≥0,则开始分析一个中断读取PCM缓冲器中负幅度的SubCount和MaxV_tmp,并执行步骤4;Step 3.2, PCM_Level_L≥0, then start to analyze an interrupt to read SubCount and MaxV_tmp with negative amplitude in the PCM buffer, and execute step 4;

步骤4、同时满足SubCount<FLowLimit,MaxV_tmp<VLowLimit的,则判断为高频噪声并过滤掉,不进行统计,为无效周期,统计出SubCount、MaxV_tmp的最大值;Step 4. If SubCount<FLowLimit and MaxV_tmp<VLowLimit are satisfied at the same time, it is judged as high-frequency noise and filtered out, no statistics are performed, it is an invalid period, and the maximum values of SubCount and MaxV_tmp are counted;

步骤5、统计出一个采样周期内MaxV_tmp的最大值MaxV,SubCount中的最大值MaxSubCount,并统计出一个周期内的MaxV、MaxSubCount,并统计出有效周期ICount的数量;Step 5, count the maximum value MaxV of MaxV_tmp in a sampling cycle, the maximum value MaxSubCount in SubCount, and count MaxV, MaxSubCount in a cycle, and count the number of effective cycle ICount;

步骤6、比较一个采样周期内前后两次采样得到的最大值MaxV,设差值为MaxV_L;Step 6. Comparing the maximum value MaxV obtained by two samples before and after one sampling period, and setting the difference as MaxV_L;

步骤7、判断MaxV_L是否小于-MinV_T;Step 7, judging whether MaxV_L is less than -MinV_T;

步骤8、MaxV_L<-MinV_T,则执行步骤8.1,MaxV_L≥-MinV_T,则执行步骤8.2;Step 8, MaxV_L<-MinV_T, then perform step 8.1, MaxV_L≥-MinV_T, then perform step 8.2;

步骤8.1、MaxV_L<-MinV_T,则直接设MaxV_L=0,马达停止振动;Step 8.1, MaxV_L<-MinV_T, then directly set MaxV_L=0, the motor stops vibrating;

步骤8.2、MaxV_L≥-MinV_T,则执行步骤9;Step 8.2, MaxV_L≥-MinV_T, then execute step 9;

步骤9、程序结束,进行下一轮判断。Step 9, the program ends, and the next round of judgment is performed.

上述步骤1中的音频文件指现有格式的音频文件,如mp3文件、wav文件、wma文件、midi文件、winamp等。The audio file in the above step 1 refers to an audio file in an existing format, such as mp3 file, wav file, wma file, midi file, winamp, etc.

以上方法用于所有带有播放音乐功能的电子产品,能同时分析左右声道,也能单独分析左右声道、立体声。The above method is applicable to all electronic products with the function of playing music, which can analyze the left and right sound channels at the same time, and can also analyze the left and right sound channels and stereo sound separately.

与现有技术相比,本发明的有益效果是:采用PCM数据的方法,根据音量的大小,以及变化的强弱和各频率给人耳带来感觉体验的不同,来计算马达的强弱继而驱动马达振动,使得电子产品根据音乐节奏变化有节奏的振动,带给人们愉快的体验,另外本发明只是针对PCM数据进行分析,不受电子产品中的平台的限制。Compared with the prior art, the beneficial effect of the present invention is: adopt the method of PCM data, according to the size of volume, and the intensity of change and the difference of sensory experience that each frequency brings to human ear, calculate the intensity of motor and then Driving the motor to vibrate makes the electronic product vibrate rhythmically according to the rhythm of the music, bringing people a pleasant experience. In addition, the present invention only analyzes the PCM data and is not limited by the platform of the electronic product.

附图说明:Description of drawings:

图1为本发明的实施例1的程序流程图;Fig. 1 is the program flowchart of embodiment 1 of the present invention;

图2为本发明的实施例2的程序流程图。Fig. 2 is a program flow chart of Embodiment 2 of the present invention.

具体实施方式:Detailed ways:

本发明的中心思想在于克服现有技术的不足,提供一种随音乐变化振动效果的实现方法,采用分析脉码调制PCM数据的方法,根据音量的大小,以及变化的强弱和各频率给人耳带来感觉体验的不同,来计算马达的强弱继而驱动马达振动,使得电子产品根据音乐节奏变化有节奏的振动。下面结合实施例参照附图进行详细说明,以便对本发明的技术特征及优点进行更深入的诠释。The central idea of the present invention is to overcome the deficiencies of the prior art, and provide a method for realizing the vibration effect changing with the music, adopting the method of analyzing the pulse code modulation PCM data, according to the size of the volume, and the strength of the change and each frequency to give people The difference in the sensory experience of the ear straps is used to calculate the strength of the motor and then drive the motor to vibrate, making the electronic product vibrate rhythmically according to the rhythm of the music. The following will describe in detail with reference to the accompanying drawings in conjunction with the embodiments, so as to further explain the technical features and advantages of the present invention.

一种随音乐变化振动效果的实现方法,有两种方案实现:方案一为判断PCM_Level_L大于零计数,小于零中断后开始分析一个周期的信息情况;方案二为判断PCM_Level_L小于零计数,大于零中断后开始分析一个周期的信息情况。A method to realize the vibration effect changing with the music, there are two schemes to realize: Scheme 1 is to judge that PCM_Level_L is greater than zero count, and if it is less than zero, start to analyze the information of a cycle; scheme 2 is to judge that PCM_Level_L is less than zero count, and greater than zero to interrupt Then start to analyze the information situation of a cycle.

实施例1Example 1

本发明的程序流程图如图1所示,一种随音乐变化振动效果的实现方法,其步骤如下:The program flow chart of the present invention is as shown in Figure 1, a kind of realization method that changes vibration effect with music, and its steps are as follows:

该方法涉及以下数据,周期为T,从PCM缓冲器中读取的PCM数据用PCM_Level_L来表示,一个周期内采样点的数量为SubCount,SubCount的最大值为MaxSubCount,一个中断中幅度最大值MaxV_tmp,幅度参考值设置为常数VLowLimit,采样点参考值设置为常数FLowLimit,一个采样周期内所有中断点幅度的最大值为MaxV,有效周期个数即频率为ICount,设幅度最小参考值为MinV_T,采样周期的时间由实现着根据产品特性设定。This method involves the following data, the cycle is T, the PCM data read from the PCM buffer is represented by PCM_Level_L, the number of sampling points in one cycle is SubCount, the maximum value of SubCount is MaxSubCount, and the maximum value of the amplitude in an interrupt is MaxV_tmp, The amplitude reference value is set to a constant VLowLimit, the sampling point reference value is set to a constant FLowLimit, the maximum value of the amplitude of all interruption points within a sampling period is MaxV, the number of effective periods is ICount, the minimum reference value of the amplitude is MinV_T, and the sampling period The time is set by the implementer according to the product characteristics.

步骤1、对音频文件解码后未在PCM数据转化成最终声音模拟波形前,截取PCM的数据,从PCM缓冲器中读每个PCM_Level_L;Step 1, after the audio file is decoded, the PCM data is intercepted before the PCM data is converted into the final sound analog waveform, and each PCM_Level_L is read from the PCM buffer;

步骤2、判断PCM_Level_L是否大于零;Step 2, determine whether PCM_Level_L is greater than zero;

步骤3、PCM_Level_L>0,则执行步骤3.1,PCM_Level_L≤0,则执行步骤3.2;Step 3, PCM_Level_L>0, then execute step 3.1, PCM_Level_L≤0, then execute step 3.2;

步骤3.1、PCM_Level_L>0,则开始计数,得到一个子周期内采样点的数量SubCount,并记下此时的幅度最大值MaxV_tmp,跳至步骤5;Step 3.1, PCM_Level_L>0, start counting, get the number of sampling points SubCount in a sub-period, and record the maximum amplitude MaxV_tmp at this time, skip to step 5;

步骤3.2、PCM_Level_L≤0,则开始分析一个中断读取PCM缓冲器中正幅度的SubCount和MaxV_tmp,并执行步骤4;Step 3.2, PCM_Level_L≤0, start to analyze an interrupt to read SubCount and MaxV_tmp with positive amplitude in the PCM buffer, and execute step 4;

步骤4、同时满足SubCount<FLowLimit,MaxV_tmp<VLowLimit的,则判断为高频噪声并过滤掉,不进行统计,为无效周期,统计出SubCount、MaxV_tmp的最大值;Step 4. If SubCount<FLowLimit and MaxV_tmp<VLowLimit are satisfied at the same time, it is judged as high-frequency noise and filtered out, no statistics are performed, it is an invalid period, and the maximum values of SubCount and MaxV_tmp are counted;

步骤5、统计出一个采样周期MaxV_tmp的最大值MaxV,SubCount中的最大值MaxSubCount,并统计出一个采样周期内的MaxV、MaxSubCount,并统计出有效周期ICount的数量;Step 5, count the maximum value MaxV of a sampling period MaxV_tmp, the maximum value MaxSubCount in SubCount, and count the MaxV and MaxSubCount in a sampling period, and count the number of valid period ICount;

步骤6、比较一个采样周期内前后两次采样得到的最大值MaxV,设差值为MaxV_L;Step 6. Comparing the maximum value MaxV obtained by two samples before and after one sampling period, and setting the difference as MaxV_L;

步骤7、判断MaxV_L是否小于-MinV_T;Step 7, judging whether MaxV_L is less than -MinV_T;

步骤8、MaxV_L<-MinV_T,则执行步骤8.1,MaxV_L≥-MinV_T,则执行步骤8.2;Step 8, MaxV_L<-MinV_T, then perform step 8.1, MaxV_L≥-MinV_T, then perform step 8.2;

步骤8.1、MaxV_L<-MinV_T,则直接设MaxV_L=0,马达停止振动;Step 8.1, MaxV_L<-MinV_T, then directly set MaxV_L=0, the motor stops vibrating;

步骤8.2、MaxV_L≥-MinV_T,则执行步骤9;Step 8.2, MaxV_L≥-MinV_T, then execute step 9;

步骤9、程序结束,继续进行下一轮判断。Step 9, the program ends, and the next round of judgment is continued.

上述步骤1中的音频文件指现有格式的音频文件,如mp3文件、wav文件、wma文件、midi文件、winamp等。The audio file in the above step 1 refers to an audio file in an existing format, such as mp3 file, wav file, wma file, midi file, winamp, etc.

实施例2Example 2

该方法也适用于判断PCM_Level_L小于零时的计数,PCM_Level_L大于零时中断分析一个周期的信息,其软件流程图如图2所示,步骤如下:This method is also suitable for judging the count when PCM_Level_L is less than zero, and when PCM_Level_L is greater than zero, stop analyzing the information of one cycle. The software flow chart is shown in Figure 2, and the steps are as follows:

该方法涉及以下数据,周期为T,从PCM缓冲器中读取的PCM数据用PCM_Level_L来表示,一个周期内采样点的数量为SubCount,SubCount的最大值为MaxSubCount,一个中断中幅度最大值MaxV_tmp,幅度参考值设置为常数VLowLimit,采样点参考值设置为常数FLowLimit,一个采样周期内所有中断点幅度的最大值为MaxV,有效周期个数即频率为ICount,设幅度最小参考值为MinV_T,采样周期的时间由实现着根据产品特性设定。This method involves the following data, the cycle is T, the PCM data read from the PCM buffer is represented by PCM_Level_L, the number of sampling points in one cycle is SubCount, the maximum value of SubCount is MaxSubCount, and the maximum value of the amplitude in an interrupt is MaxV_tmp, The amplitude reference value is set to a constant VLowLimit, the sampling point reference value is set to a constant FLowLimit, the maximum value of the amplitude of all interruption points within a sampling period is MaxV, the number of effective periods is ICount, the minimum reference value of the amplitude is MinV_T, and the sampling period The time is set by the implementer according to the product characteristics.

步骤1、对音频文件解码后未在PCM数据转化成最终声音模拟波形前,截取PCM的数据,从PCM缓冲器中读每个PCM_Level_L;Step 1, after the audio file is decoded, the PCM data is intercepted before the PCM data is converted into the final sound analog waveform, and each PCM_Level_L is read from the PCM buffer;

步骤2、判断PCM_Level_L是否小于零;Step 2, judging whether PCM_Level_L is less than zero;

步骤3、PCM_Level_L<0,则执行步骤3.1,PCM_Level_L≥0,则执行步骤3.2;Step 3, PCM_Level_L<0, then execute step 3.1, PCM_Level_L≥0, then execute step 3.2;

步骤3.1、PCM_Level_L<0,则开始计数,得到一个周期内采样点的数量SubCount,并记下此时的幅度最大值MaxV_tmp,跳至步骤5;Step 3.1, PCM_Level_L<0, start counting, get the number of sampling points SubCount in one cycle, and write down the maximum amplitude MaxV_tmp at this time, skip to step 5;

步骤3.2、PCM_Level_L≥0,则开始分析一个中断读取PCM缓冲器中负幅度的SubCount和MaxV_tmp,并执行步骤4;Step 3.2, PCM_Level_L≥0, then start to analyze an interrupt to read SubCount and MaxV_tmp with negative amplitude in the PCM buffer, and execute step 4;

步骤4、同时满足SubCount<FLowLimit,MaxV_tmp<VLowLimit的,则判断为高频噪声并过滤掉,不进行统计,为无效周期,统计出SubCount、MaxV_tmp的最大值;Step 4. If SubCount<FLowLimit and MaxV_tmp<VLowLimit are satisfied at the same time, it is judged as high-frequency noise and filtered out, no statistics are performed, it is an invalid period, and the maximum values of SubCount and MaxV_tmp are counted;

步骤5、统计出一个采样周期内MaxV_tmp的最大值MaxV,SubCount中的最大值MaxSubCount,并统计出一个周期内的MaxV、MaxSubCount,并统计出有效周期ICount的数量;Step 5, count the maximum value MaxV of MaxV_tmp in a sampling cycle, the maximum value MaxSubCount in SubCount, and count MaxV, MaxSubCount in a cycle, and count the number of effective cycle ICount;

步骤6、比较一个采样周期内前后两次采样得到的最大值MaxV,设差值为MaxV_L;Step 6. Comparing the maximum value MaxV obtained by two samples before and after one sampling period, and setting the difference as MaxV_L;

步骤7、判断MaxV_L是否小于-MinV_T;Step 7, judging whether MaxV_L is less than -MinV_T;

步骤8、MaxV_L<-MinV_T,则执行步骤8.1,MaxV_L≥-MinV_T,则执行步骤8.2;Step 8, MaxV_L<-MinV_T, then perform step 8.1, MaxV_L≥-MinV_T, then perform step 8.2;

步骤8.1、MaxV_L<-MinV_T,则直接设MaxV_L=0,马达停止振动;Step 8.1, MaxV_L<-MinV_T, then directly set MaxV_L=0, the motor stops vibrating;

步骤8.2、MaxV_L≥-MinV_T,则执行步骤9;Step 8.2, MaxV_L≥-MinV_T, then execute step 9;

步骤9、程序结束,进行下一轮判断。Step 9, the program ends, and the next round of judgment is performed.

上述步骤1中的音频文件指现有格式的音频文件,如mp3文件、wav文件、wma文件、midi文件、winamp等。The audio file in the above step 1 refers to an audio file in an existing format, such as mp3 file, wav file, wma file, midi file, winamp, etc.

在具体工作时,采用分析脉码调制PCM数据的方法,根据音量的大小,以及变化的强弱和各频率给人耳带来感觉体验的不同,来计算马达的强弱继而驱动马达振动。由于对声音变化起主要作用的音源相同,所以一个周期内大多数声音都是同一个频率,因此用一个周期内回到原轨的个数,以及每个波形跨过原轨所用的时间,来推算当前的音源频率;过滤掉幅度不高,频率很高的杂波;最后再根据微调得出音乐的变化节奏,对人耳的影响进行最终振幅增强或者衰减,对马达特性进行细节调试,根据某个区间内的幅度进行增强、衰减或者突变,输出电压驱动马达,使得带有音乐播放功能的电子产品根据音乐节奏变化有节奏的振动,带给人们愉快的体验。In the specific work, the method of analyzing the pulse code modulation PCM data is used to calculate the strength of the motor and then drive the motor to vibrate according to the volume, the strength of the change, and the difference in sensory experience brought to the ear by each frequency. Since the sound source that plays a major role in the sound change is the same, most of the sounds in a cycle are of the same frequency, so the number of returning to the original track in a cycle and the time it takes for each waveform to cross the original track are used to calculate Estimate the current frequency of the sound source; filter out the clutter with low amplitude and high frequency; finally obtain the changing rhythm of the music according to the fine-tuning, perform final amplitude enhancement or attenuation on the impact on the human ear, and perform detailed debugging on the motor characteristics, according to The amplitude in a certain range is enhanced, attenuated or mutated, and the output voltage drives the motor, so that the electronic product with music playback function vibrates rhythmically according to the rhythm of the music, bringing people a pleasant experience.

尽管本发明通过具体实施例对随音乐变化振动效果的实现方法作出了清晰而完整的描述,但是本发明不仅仅限于所述实施例,通过简单的数据或程序变动来达到随音乐变化振动效果的目的是可能发生的并且都包括在本发明之中。Although the present invention has made a clear and complete description of the implementation method of the vibration effect changing with the music through specific embodiments, the present invention is not limited to the embodiments, and the vibration effect changing with the music is achieved through simple data or program changes. Objects are possible and are included in the present invention.

Claims (4)

1.一种随音乐变化振动效果的实现方法,其步骤如下:1. A method for realizing the effect of changing vibrations with music, the steps are as follows: 该方法涉及以下数据,周期为T,从PCM缓冲器中读取的PCM数据用PCM_Level_L来表示,一个周期内采样点的数量为SubCount,SubCount的最大值为MaxSubCount,一个中断中幅度最大值MaxV_tmp,幅度参考值设置为常数VLowLimit,采样点参考值设置为常数FLowLimit,一个采样周期内所有中断点幅度的最大值为MaxV,有效周期个数即频率为ICount,设幅度最小参考值为MinV_T,采样周期的时间由实现着根据产品特性设定This method involves the following data, the cycle is T, the PCM data read from the PCM buffer is represented by PCM_Level_L, the number of sampling points in one cycle is SubCount, the maximum value of SubCount is MaxSubCount, and the maximum value of the amplitude in an interrupt is MaxV_tmp, The amplitude reference value is set to a constant VLowLimit, the sampling point reference value is set to a constant FLowLimit, the maximum value of the amplitude of all interruption points within a sampling period is MaxV, the number of effective periods is ICount, the minimum reference value of the amplitude is MinV_T, and the sampling period The time is set by the implementer according to the product characteristics 步骤1、对音频文件解码后未在PCM数据转化成最终声音模拟波形前,截取PCM的数据,从PCM缓冲器中读每个PCM_Level_L;Step 1, after the audio file is decoded, the PCM data is intercepted before the PCM data is converted into the final sound analog waveform, and each PCM_Level_L is read from the PCM buffer; 步骤2、判断PCM_Level_L是否大于零;Step 2, determine whether PCM_Level_L is greater than zero; 步骤3、PCM_Level_L>0,则执行步骤3.1,PCM_Level_L≤0,则执行步骤3.2;Step 3, PCM_Level_L>0, then execute step 3.1, PCM_Level_L≤0, then execute step 3.2; 步骤3.1、PCM_Level_L>0,则开始计数,得到一个子周期内采样点的数量SubCount,并记下此时的幅度最大值MaxV_tmp,跳至步骤5;Step 3.1, PCM_Level_L>0, start counting, get the number of sampling points SubCount in a sub-period, and record the maximum amplitude MaxV_tmp at this time, skip to step 5; 步骤3.2、PCM_Level_L≤0,则开始分析一个中断读取PCM缓冲器中正幅度的SubCount和MaxV_tmp,并执行步骤4;Step 3.2, PCM_Level_L≤0, start to analyze an interrupt to read SubCount and MaxV_tmp with positive amplitude in the PCM buffer, and execute step 4; 步骤4、同时满足SubCount<FLowLimit,MaxV_tmp<VLowLimit的,则判断为高频噪声并过滤掉,不进行统计,为无效周期,统计出SubCount、MaxV_tmp的最大值;Step 4. If SubCount<FLowLimit and MaxV_tmp<VLowLimit are satisfied at the same time, it is judged as high-frequency noise and filtered out, no statistics are performed, it is an invalid period, and the maximum values of SubCount and MaxV_tmp are counted; 步骤5、统计出一个采样周期MaxV_tmp的最大值MaxV,SubCount中的最大值MaxSubCount,并统计出一个采样周期内的MaxV、MaxSubCount,并统计出有效周期ICount的数量;Step 5, count the maximum value MaxV of a sampling period MaxV_tmp, the maximum value MaxSubCount in SubCount, and count the MaxV and MaxSubCount in a sampling period, and count the number of valid period ICount; 步骤6、比较一个采样周期内前后两次采样得到的最大值MaxV,设差值为MaxV_L;Step 6. Comparing the maximum value MaxV obtained by two samples before and after one sampling period, and setting the difference as MaxV_L; 步骤7、判断MaxV_L是否小于-MinV_T;Step 7, judging whether MaxV_L is less than -MinV_T; 步骤8、MaxV_L<-MinV_T,则执行步骤8.1,MaxV_L≥-MinV_T,则执行步骤8.2;Step 8, MaxV_L<-MinV_T, then perform step 8.1, MaxV_L≥-MinV_T, then perform step 8.2; 步骤8.1、MaxV_L<-MinV_T,则直接设MaxV_L=0,马达停止振动;Step 8.1, MaxV_L<-MinV_T, then directly set MaxV_L=0, the motor stops vibrating; 步骤8.2、MaxV_L≥-MinV_T,则执行步骤9;Step 8.2, MaxV_L≥-MinV_T, then execute step 9; 步骤9、程序结束,继续进行下一轮判断。Step 9, the program ends, and the next round of judgment is continued. 2.根据权利要求1所述的随音乐变化振动效果的实现方法,其特征在于:上述步骤1中的音频文件指现有格式的音频文件。2. The method for realizing the vibration effect changing with music according to claim 1, characterized in that: the audio file in the above step 1 refers to an audio file in an existing format. 3.一种随音乐变化振动效果的实现方法,其特征在于,步骤如下:3. A method for realizing the effect of changing vibrations with music, characterized in that the steps are as follows: 该方法涉及以下数据,周期为T,从PCM缓冲器中读取的PCM数据用PCM_Level_L来表示,一个周期内采样点的数量为SubCount,SubCount的最大值为MaxSubCount,一个中断中幅度最大值MaxV_tmp,幅度参考值设置为常数VLowLimit,采样点参考值设置为常数FLowLimit,一个采样周期内所有中断点幅度的最大值为MaxV,有效周期个数即频率为ICount,设幅度最小参考值为MinV_T,采样周期的时间由实现着根据产品特性设定This method involves the following data, the cycle is T, the PCM data read from the PCM buffer is represented by PCM_Level_L, the number of sampling points in one cycle is SubCount, the maximum value of SubCount is MaxSubCount, and the maximum value of the amplitude in an interrupt is MaxV_tmp, The amplitude reference value is set to a constant VLowLimit, the sampling point reference value is set to a constant FLowLimit, the maximum value of the amplitude of all interruption points within a sampling period is MaxV, the number of effective periods is ICount, the minimum reference value of the amplitude is MinV_T, and the sampling period The time is set by the implementer according to the product characteristics 步骤1、对音频文件解码后未在PCM数据转化成最终声音模拟波形前,截取PCM的数据,从PCM缓冲器中读每个PCM_Level_L;Step 1, after the audio file is decoded, the PCM data is intercepted before the PCM data is converted into the final sound analog waveform, and each PCM_Level_L is read from the PCM buffer; 步骤2、判断PCM_Level_L是否小于零;Step 2, determine whether PCM_Level_L is less than zero; 步骤3、PCM_Level_L<0,则执行步骤3.1,PCM_Level_L≥0,则执行步骤3.2;Step 3, PCM_Level_L<0, then execute step 3.1, PCM_Level_L≥0, then execute step 3.2; 步骤3.1、PCM_Level_L<0,则开始计数,得到一个周期内采样点的数量SubCount,并记下此时的幅度最大值MaxV_tmp,跳至步骤5;Step 3.1, PCM_Level_L<0, start counting, get the number of sampling points SubCount in one cycle, and write down the maximum amplitude MaxV_tmp at this time, skip to step 5; 步骤3.2、PCM_Level_L≥0,则开始分析一个中断读取PCM缓冲器中负幅度的SubCount和MaxV_tmp,并执行步骤4;Step 3.2, PCM_Level_L≥0, then start to analyze an interrupt to read SubCount and MaxV_tmp with negative amplitude in the PCM buffer, and execute step 4; 步骤4、同时满足SubCount<FLowLimit,MaxV_tmp<VLowLimit的,则判断为高频噪声并过滤掉,不进行统计,为无效周期,统计出SubCount、MaxV_tmp的最大值;Step 4. If SubCount<FLowLimit and MaxV_tmp<VLowLimit are satisfied at the same time, it is judged as high-frequency noise and filtered out, no statistics are performed, it is an invalid period, and the maximum values of SubCount and MaxV_tmp are counted; 步骤5、统计出一个采样周期内MaxV_tmp的最大值MaxV,SubCount中的最大值MaxSubCount,并统计出一个周期内的MaxV、MaxSubCount,并统计出有效周期ICount的数量;Step 5, count the maximum value MaxV of MaxV_tmp in a sampling cycle, the maximum value MaxSubCount in SubCount, and count MaxV, MaxSubCount in a cycle, and count the number of effective cycle ICount; 步骤6、比较一个采样周期内前后两次采样得到的最大值MaxV,设差值为MaxV_L;Step 6. Comparing the maximum value MaxV obtained by two samples before and after one sampling period, and setting the difference as MaxV_L; 步骤7、判断MaxV_L是否小于-MinV_T;Step 7, judging whether MaxV_L is less than -MinV_T; 步骤8、MaxV_L<-MinV_T,则执行步骤8.1,MaxV_L≥-MinV_T,则执行步骤8.2;Step 8, MaxV_L<-MinV_T, then perform step 8.1, MaxV_L≥-MinV_T, then perform step 8.2; 步骤8.1、MaxV_L<-MinV_T,则直接设MaxV_L=0,马达停止振动;Step 8.1, MaxV_L<-MinV_T, then directly set MaxV_L=0, the motor stops vibrating; 步骤8.2、MaxV_L≥-MinV_T,则执行步骤9;Step 8.2, MaxV_L≥-MinV_T, then execute step 9; 步骤9、程序结束,进行下一轮判断。Step 9, the program ends, and the next round of judgment is performed. 4.根据权利要求3所述的随音乐变化振动效果的实现方法,其特征在于:上述步骤1中的音频文件指现有格式的音频文件。4. The method for realizing the vibration effect changing with music according to claim 3, characterized in that: the audio file in the above step 1 refers to an audio file in an existing format.
CN 201010546550 2010-11-11 2010-11-11 Implementation method for changing vibration effect with music Expired - Fee Related CN102064832B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201010546550 CN102064832B (en) 2010-11-11 2010-11-11 Implementation method for changing vibration effect with music

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201010546550 CN102064832B (en) 2010-11-11 2010-11-11 Implementation method for changing vibration effect with music

Publications (2)

Publication Number Publication Date
CN102064832A true CN102064832A (en) 2011-05-18
CN102064832B CN102064832B (en) 2013-09-18

Family

ID=43999960

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201010546550 Expired - Fee Related CN102064832B (en) 2010-11-11 2010-11-11 Implementation method for changing vibration effect with music

Country Status (1)

Country Link
CN (1) CN102064832B (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104580692A (en) * 2014-12-02 2015-04-29 广东欧珀移动通信有限公司 Method and device for enabling mobile phone to dance with music
CN106126184A (en) * 2016-06-30 2016-11-16 维沃移动通信有限公司 A kind of audio signal player method and mobile terminal
CN108845673A (en) * 2012-08-31 2018-11-20 意美森公司 Use sound-haptic effect converting system of mapping
CN108989706A (en) * 2017-06-02 2018-12-11 北京字节跳动网络技术有限公司 The method and device of special efficacy is generated based on music rhythm
CN109887528A (en) * 2019-02-15 2019-06-14 上海艾为电子技术股份有限公司 Motor is with the method and device of audio frequency vibration, storage medium and electronic equipment
CN110198385A (en) * 2019-05-28 2019-09-03 Oppo广东移动通信有限公司 A kind of vibration frequency adjusting method, device, storage medium and electronic equipment
CN111669497A (en) * 2020-06-12 2020-09-15 杭州趣维科技有限公司 Method for driving sticker effect by volume during self-shooting of mobile terminal
CN112114674A (en) * 2020-09-29 2020-12-22 北京小米移动软件有限公司 Vibration intensity control method and device, electronic device, storage medium
CN114404937A (en) * 2021-12-24 2022-04-29 歌尔光学科技有限公司 Wearable device control method and device, wearable device and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1489148A (en) * 2002-10-10 2004-04-14 上海歌升音像科技有限公司 Portable (recordable) karaoke apparatus
EP1533784A2 (en) * 2003-11-20 2005-05-25 Sony Corporation Playback mode control device and method
US20070044641A1 (en) * 2003-02-12 2007-03-01 Mckinney Martin F Audio reproduction apparatus, method, computer program
CN101326570A (en) * 2005-10-13 2008-12-17 弗劳恩霍弗应用技术研究院 Controlling the reproduction of audio information

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1489148A (en) * 2002-10-10 2004-04-14 上海歌升音像科技有限公司 Portable (recordable) karaoke apparatus
US20070044641A1 (en) * 2003-02-12 2007-03-01 Mckinney Martin F Audio reproduction apparatus, method, computer program
EP1533784A2 (en) * 2003-11-20 2005-05-25 Sony Corporation Playback mode control device and method
CN101326570A (en) * 2005-10-13 2008-12-17 弗劳恩霍弗应用技术研究院 Controlling the reproduction of audio information

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108845673A (en) * 2012-08-31 2018-11-20 意美森公司 Use sound-haptic effect converting system of mapping
CN108845673B (en) * 2012-08-31 2021-06-22 意美森公司 Sound-to-haptic effect conversion system using mapping
CN104580692A (en) * 2014-12-02 2015-04-29 广东欧珀移动通信有限公司 Method and device for enabling mobile phone to dance with music
CN106126184A (en) * 2016-06-30 2016-11-16 维沃移动通信有限公司 A kind of audio signal player method and mobile terminal
CN106126184B (en) * 2016-06-30 2019-04-12 维沃移动通信有限公司 A kind of audio signal playback method and mobile terminal
CN108989706A (en) * 2017-06-02 2018-12-11 北京字节跳动网络技术有限公司 The method and device of special efficacy is generated based on music rhythm
CN109887528A (en) * 2019-02-15 2019-06-14 上海艾为电子技术股份有限公司 Motor is with the method and device of audio frequency vibration, storage medium and electronic equipment
CN110198385A (en) * 2019-05-28 2019-09-03 Oppo广东移动通信有限公司 A kind of vibration frequency adjusting method, device, storage medium and electronic equipment
CN111669497A (en) * 2020-06-12 2020-09-15 杭州趣维科技有限公司 Method for driving sticker effect by volume during self-shooting of mobile terminal
CN112114674A (en) * 2020-09-29 2020-12-22 北京小米移动软件有限公司 Vibration intensity control method and device, electronic device, storage medium
CN114404937A (en) * 2021-12-24 2022-04-29 歌尔光学科技有限公司 Wearable device control method and device, wearable device and medium
CN114404937B (en) * 2021-12-24 2025-06-24 歌尔科技有限公司 Wearable device control method, device, wearable device and medium

Also Published As

Publication number Publication date
CN102064832B (en) 2013-09-18

Similar Documents

Publication Publication Date Title
CN102064832B (en) Implementation method for changing vibration effect with music
Mauch et al. The audio degradation toolbox and its application to robustness evaluation
CN102474232B (en) System for increasing perceived loudness of speakers
CN103677249B (en) Use sound-haptic effect converting system of mapping
CN102024481B (en) Method and device for extracting vibration information from audio file and vibrating device
KR100619066B1 (en) Method and apparatus for strengthening low range of audio signal
US20070236449A1 (en) Systems and Methods for Enhanced Haptic Effects
CN103365415A (en) Sound to haptic effect conversion system using multiple actuators
FI3848929T3 (en) Device and method for reducing quantization noise in a time-domain decoder
CN105773612A (en) System and method for controlling dance of robot
CN110322898A (en) Vagitus detection method, device and computer readable storage medium
DE60311891D1 (en) AUDIO CODING
CN110390954A (en) Method and device for evaluating quality of voice product
CN111246344B (en) Audio processing method and intelligent sound box
CN1533120A (en) audio device
CN112298032A (en) Method and system for synthesizing pedestrian warning sound outside new energy automobile
CN106548782A (en) The processing method and mobile terminal of acoustical signal
CN207135242U (en) A kind of wireless microphone with intelligent noise removal function
US9826312B2 (en) Circuit and method for driving a loudspeaker
CN209118747U (en) A kind of chord crying musical instrument intelligence temperament device
CN116013349B (en) Audio processing method and related device
CN103236255A (en) Software method for transforming audio files into MIDI (musical instrument digital interface) files
JP5177657B2 (en) Acoustic characteristic control device
CN2682533Y (en) Digital audio data reproduction apparatus
CN203747968U (en) Sound box

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CP01 Change in the name or title of a patent holder

Address after: Changan Town, Guangdong province 523860 usha Beach Road Dongguan City, No. 18 Guangdong Oupo Mobile Communication Co Ltd

Patentee after: GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd.

Address before: Changan Town, Guangdong province 523860 usha Beach Road Dongguan City, No. 18 Guangdong Oupo Mobile Communication Co Ltd

Patentee before: GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd.

CP01 Change in the name or title of a patent holder
CP02 Change in the address of a patent holder

Address after: Changan town in Guangdong province Dongguan 523860 usha Beach Road No. 18

Patentee after: GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd.

Address before: Changan Town, Guangdong province 523860 usha Beach Road Dongguan City, No. 18 Guangdong Oupo Mobile Communication Co Ltd

Patentee before: GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd.

CP02 Change in the address of a patent holder
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20130918

CF01 Termination of patent right due to non-payment of annual fee