Disclosure of Invention
The invention provides a volume adjusting method and device, which can automatically adjust the volume by acquiring the gain of a sound signal of an input source, thereby enhancing the interaction capacity of a terminal and a user.
In order to achieve the above purpose, the embodiment of the invention adopts the following technical scheme:
the embodiment of the invention provides a volume adjusting method, which comprises the following steps:
acquiring Pulse Code Modulation (PCM) data of a sound signal of an input source;
according to the PCM data, calculating gain of the sound signal of the input source;
obtaining a stepping gain value by adopting a preset algorithm according to the gain of the sound signal of the input source;
and adjusting the gain of the sound signal of the subsequent input source according to the stepping gain value.
Obtaining Pulse Code Modulation (PCM) data of a sound signal of an input source; according to the PCM data, calculating the gain of the sound signal of the input source, and the method comprises the following steps:
sampling the sound signal of the input source to obtain a sound signal value of a certain PCM sampling point;
and dividing the sound signal value of the certain PCM sampling point by the value of the sampling point number to perform squaring, taking the logarithm of the squared value with 10 as a base, and multiplying the logarithm value by 10 to obtain the gain of the sound signal of the input source.
Before adjusting the gain of the sound signal of the subsequent input source according to the step gain value, the method further comprises:
an output threshold range of the sound output device is obtained.
Adjusting the gain of the sound signal of the subsequent input source according to the step gain value, comprising:
if the gain of the sound signal of the subsequent input source is within the output threshold value range, adjusting the gain of the sound signal of the subsequent input source according to the stepping gain value;
or,
and if the gain of the sound signal of the subsequent input source is not in the output threshold range, adjusting and controlling the gain of the sound signal of the subsequent input source in the threshold range.
Before obtaining the Pulse Code Modulation (PCM) data of the sound signal of the input source, the method further comprises the following steps:
and receiving an intelligent volume adjusting instruction.
An embodiment of the present invention provides a volume adjustment device, including:
an acquisition unit configured to acquire Pulse Code Modulation (PCM) data of a sound signal of an input source;
the processing unit is used for calculating the gain of the sound signal of the input source according to the PCM data and obtaining a stepping gain value by adopting a preset algorithm according to the gain of the sound signal of the input source;
and the adjusting unit is used for adjusting the gain of the sound signal of the subsequent input source according to the stepping gain value.
The processing unit is specifically configured to sample the sound signal of the input source, obtain a sound signal value of a certain PCM sampling point, square the sound signal value of the certain PCM sampling point by a value obtained by dividing the sound signal value by the number of sampling points, base-logarithm the squared value by 10, and multiply the logarithm value by 10 to obtain the gain of the sound signal of the input source.
The acquiring unit is further used for acquiring the output threshold range of the sound output equipment.
The adjusting unit is specifically configured to adjust the gain of the sound signal of the subsequent input source according to the step gain value if the gain of the sound signal of the subsequent input source is within the output threshold range;
or,
specifically, if the gain of the sound signal of the subsequent input source is not within the output threshold range, the gain adjustment of the sound signal of the subsequent input source is controlled within the threshold range.
The volume adjusting device further comprises:
and the receiving unit is used for receiving the intelligent volume adjusting instruction.
The embodiment of the invention provides a volume adjusting method and a volume adjusting device, which are characterized in that Pulse Code Modulation (PCM) data of a sound signal of an input source are obtained, the gain of the sound signal of the input source is calculated according to the PCM data, a stepping gain value is obtained by adopting a preset algorithm according to the gain of the sound signal of the input source, and finally the gain of the sound signal of a subsequent input source is adjusted according to the stepping gain value. In the scheme, the gain and the step gain value of the sound signal of the input source are obtained, and the gain of the sound signal of the subsequent input source is adjusted according to the step gain value, so that the volume is automatically adjusted, a user can hear the gain value within a reasonable sound interval range without adjusting the output gain, and the intelligent one side is embodied.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
An embodiment of the present invention provides a volume adjustment method, as shown in fig. 1, including:
s101, the volume adjusting device obtains Pulse Code Modulation (PCM) data of the sound signal of the input source.
Specifically, when a user watches a video or listens to an audio, the user may need to perform volume adjustment through some operations. Firstly, an intelligent volume adjusting device is turned on, the volume adjusting device receives and receives an intelligent volume adjusting instruction, and then Pulse Code Modulation (PCM) data of a sound signal of an input source is obtained. For example, the input source for acquiring the sound Signal may be a television input source HDMI (High definition multimedia Interface), a television Signal source, or a CVBS (Composite Video Broadcast Signal). Pulse Code modulation (pcm) data of an audio signal is used to digitize an analog audio signal by pulse Code modulation.
And S102, calculating the gain of the sound signal of the input source by the volume adjusting device according to the PCM data.
Specifically, the volume adjusting device samples a sound signal of an input source to obtain a sound signal value of a certain PCM sampling point; and dividing the sound signal value of a certain PCM sampling point by the value of the sampling point number to perform squaring, taking the logarithm of the squared value with 10 as a base, and multiplying the logarithm value by 10 to obtain the gain of the sound signal of the input source. For example, as shown in fig. 5, the abscissa is the sampling frequency, the ordinate is the sampling precision, 2 bytes (16 bits) are 65536 sampling points, i.e. the ordinate is divided into 2 to the power of 16 65536 parts, the sampling frequency is 44100Hz, i.e. 44100 times per second, the sound signal value of a certain PCM sampling point is obtained as x, and the gain calculation formula of the sound signal of the input source is as follows:
dB=10*lg[(x/65536)2]
in the embodiment of the present invention, the gain calculation method is only an exemplary preferred method, and is not limited to performing the calculation with the base 10 as a base, and other bases may be used, and the sampling precision in the calculation may be other values, which is not specifically limited in the embodiment of the present invention. The calculation of the gain is not limited to the above-mentioned calculation method, and may be performed by other methods, which is not specifically limited in this embodiment of the present invention.
S103, the volume adjusting device obtains a stepping gain value by adopting a preset algorithm according to the gain of the sound signal of the input source.
It should be noted that the preset algorithm is an algorithm configured by the volume adjustment device itself, and mainly obtains the step gain value through the algorithm, which is not limited to a certain algorithm, but may be other algorithms, and this is not specifically limited in the embodiment of the present invention.
And S104, the volume adjusting device adjusts the gain of the sound signal of the subsequent input source according to the stepping gain value.
Specifically, if the gain of the sound signal of the subsequent input source is within the output threshold range, the gain of the sound signal of the subsequent input source is adjusted according to the step gain value; alternatively, if the gain of the audio signal of the subsequent input source is not within the output threshold range, the gain adjustment of the audio signal of the subsequent input source is controlled to be within the threshold range. So as to ensure that the output sound signal is not distorted and the sound device is protected from being damaged by excessive sound output.
The embodiment of the invention provides a volume adjusting method, which comprises the steps of obtaining Pulse Code Modulation (PCM) data of a sound signal of an input source, calculating gain of the sound signal of the input source according to the PCM data, obtaining a step gain value according to the gain of the sound signal of the input source by adopting a preset algorithm, and finally adjusting gain of a subsequent sound signal of the input source according to the step gain value. In the scheme, the gain and the step gain value of the sound signal of the input source are obtained, and the gain of the sound signal of the subsequent input source is adjusted according to the step gain value, so that the volume is automatically adjusted, a user can hear the gain value within a reasonable sound interval range without adjusting the output gain, and the intelligent one side is embodied.
Example two
An embodiment of the present invention provides a volume adjusting method, as shown in fig. 2, including:
s201, the volume adjusting device receives an intelligent volume adjusting instruction.
Specifically, when a user watches a video or listens to an audio, the user may need to perform volume adjustment through some operations. Firstly, an intelligent volume adjusting device is turned on, the volume adjusting device receives and receives an intelligent volume adjusting instruction, and then Pulse Code Modulation (PCM) data of a sound signal of an input source is obtained. For example, the input source for acquiring the sound Signal may be a television input source HDMI (High definition multimedia Interface), a television Signal source, and a CVBS (Composite Video Broadcast Signal).
S202, sampling a sound signal of an input source by a volume adjusting device to obtain a sound signal value of a certain PCM sampling point; and dividing the sound signal value of a certain PCM sampling point by the value of the sampling point number to perform squaring, taking the logarithm of the squared value with 10 as a base, and multiplying the logarithm value by 10 to obtain the gain of the sound signal of the input source.
For example, as shown in fig. 5, the abscissa is the sampling frequency, the ordinate is the sampling precision, 2 bytes (16 bits) are 65536 sampling points, i.e. the ordinate is divided into 2 to the power of 16 65536 parts, the sampling frequency is 44100Hz, i.e. 44100 times per second, the sound signal value of a certain PCM sampling point is obtained as x, and the gain calculation formula of the sound signal of the input source is as follows:
dB=10*lg[(x/65536)2]
in the embodiment of the present invention, the gain calculation method is only an exemplary preferred method, and is not limited to performing the calculation with the base 10 as a base, and other bases may be used, and the sampling precision in the calculation may be other values, which is not specifically limited in the embodiment of the present invention. The calculation of the gain is not limited to the above-mentioned calculation method, and may be performed by other methods, which is not specifically limited in this embodiment of the present invention.
S203, the volume adjusting device acquires the output threshold range of the sound output equipment.
The volume adjusting device obtains the output threshold range of the sound output equipment, and if the gain of the sound signal of the subsequent input source is not in the output threshold range, the gain adjustment of the sound signal of the subsequent input source is controlled in the threshold range, so that the output sound signal is not distorted and eliminated, and the sound device is protected from being damaged by overlarge sound output.
S204, if the gain of the sound signal of the subsequent input source is within the output threshold range, the volume adjusting device adjusts the gain of the sound signal of the subsequent input source according to the stepping gain value; or,
if the gain of the sound signal of the subsequent input source is not within the output threshold range, the volume adjusting device adjusts the gain of the sound signal of the subsequent input source to be within the threshold range.
For example, the gain value of the input sound signal is-5 dB, the output threshold range of the sound output device is-20 dB- +20dB, the step gain is 2dB, and the gain value of the output sound signal after being adjusted by the volume adjusting device is-3 dB, that is, the output sound signal is amplified by 2 dB. And if the gain of the sound signal of the subsequent input source is not in the output threshold range, adjusting and controlling the gain of the sound signal of the subsequent input source in the threshold range. So as to ensure that the output sound signal is not distorted and the sound device is protected from being damaged by excessive sound output.
The embodiment of the invention provides a volume adjusting method, which comprises the steps of obtaining Pulse Code Modulation (PCM) data of a sound signal of an input source, calculating gain of the sound signal of the input source according to the PCM data, obtaining a step gain value according to the gain of the sound signal of the input source by adopting a preset algorithm, and finally adjusting gain of a subsequent sound signal of the input source according to the step gain value. This scheme can carry out intelligent regulation to the volume, through gain and the step gain value that obtains the sound signal of input source, the size of automatically regulated volume can make the user can hear the gain value in the interval within range of reasonable sound when not adjusting output gain, embodies more intelligent one side.
EXAMPLE III
An embodiment of the present invention provides a volume adjustment device 1, as shown in fig. 3, including:
an acquisition unit 10 for acquiring pulse code modulation PCM data of a sound signal of an input source;
the processing unit 11 is configured to calculate a gain of the sound signal of the input source according to the PCM data, and obtain a step gain value by using a preset algorithm according to the gain of the sound signal of the input source;
and an adjusting unit 12 for adjusting the gain of the sound signal of the subsequent input source according to the step gain value.
The processing unit 11 is specifically configured to sample an audio signal of an input source, obtain an audio signal value of a certain PCM sampling point, square a value obtained by dividing the audio signal value of the certain PCM sampling point by the number of sampling points, base-logarithm-10 the squared value, and multiply the logarithm value by 10 to obtain a gain of the audio signal of the input source.
The obtaining unit 10 is further configured to obtain an output threshold range of the sound output apparatus.
An adjusting unit 12, configured to adjust the gain of the subsequent sound signal of the input source according to the step gain value if the gain of the subsequent sound signal of the input source is within the output threshold range; or,
specifically, the method is used for adjusting and controlling the gain of the sound signal of the subsequent input source within the threshold range if the gain of the sound signal of the subsequent input source is not within the output threshold range.
The volume adjustment device 1, as shown in fig. 4, further includes:
and the receiving unit 13 is used for receiving the intelligent volume adjusting instruction.
The embodiment of the invention provides a volume adjusting device, which is characterized in that Pulse Code Modulation (PCM) data of a sound signal of an input source are obtained, the gain of the sound signal of the input source is calculated according to the PCM data, a stepping gain value is obtained by adopting a preset algorithm according to the gain of the sound signal of the input source, and finally the gain of the sound signal of a subsequent input source is adjusted according to the stepping gain value. In the scheme, the gain and the step gain value of the sound signal of the input source are obtained, and the gain of the sound signal of the subsequent input source is adjusted according to the step gain value, so that the volume is automatically adjusted, a user can hear the gain value within a reasonable sound interval range without adjusting the output gain, and the intelligent one side is embodied.
It will be clear to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional modules is merely used as an example, and in practical applications, the above function distribution may be performed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to perform all or part of the above described functions. For the specific working processes of the system, the apparatus and the unit described above, reference may be made to the corresponding processes in the foregoing method embodiments, and details are not described here again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, a module or a unit may be divided into only one logical function, and may be implemented in other ways, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be substantially implemented or contributed by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.