Processing method and apparatus for vibration waveform, device, and readable storage medium
Embodiments of this application provide a processing method and apparatus for a vibration waveform, a device, and a readable storage medium. In the processing method for a vibration waveform, a vibration description file is obtained, and a waveform type described in the vibration description file is recognized; a startup time and a stop time are extracted from the vibration description file in a case that the waveform type described in the vibration description file is a steady-state waveform; and an amplitude of the steady-state waveform within the startup time is processed as being smoothly changed from zero to an amplitude of the linear motor in a steady vibration state, and an amplitude of the steady-state waveform within the stop time is processed as being smoothly changed from the amplitude of the linear motor in the steady vibration state to zero.
1 . A processing method for a vibration waveform applicable to an electronic device that comprises a linear motor, the method comprising:
obtaining a vibration description file;
recognizing a waveform type described in the vibration description file;
determining a startup time and a stop time from the vibration description file in a case that the waveform type described in the vibration description file is a steady-state waveform;
adjusting an amplitude of an original steady-state waveform described in the vibration description file by:
adjusting an amplitude of the original steady-state waveform within the startup time as being smoothly changed from zero to an amplitude of the linear motor in a steady vibration state, including:
superimposing a first cosine waveform on the original steady-state waveform within the startup time, wherein the first cosine waveform has a same duration as that of the startup time, and
adjusting an amplitude of the original steady-state waveform within the stop time as being smoothly changed from the amplitude of the linear motor in the steady vibration state to zero;
obtaining a driving waveform based on an adjusted steady-state waveform; and
controlling vibration of the linear motor of the electronic device based on the driving waveform to reduce noise within the startup time and the stop time.
2 . The processing method for a vibration waveform according to claim 1 , wherein
by superimposing the first cosine waveform on the original steady-state waveform within the startup time, the amplitude of the adjusted steady-state waveform within the startup time smoothly transitions from zero to the amplitude of the linear motor in the steady vibration state.
3 . The processing method for a vibration waveform according to claim 1 , wherein the adjusting an amplitude of the original steady-state waveform within the startup time as being smoothly changed from zero to an amplitude of the linear motor in a steady vibration state comprises:
adjusting the original steady-state waveform within the startup time by using an ascent algorithm, so that the amplitude of the adjusted steady-state waveform within the startup time smoothly transitions from zero to the amplitude of the linear motor in the steady vibration state.
4 . The processing method for a vibration waveform according to claim 1 , wherein the adjusting an amplitude of the original steady-state waveform within the stop time as being smoothly changed from the amplitude of the linear motor in the steady vibration state to zero comprises:
superimposing a cosine waveform on the original steady-state waveform within the stop time, so that the amplitude of the adjusted steady-state waveform within the stop time smoothly transitions from the amplitude of the linear motor in the steady vibration state to zero.
5 . The processing method for a vibration waveform according to claim 1 , wherein the adjusting an amplitude of the original steady-state waveform within the stop time as being smoothly changed from the amplitude of the linear motor in the steady vibration state to zero comprises:
adjusting the original steady-state waveform within the stop time by using an ascent algorithm, so that the amplitude of the adjusted steady-state waveform within the stop time smoothly transitions from the amplitude of the linear motor in the steady vibration state to zero.
6 . A non-transitory machine-readable storage medium having instructions stored therein, which when executed by a processor, cause an electronic device that comprises a linear motor to perform operations for a vibration waveform, the operations comprising:
obtaining a vibration description file;
recognizing a waveform type described in the vibration description file;
determining a startup time and a stop time from the vibration description file in a case that the waveform type described in the vibration description file is a steady-state waveform;
adjusting an amplitude of an original steady-state waveform described in the vibration description file by:
adjusting an amplitude of the original steady-state waveform within the startup time as being smoothly changed from zero to an amplitude of the linear motor in a steady vibration state, including:
superimposing a first cosine waveform on the original steady-state waveform within the startup time, wherein the first cosine waveform has a same duration as that of the startup time, and
adjusting the amplitude of the original steady-state waveform within the stop time as being smoothly changed from the amplitude of the linear motor in the steady vibration state to zero;
obtaining a driving waveform based on an adjusted steady-state waveform; and
controlling vibration of the linear motor of the electronic device based on the driving waveform to reduce noise within the startup time and the stop time.
7 . The non-transitory machine-readable storage medium according to claim 6 , wherein
by superimposing the first cosine waveform on the original steady-state waveform within the startup time, the amplitude of the adjusted steady-state waveform within the startup time smoothly transitions from zero to the amplitude of the linear motor in the steady vibration state.
8 . The non-transitory machine-readable storage medium according to claim 6 , wherein the adjusting the amplitude of the original steady-state waveform within the stop time as being smoothly changed from the amplitude of the linear motor in the steady vibration state to zero comprises:
superimposing a cosine waveform on the original steady-state waveform within the stop time, so that the amplitude of the adjusted steady-state waveform within the stop time smoothly transitions from the amplitude of the linear motor in the steady vibration state to zero;
or adjusting the original steady-state waveform within the stop time by using an ascent algorithm, so that the amplitude of the adjusted steady-state waveform within the stop time smoothly transitions from the amplitude of the linear motor in the steady vibration state to zero.
9 . An electronic device, comprising:
a linear motor;
one or more processors; and
a memory, storing a program thereon;
the program, when executed by the one or more processors, causing the electronic device to implement operations:
obtaining a vibration description file;
recognizing a waveform type described in the vibration description file;
determining a startup time and a stop time from the vibration description file in a case that the waveform type described in the vibration description file is a steady-state waveform;
adjusting an amplitude of an original steady-state waveform described in the vibration description file by:
adjusting an amplitude of the original steady-state waveform within the startup time as being smoothly changed from zero to an amplitude of the linear motor in a steady vibration state, including:
superimposing a first cosine waveform on the original steady-state waveform within the startup time, wherein the first cosine waveform has a same duration as that of the startup time, and
adjusting an amplitude of the original steady-state waveform within the stop time as being smoothly changed from the amplitude of the linear motor in the steady vibration state to zero;
obtaining a driving waveform based on an adjusted steady-state waveform; and
controlling vibration of the linear motor of the electronic device based on the driving waveform to reduce noise within the startup time and the stop time.
10 . The electronic device according to claim 9 , wherein
by superimposing the first cosine waveform on the original steady-state waveform within the startup time, the amplitude of the adjusted steady-state waveform within the startup time smoothly transitions from zero to the amplitude of the linear motor in the steady vibration state.
11 . The electronic device according to claim 9 , wherein the adjusting an amplitude of the original steady-state waveform within the startup time as being smoothly changed from zero to an amplitude of the linear motor in a steady vibration state comprises:
adjusting the original steady-state waveform within the startup time by using an ascent algorithm, so that the amplitude of the adjusted steady-state waveform within the startup time smoothly transitions from zero to the amplitude of the linear motor in the steady vibration state.
12 . The electronic device according to claim 9 , wherein the adjusting an amplitude of the original steady-state waveform within the stop time as being smoothly changed from the amplitude of the linear motor in the steady vibration state to zero comprises:
superimposing a cosine waveform on the original steady-state waveform within the stop time, so that the amplitude of the adjusted steady-state waveform within the stop time smoothly transitions from the amplitude of the linear motor in the steady vibration state to zero.
13 . The electronic device according to claim 9 , wherein the adjusting an amplitude of the original steady-state waveform within the stop time as being smoothly changed from the amplitude of the linear motor in the steady vibration state to zero comprises:
adjusting the original steady-state waveform within the stop time by using an ascent algorithm, so that the amplitude of the adjusted steady-state waveform within the stop time smoothly transitions from the amplitude of the linear motor in the steady vibration state to zero.
14 . The non-transitory machine-readable storage medium according to claim 6 , wherein the adjusting an amplitude of the original steady-state waveform within the startup time as being smoothly changed from zero to an amplitude of the linear motor in a steady vibration state comprises:
adjusting the original steady-state waveform within the startup time by using an ascent algorithm, amplitude of the adjusted steady-state waveform within the startup time smoothly transitions from zero to the amplitude of the linear motor in the steady vibration state.