Disclosure of Invention
In view of this, the main objective of the present invention is to provide a method and an apparatus for automatically adjusting a volume, which can automatically adjust the volume, avoid the situation that a sound is suddenly big or suddenly small when different sound sources are switched, and improve user experience.
In order to achieve the purpose, the technical scheme of the invention is realized as follows:
the invention provides a method for automatically adjusting volume, which comprises the following steps:
collecting sound data sent by current terminal external playing equipment to obtain a loudness value of current sound;
and comparing the obtained loudness value of the current sound with a preset loudness value of the sound, and adjusting the current volume value according to the comparison result.
In the foregoing solution, the comparing the obtained loudness value of the current sound with a preset loudness value of the sound, and adjusting the current loudness value according to the comparison result includes:
judging whether the loudness value of the current sound is equal to a preset sound loudness value or not, and if so, not executing any operation; otherwise, judging whether the loudness value of the current sound is greater than a preset sound loudness value;
if the loudness value of the current sound is larger than the preset loudness value of the sound, the loudness value of the current terminal is reduced until the loudness value of the current sound is equal to the preset loudness value of the sound; and if the loudness value of the current sound is smaller than the preset loudness value, the loudness value of the current terminal is increased until the loudness value of the current sound is equal to the preset loudness value.
In the above scheme, the method further comprises: the play-out device outputs an audio signal according to the actual volume value.
In the above scheme, before acquiring the sound data sent by the current terminal play-out device, the method further includes: and starting the function of automatically adjusting the volume.
The invention also provides a device for automatically adjusting the volume, which comprises a sound monitoring module, a comparison module and a sound adjusting module; wherein,
the sound monitoring module is used for collecting sound data, obtaining the loudness value of the current sound and sending the obtained loudness value to the comparison module;
the comparison module is used for comparing the loudness value of the current sound sent by the sound monitoring module with a preset sound loudness value and sending the comparison result to the sound adjustment module;
and the sound adjusting module is used for adjusting the current volume value according to the comparison result sent by the comparing module.
In the above scheme, the apparatus further includes a storage module, configured to store a preset sound loudness value.
In the above scheme, the sound adjusting module is specifically configured to, when the comparison result is that the loudness value of the current sound is greater than the preset sound loudness value, decrease the current loudness value until the loudness value of the current sound is equal to the preset sound loudness value; and when the comparison result shows that the loudness value of the current sound is smaller than the preset sound loudness value, increasing the current sound value until the loudness value of the current sound is equal to the preset sound loudness value.
In the above scheme, the apparatus further comprises an external device for outputting the audio signal according to the actual volume value.
In the above scheme, the device further comprises a switch module for turning on or off the function of automatically adjusting the volume.
The method and the device for automatically adjusting the volume acquire the loudness value of the current sound by acquiring the sound data sent by the current terminal external playing equipment, and compare the loudness value of the current sound with the preset loudness value; and increasing or decreasing the volume value of the current terminal according to the comparison result. Therefore, the condition of big or small sound can be avoided when different sound sources are switched, automatic adjustment of the sound volume is realized, and the user experience is improved.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and specific embodiments.
Fig. 1 is a schematic flow chart of a method for automatically adjusting volume according to the present invention, as shown in fig. 1, including the following steps:
step 101: collecting sound data sent by current terminal external playing equipment to obtain a loudness value of current sound;
here, before the collecting the sound data emitted by the current terminal playing device, the method further includes: starting the function of automatically adjusting the volume;
specifically, the technical scheme of the invention has the function of turning on or turning off the automatic volume adjustment, and because the sound data is greatly influenced by the external sound, when the external sound is large and the collection of the sound data sent by the external equipment is influenced, the automatic volume adjustment is influenced, so that the function of automatically adjusting the volume can be turned on or turned off by a user according to the actual external environment.
Here, the sound data includes loudness of sound emitted by the current terminal playback device.
Step 102: comparing the obtained loudness value of the current sound with a preset loudness value, and adjusting the current loudness value according to the comparison result;
here, it is assumed that the loudness value of the current sound is Vt, and the preset sound loudness value is Vs; specifically, referring to fig. 2, step 102 includes:
step 102 a: judging whether the loudness value Vt of the current sound is equal to a preset sound loudness value Vs, if so, executing the step 102b, and ending the current processing process; otherwise, go to step 102 c;
here, the preset sound loudness value Vs is set by the user according to his or her needs, and is a sound loudness that the user feels optimal.
Step 102c to step 102 e: comparing the loudness value Vt of the current sound with a preset sound loudness value Vs, if Vt is greater than Vs, reducing the volume value of the current terminal, executing step 102a until Vt is equal to Vs, and ending the current processing process; if Vt is less than Vs, then increase the volume value of the current terminal, execute step 102a, until Vt is equal to Vs, end the current processing process;
here, the comparison module sends a signal to the sound adjustment module to inform the sound adjustment module of the comparison result between Vt and Vs; the sound adjusting module adjusts the sound gain parameters according to the received signals; wherein the sound gain parameter may affect the actual playing loudness of the sound.
When the loudness value of the current sound is inconsistent with the preset loudness value of the sound, the loudness value of the current sound can be adjusted step by step according to the minimum unit of the current terminal volume value until the loudness value of the current sound is consistent with the preset loudness value of the sound;
or, the loudness value of the current sound is too different from the preset sound loudness value, the volume can be adjusted according to N minimum units of the current terminal volume value, which is equivalent to setting a volume adjustment amplitude, so that the sound loudness can be adjusted in an accelerated manner.
For example, the volume value of the terminal is between 0 and 100, the minimum unit is 1, if the loudness value of the current sound is 70 db and the preset sound loudness value is 60 db, the volume value of the current terminal needs to be reduced, so that the loudness value of the current sound is reduced to 60 db; if the current volume value of the terminal is 30, the current volume value of the terminal can be adjusted step by step according to the minimum unit of the volume value, the volume value of the terminal is adjusted to 29, sound data sent by current terminal external equipment is collected continuously, and the obtained loudness value of the current sound is compared with a preset loudness value until the loudness value of the current sound is equal to the preset loudness value;
for example, the loudness value of the current sound is 75 decibels, the preset sound loudness value is 45 decibels, and the difference is 30 decibels, the loudness value of the current terminal needs to be reduced, so that the loudness value of the current sound is reduced to 45 decibels; the volume value of the terminal is between 0 and 100, the minimum unit is 1, the current volume value is 35, the adjustment can be carried out according to the minimum unit of 5 volume values, the volume value is adjusted to be 30, sound data sent by the current terminal external playing equipment are collected continuously, the obtained loudness value of the current sound is compared with the preset sound loudness value, and the obtained loudness value of the current sound is equal to the preset sound loudness value.
Here, whether to adjust the volume according to the minimum unit or the volume adjustment amplitude may be selected by the comparison module according to a comparison result between the loudness value of the current sound and a preset loudness value of the sound, and sent to the sound adjustment module through a signal.
Fig. 3 is a schematic structural diagram of the apparatus for automatically adjusting volume according to the present invention, as shown in fig. 2, the apparatus includes a sound monitoring module 32, a comparing module 33 and a sound adjusting module 35; wherein,
the sound monitoring module 32 is configured to collect sound data, obtain a loudness value of the current sound, and send the obtained loudness value to the comparison module 33;
the comparing module 33 is configured to compare the loudness value of the current sound sent by the sound monitoring module 32 with a preset sound loudness value, and send the comparison result to the sound adjusting module 35;
the sound adjusting module 35 is configured to adjust the current volume value according to the comparison result sent by the comparing module 33.
Further, the apparatus further comprises a storage module 34 for storing the preset sound loudness value.
Further, the sound adjusting module 35 is specifically configured to, when the comparison result is that the loudness value of the current sound is greater than the preset sound loudness value, decrease the current volume value until the loudness value of the current sound is equal to the preset sound loudness value; and when the comparison result shows that the loudness value of the current sound is smaller than the preset sound loudness value, increasing the current sound value until the loudness value of the current sound is equal to the preset sound loudness value.
Further, the apparatus further comprises a play-out device 31 for outputting an audio signal in dependence of the actual volume value.
Furthermore, the device also comprises a switch module which is used for switching on or off the function of automatically adjusting the volume.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, and improvement made within the spirit and scope of the present invention are included in the protection scope of the present invention.