Disclosure of Invention
The embodiment of the application provides a method and a system for identifying an earphone and a loudspeaker, a head-mounted display device and a storage medium, so as to at least solve the problems that one audio interface of a terminal device in the related art supports both the earphone and the loudspeaker, and noise exists when the earphone and the loudspeaker are identified incorrectly.
In a first aspect, an embodiment of the present application provides a method for identifying a headphone and a speaker, where the speaker and the headphone share an audio interface, and an impedance of the speaker is much smaller than an impedance of the headphone, the method includes:
detecting that an external device is inserted, and acquiring a first voltage of the external device when the insertion time of the external device reaches a preset time;
and judging whether the first voltage is within a preset range, if so, determining that the external equipment is a loudspeaker, and if not, determining that the external equipment is an earphone.
In some embodiments, after the detecting of the insertion of the external device, the method further includes:
under the condition that the insertion time of the external equipment reaches the preset time, continuously and repeatedly acquiring a second voltage of the external equipment, and acquiring an average value of the second voltage;
and judging whether the average value of the second voltage is within the preset range, if so, determining that the external equipment is a loudspeaker, and if not, determining that the external equipment is an earphone.
In some embodiments, obtaining the first voltage of the external device comprises:
the external equipment is a four-section type audio plug equipment, and the voltage between the third section of the audio plug and the fourth section of the audio plug is obtained;
if the external device is an earphone, the first section of the earphone audio plug is a left sound channel, the second section of the earphone audio plug is a right sound channel, the third section of the earphone audio plug is a microphone, and the fourth section of the earphone audio plug is a ground;
if the external equipment is a loudspeaker, the first section of the loudspeaker audio plug is a left loudspeaker, the second section of the loudspeaker audio plug is a right loudspeaker, the third section of the loudspeaker audio plug is a detection pin, and the fourth section of the loudspeaker audio plug is a ground.
In some embodiments, before detecting insertion of the external device, the method further comprises:
setting a preset time;
and the time required by fully charging the capacitive load between the third section of the horn audio plug and the fourth section of the horn audio plug is the preset time.
In a second aspect, the present application provides a system for identifying a speaker and a headset, which is applied to the speaker and the headset sharing an audio interface, wherein the impedance of the speaker is much smaller than the impedance of the headset, the system includes a detection module, an acquisition module and a determination module,
the detection module is used for detecting the insertion of the external equipment;
the external equipment comprises an acquisition module, a control module and a control module, wherein the acquisition module is used for acquiring a first voltage of the external equipment under the condition that the insertion time of the external equipment reaches a preset time;
and the judging module is used for judging whether the first voltage is within a preset range, if so, the external equipment is a loudspeaker, and if not, the external equipment is an earphone.
In some embodiments, after the detection module detects the insertion of the external device,
the obtaining module obtains a second voltage of the external equipment continuously for multiple times when the insertion time of the external equipment reaches a preset time, and obtains an average value of the second voltage;
the judgment module judges whether the average value of the second voltage is within the preset range, if so, the external equipment is a loudspeaker, and if not, the external equipment is an earphone.
In some embodiments, the obtaining module obtains the first voltage of the external device by:
the external equipment is equipment with a four-section type audio plug, and the acquisition module acquires voltage between the third section of the audio plug and the fourth section of the audio plug;
if the external device is an earphone, the first section of the earphone audio plug is a left sound channel, the second section of the earphone audio plug is a right sound channel, the third section of the earphone audio plug is a microphone, and the fourth section of the earphone audio plug is a ground;
if the external equipment is a loudspeaker, the first section of the loudspeaker audio plug is a left loudspeaker, the second section of the loudspeaker audio plug is a right loudspeaker, the third section of the loudspeaker audio plug is a detection pin, and the fourth section of the loudspeaker audio plug is a ground.
In some embodiments, the system further comprises a setting module, before the detection module detects the insertion of the external device,
the setting module is used for setting preset time;
and the time required by fully charging the capacitive load between the third section of the horn audio plug and the fourth section of the horn audio plug is the preset time.
In a third aspect, embodiments of the present application provide a head-mounted display device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor, when executing the computer program, implements the method for identifying earphones and speakers as described in the first aspect.
In a fourth aspect, embodiments of the present application provide a storage medium having a computer program stored thereon, where the computer program is executed by a processor to implement the method for recognizing a headphone and a loudspeaker as described in the first aspect.
Compared with the related art, the method for identifying the earphone and the loudspeaker is applied to the loudspeaker and the earphone which share one audio interface, the impedance of the loudspeaker is far smaller than that of the earphone, and the first voltage of the external equipment is obtained when the insertion time of the external equipment reaches the preset time by detecting the insertion of the external equipment; whether the first voltage is in a preset range is judged, if the judgment result is yes, the external equipment is a loudspeaker, if the judgment result is no, the external equipment is an earphone, the impedance of the loudspeaker is far smaller than the impedance of the earphone, so that the voltage stabilization time of the loudspeaker is far smaller than the voltage stabilization time of the earphone, in the preset time, after the voltage of the loudspeaker rises to the preset range, the voltage of the earphone is far smaller than the voltage in the preset range, so that whether the voltage of the external equipment is in the preset range or not can be judged, whether the inserted external equipment is the earphone or the loudspeaker can be identified, the problem that an audio interface of the terminal equipment supports both the earphone and the loudspeaker, errors are easily identified by the earphone and the loudspeaker, and noise exists when the earphone and the loudspeaker are identified incorrectly is solved.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments provided in the present application without any inventive step are within the scope of protection of the present application. Moreover, it should be appreciated that in the development of any such actual implementation, as in any engineering or design project, numerous implementation-specific decisions must be made to achieve the developers' specific goals, such as compliance with system-related and business-related constraints, which may vary from one implementation to another.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the specification. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of ordinary skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments without conflict.
Unless defined otherwise, technical or scientific terms referred to herein shall have the ordinary meaning as understood by those of ordinary skill in the art to which this application belongs. Reference to "a," "an," "the," and similar words throughout this application are not to be construed as limiting in number, and may refer to the singular or the plural. The present application is directed to the use of the terms "including," "comprising," "having," and any variations thereof, which are intended to cover non-exclusive inclusions; for example, a process, method, system, article, or apparatus that comprises a list of steps or modules (elements) is not limited to the listed steps or elements, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. Reference to "connected," "coupled," and the like in this application is not intended to be limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. Reference herein to "a plurality" means greater than or equal to two. "and/or" describes an association relationship of associated objects, meaning that three relationships may exist, for example, "A and/or B" may mean: a exists alone, A and B exist simultaneously, and B exists alone. Reference herein to the terms "first," "second," "third," and the like, are merely to distinguish similar objects and do not denote a particular ordering for the objects.
The present embodiment provides a method for identifying a speaker and a headset, which is applied to a speaker and a headset sharing an audio interface, where the impedance of the speaker is much smaller than the impedance of the headset, fig. 1 is a flowchart of a method for identifying a speaker and a headset according to an embodiment of the present application, and as shown in fig. 1, the method includes the following steps:
step S101, detecting that an external device is inserted, and acquiring a first voltage of the external device when the insertion time of the external device reaches a preset time;
step S102, judging whether the first voltage is in a preset range, if so, determining that the external equipment is a loudspeaker, and if not, determining that the external equipment is an earphone. In this embodiment, the preset range is a voltage value of the loudspeaker or the earphone after the voltage is stabilized, the voltage value is within a range of a positive preset value and a negative preset value, and the preset value is as small as possible, so that the result is more accurate.
Through the steps from S101 to S102, the impedance of the loudspeaker is far smaller than the impedance of the earphone, so that the voltage stabilization time of the loudspeaker is far smaller than the voltage stabilization time of the earphone, and after the voltage of the loudspeaker rises to a preset range within the preset time, the voltage of the earphone is far smaller than the voltage within the preset range, so that whether the inserted external equipment is the earphone or the loudspeaker can be identified by judging whether the voltage of the external equipment is within the preset range, and the problems that an audio interface of the terminal equipment supports both the earphone and the loudspeaker, and noise exists when the earphone and the loudspeaker are identified incorrectly are solved.
In some embodiments, in acquiring the first voltage of the external device, in order to prevent inaccurate voltage measurement due to various reasons, the voltage of the external device needs to be acquired multiple times, fig. 2 is a flowchart of another method for recognizing a headset and a speaker according to an embodiment of the present application, and as shown in fig. 2, the method includes the following steps:
step S201, under the condition that the insertion time of the external equipment reaches the preset time, continuously and repeatedly acquiring a second voltage of the external equipment, and acquiring an average value of the second voltage;
step S202, judging whether the average value of the second voltage is in a preset range, if so, the external equipment is a loudspeaker, and if not, the external equipment is an earphone.
Through the steps S201 to S202, after the second voltage of the external device is continuously obtained for multiple times, the maximum voltage and the minimum voltage are discarded, and then the average voltage is obtained, and whether the average voltage is within the preset range or not is determined, so that the problem of determination errors caused by measurement errors is prevented, and the determination accuracy is improved;
in some embodiments, obtaining the first voltage of the external device comprises: the external equipment is a four-section type audio plug equipment, and the voltage between the third section of the audio plug and the fourth section of the audio plug is obtained; if the external equipment is an earphone, the first section of the earphone audio plug is a left sound channel, the second section of the earphone audio plug is a right sound channel, the third section of the earphone audio plug is a microphone, and the fourth section of the earphone audio plug is a ground; if the external equipment is a loudspeaker, the first section of the loudspeaker audio plug is a left loudspeaker, the second section of the loudspeaker audio plug is a right loudspeaker, the third section of the loudspeaker audio plug is a detection pin, and the fourth section of the loudspeaker audio plug is a ground. In this embodiment, the impedance between the third section of the speaker audio plug and the fourth section of the speaker audio plug is far smaller than the impedance between the third section of the earphone audio plug and the fourth section of the earphone audio plug, so that the voltage stabilization time between the third section of the speaker audio plug and the fourth section of the speaker audio plug is far smaller than the voltage between the third section of the earphone audio plug and the fourth section of the earphone audio plug, and after the voltage between the third section of the speaker audio plug and the fourth section of the speaker audio plug rises to a preset range within a preset time, the voltage between the third section of the earphone audio plug and the fourth section of the earphone audio plug is far smaller than the voltage within the preset range, so that whether the inserted external device is an earphone or a speaker can be identified by judging whether the voltage between the third section of the external device audio plug and the fourth section of the audio plug is within the preset range.
In some embodiments, a preset time is set before the insertion of the external device is detected; and the time required by fully charging the capacitive load between the third section of the horn audio plug and the fourth section of the horn audio plug is preset time. Illustratively, the capacitive load between the third and fourth sections of the horn audio plug is fully charged to a voltage, the voltage is equal to the voltage of the fully charged capacitive load between the third section and the fourth section of the earphone audio plug, but the time required for fully charging the capacitive load and the fourth section of the earphone audio plug is different, because the impedance between the third section and the fourth section of the loudspeaker audio plug is far smaller than the impedance between the third section and the fourth section of the earphone audio plug, the time required for fully charging the capacitive load between the third section and the fourth section of the loudspeaker audio plug is taken as the preset time, for example, the preset time is 500ms, when the insertion time of the external device reaches 500ms, acquiring the voltage between the third section of the audio plug of the external equipment and the fourth section of the audio plug, if the voltage is increased to be within a preset range, the external device is a loudspeaker, and if the voltage is far smaller than the minimum value of the preset range, the external device is an earphone.
It should be noted that the steps illustrated in the above-described flow diagrams or in the flow diagrams of the figures may be performed in a computer system, such as a set of computer-executable instructions, and that, although a logical order is illustrated in the flow diagrams, in some cases, the steps illustrated or described may be performed in an order different than here.
The present embodiment further provides a system for recognizing an earphone and a speaker, which is used to implement the foregoing embodiments and preferred embodiments, and the description of the system is omitted here. As used hereinafter, the terms "module," "unit," "subunit," and the like may implement a combination of software and/or hardware for a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 3 is a block diagram of a structure of a system for recognizing a speaker and an earphone according to an embodiment of the present application, which is applied to an audio interface shared by the speaker and the earphone, where an impedance of the speaker is smaller than an impedance of the earphone, as shown in fig. 3, the system includes a detection module 31, an obtaining module 32, and a determining module 33, where the detection module 31 is used to detect that an external device is inserted; the obtaining module 32 is configured to obtain a first voltage of the external device when the insertion time of the external device reaches a preset time; the judging module 33 is configured to judge whether the first voltage is within a preset range, if the judging result is yes, the external device is a loudspeaker, if the judging result is no, the external device is an earphone, the impedance of the loudspeaker is far smaller than the impedance of the earphone, so that the voltage stabilization time of the loudspeaker is far smaller than the voltage stabilization time of the earphone, within the preset time, after the voltage of the loudspeaker rises to the preset range, the voltage of the earphone is far smaller than the voltage within the preset range, so that whether the voltage of the external device is within the preset range or not can be judged, whether the external device is an earphone or a loudspeaker can be identified, and the problem that an audio interface of the terminal device supports both the earphone and the loudspeaker, and noise exists when the earphone and the loudspeaker are identified incorrectly is solved.
The above modules may be functional modules or program modules, and may be implemented by software or hardware. For a module implemented by hardware, the modules may be located in the same processor; or the modules can be respectively positioned in different processors in any combination.
The present embodiment also provides a head-mounted display device comprising a memory having a computer program stored therein and a processor arranged to execute the computer program to perform the steps of any of the above method embodiments.
Optionally, the head-mounted display device may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
It should be noted that, for specific examples in this embodiment, reference may be made to examples described in the foregoing embodiments and optional implementations, and details of this embodiment are not described herein again.
In addition, in combination with the method for recognizing the earphone and the speaker in the above embodiments, the embodiments of the present application may provide a storage medium to implement. The storage medium having stored thereon a computer program; the computer program when executed by a processor implements any of the above-described embodiments of the method of headset and speaker recognition.
In one embodiment, a computer device is provided, which may be a terminal. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of headset and speaker recognition. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It should be understood by those skilled in the art that various features of the above-described embodiments can be combined in any combination, and for the sake of brevity, all possible combinations of features in the above-described embodiments are not described in detail, but rather, all combinations of features which are not inconsistent with each other should be construed as being within the scope of the present disclosure.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.