US-12627928-B2 - Sound channel switching method and apparatus, and electronic device
Abstract
A channel switching method and apparatus, and an electronic device, and relates to the field of communication technologies. The method includes: in case that an electronic device plays audio and its target state changes, obtaining its state change parameter, the state change parameter including a folding angle, a rotation angle, or a scaling amplitude; according to the state change parameter, fusing first and second channel signals in a first manner to obtain a third channel signal, fusing the first and second channel signals in a second manner to obtain a fourth channel signal; controlling a first speaker playing the first channel signal to switch to the third channel signal, and controlling a second speaker playing the second channel signal to switch to the fourth channel signal, where before the channel signal switching, channels played by the first and second speakers do not match orientations of the speakers.
Inventors
- Yannan YAN
- Liwen YOU
Assignees
- VIVO MOBILE COMMUNICATION CO., LTD.
Dates
- Publication Date
- 20260512
- Application Date
- 20240206
- Priority Date
- 20210806
Claims (17)
- 1 . A sound channel switching method, applied to an electronic device, wherein the method comprises: obtaining a state change parameter of the electronic device in a case that the electronic device plays audio and a target state of the electronic device changes, wherein the state change parameter comprises a folding angle, a rotation angle, or a scaling amplitude, and the scaling amplitude is a scaling amplitude of a screen of the electronic device; fusing a first sound channel signal and a second sound channel signal according to the state change parameter in a first fusion manner to obtain a third sound channel signal, and fusing the first sound channel signal and the second sound channel signal in a second fusion manner to obtain a fourth sound channel signal; and controlling a first speaker to switch from playing the first sound channel signal to playing the third sound channel signal, and controlling a second speaker to switch from playing the second sound channel signal to playing the fourth sound channel signal, wherein before a sound channel signal is switched, sound channels played by the first speaker and the second speaker do not match orientations in which the first speaker and the second speaker are located; wherein the fusing a first sound channel signal and a second sound channel signal according to the state change parameter in a first fusion manner to obtain a third sound channel signal, and fusing the first sound channel signal and the second sound channel signal in a second fusion manner to obtain a fourth sound channel signal comprises: separately obtaining a first spectrum amplitude value of the first sound channel signal and a second spectrum amplitude value of the second sound channel signal; determining a fusion component according to the state change parameter, the first spectrum amplitude value, and the second spectrum amplitude value; performing first operation processing on the first spectrum amplitude value and the fusion component to obtain a third spectrum amplitude value of the fused third sound channel signal; and performing second operation processing on the second spectrum amplitude value and the fusion component to obtain a fourth spectrum amplitude value of the fused fourth sound channel signal.
- 2 . The method according to claim 1 , wherein the determining a fusion component according to the state change parameter, the first spectrum amplitude value, and the second spectrum amplitude value comprises: determining a state coefficient according to the state change parameter and a maximum change value of the target state; and calculating a product of the state coefficient and a first difference to obtain the fusion component, wherein the first difference is a difference between the first spectrum amplitude value and the second spectrum amplitude value.
- 3 . The method according to claim 2 , wherein the performing first operation processing on the first spectrum amplitude value and the fusion component to obtain a third spectrum amplitude value of the fused third sound channel signal comprises: subtracting the fusion component from the first spectrum amplitude value to obtain the third spectrum amplitude value; and the performing second operation processing on the second spectrum amplitude value and the fusion component to obtain a fourth spectrum amplitude value of the fused fourth sound channel signal comprises: adding the second spectrum amplitude value and the fusion component to obtain the fourth spectrum amplitude value.
- 4 . The method according to claim 2 , wherein when the state change parameter is a folding angle, the maximum change value of the target state is 180 degrees; when the state change parameter is a rotation angle, the maximum change value of the target state is 90 degrees or 180 degrees; or when the state change parameter is a scaling amplitude, the maximum change value of the target state is a maximum scaling amplitude of the screen of the electronic device.
- 5 . The method according to claim 1 , wherein the separately obtaining a first spectrum amplitude value of the first sound channel signal and a second spectrum amplitude value of the second sound channel signal comprises: separately obtaining a first amplitude characteristic of the first sound channel signal in a frequency domain and a second amplitude characteristic of the second sound channel signal in the frequency domain; and separately converting the first amplitude characteristic and the second amplitude characteristic into spectrum amplitude values, so as to obtain the first spectrum amplitude value and the second spectrum amplitude value.
- 6 . The method according to claim 1 , wherein before the controlling a first speaker to switch from playing the first sound channel signal to playing the third sound channel signal, and controlling a second speaker to switch from playing the second sound channel signal to playing the fourth sound channel signal, the method further comprises: predicting an orientation of each speaker in a plurality of speakers of the electronic device after the target state of the electronic device changes; and in a case that a sound channel currently played by a target speaker in the plurality of speakers does not match a predicted orientation of the target speaker, determining that the target speaker is a to-be-switched speaker, wherein a speaker that currently plays the first sound channel signal in the speaker to be switched is the first speaker, and a speaker that currently plays the second sound channel signal in the speaker to be switched is the second speaker.
- 7 . An electronic device, comprising a processor, a memory, and a program or an instruction that is stored in the memory and that is executable by the processor, wherein the program or the instruction is executed by the processor to implement the following steps: obtaining a state change parameter of the electronic device in a case that the electronic device plays audio and a target state of the electronic device changes, wherein the state change parameter comprises a folding angle, a rotation angle, or a scaling amplitude, and the scaling amplitude is a scaling amplitude of a screen of the electronic device; fusing a first sound channel signal and a second sound channel signal according to the state change parameter in a first fusion manner to obtain a third sound channel signal, and fusing the first sound channel signal and the second sound channel signal in a second fusion manner to obtain a fourth sound channel signal; and controlling a first speaker to switch from playing the first sound channel signal to playing the third sound channel signal, and controlling a second speaker to switch from playing the second sound channel signal to playing the fourth sound channel signal, wherein before a sound channel signal is switched, sound channels played by the first speaker and the second speaker do not match orientations in which the first speaker and the second speaker are located; wherein the fusing a first sound channel signal and a second sound channel signal according to the state change parameter in a first fusion manner to obtain a third sound channel signal, and fusing the first sound channel signal and the second sound channel signal in a second fusion manner to obtain a fourth sound channel signal comprises: separately obtaining a first spectrum amplitude value of the first sound channel signal and a second spectrum amplitude value of the second sound channel signal; determining a fusion component according to the state change parameter, the first spectrum amplitude value, and the second spectrum amplitude value; performing first operation processing on the first spectrum amplitude value and the fusion component to obtain a third spectrum amplitude value of the fused third sound channel signal; and performing second operation processing on the second spectrum amplitude value and the fusion component to obtain a fourth spectrum amplitude value of the fused fourth sound channel signal.
- 8 . The electronic device according to claim 7 , wherein the determining a fusion component according to the state change parameter, the first spectrum amplitude value, and the second spectrum amplitude value comprises: determining a state coefficient according to the state change parameter and a maximum change value of the target state; and calculating a product of the state coefficient and a first difference to obtain the fusion component, wherein the first difference is a difference between the first spectrum amplitude value and the second spectrum amplitude value.
- 9 . The electronic device according to claim 8 , wherein the performing first operation processing on the first spectrum amplitude value and the fusion component to obtain a third spectrum amplitude value of the fused third sound channel signal comprises: subtracting the fusion component from the first spectrum amplitude value to obtain the third spectrum amplitude value; and the performing second operation processing on the second spectrum amplitude value and the fusion component to obtain a fourth spectrum amplitude value of the fused fourth sound channel signal comprises: adding the second spectrum amplitude value and the fusion component to obtain the fourth spectrum amplitude value.
- 10 . The electronic device according to claim 8 , wherein when the state change parameter is a folding angle, the maximum change value of the target state is 180 degrees; when the state change parameter is a rotation angle, the maximum change value of the target state is 90 degrees or 180 degrees; or when the state change parameter is a scaling amplitude, the maximum change value of the target state is a maximum scaling amplitude of the screen of the electronic device.
- 11 . The electronic device according to claim 7 , wherein the separately obtaining a first spectrum amplitude value of the first sound channel signal and a second spectrum amplitude value of the second sound channel signal comprises: separately obtaining a first amplitude characteristic of the first sound channel signal in a frequency domain and a second amplitude characteristic of the second sound channel signal in the frequency domain; and separately converting the first amplitude characteristic and the second amplitude characteristic into spectrum amplitude values, so as to obtain the first spectrum amplitude value and the second spectrum amplitude value.
- 12 . The electronic device according to claim 7 , wherein before the controlling a first speaker to switch from playing the first sound channel signal to playing the third sound channel signal, and controlling a second speaker to switch from playing the second sound channel signal to playing the fourth sound channel signal, the program or the instruction is executed by the processor to implement the following steps: predicting an orientation of each speaker in a plurality of speakers of the electronic device after the target state of the electronic device changes; and in a case that a sound channel currently played by a target speaker in the plurality of speakers does not match a predicted orientation of the target speaker, determining that the target speaker is a to-be-switched speaker, wherein a speaker that currently plays the first sound channel signal in the speaker to be switched is the first speaker, and a speaker that currently plays the second sound channel signal in the speaker to be switched is the second speaker.
- 13 . A non-transitory readable storage medium, wherein a program or an instruction is stored on the non-transitory readable storage medium, and the program or the instruction is executed by a processor of an electronic device to implement the following steps: obtaining a state change parameter of the electronic device in a case that the electronic device plays audio and a target state of the electronic device changes, wherein the state change parameter comprises a folding angle, a rotation angle, or a scaling amplitude, and the scaling amplitude is a scaling amplitude of a screen of the electronic device; fusing a first sound channel signal and a second sound channel signal according to the state change parameter in a first fusion manner to obtain a third sound channel signal, and fusing the first sound channel signal and the second sound channel signal in a second fusion manner to obtain a fourth sound channel signal; and controlling a first speaker to switch from playing the first sound channel signal to playing the third sound channel signal, and controlling a second speaker to switch from playing the second sound channel signal to playing the fourth sound channel signal, wherein before a sound channel signal is switched, sound channels played by the first speaker and the second speaker do not match orientations in which the first speaker and the second speaker are located; wherein the fusing a first sound channel signal and a second sound channel signal according to the state change parameter in a first fusion manner to obtain a third sound channel signal, and fusing the first sound channel signal and the second sound channel signal in a second fusion manner to obtain a fourth sound channel signal comprises: separately obtaining a first spectrum amplitude value of the first sound channel signal and a second spectrum amplitude value of the second sound channel signal; determining a fusion component according to the state change parameter, the first spectrum amplitude value, and the second spectrum amplitude value; performing first operation processing on the first spectrum amplitude value and the fusion component to obtain a third spectrum amplitude value of the fused third sound channel signal; and performing second operation processing on the second spectrum amplitude value and the fusion component to obtain a fourth spectrum amplitude value of the fused fourth sound channel signal.
- 14 . The non-transitory readable storage medium according to claim 13 , wherein the determining a fusion component according to the state change parameter, the first spectrum amplitude value, and the second spectrum amplitude value comprises: determining a state coefficient according to the state change parameter and a maximum change value of the target state; and calculating a product of the state coefficient and a first difference to obtain the fusion component, wherein the first difference is a difference between the first spectrum amplitude value and the second spectrum amplitude value.
- 15 . The non-transitory readable storage medium according to claim 14 , wherein the performing first operation processing on the first spectrum amplitude value and the fusion component to obtain a third spectrum amplitude value of the fused third sound channel signal comprises: subtracting the fusion component from the first spectrum amplitude value to obtain the third spectrum amplitude value; and the performing second operation processing on the second spectrum amplitude value and the fusion component to obtain a fourth spectrum amplitude value of the fused fourth sound channel signal comprises: adding the second spectrum amplitude value and the fusion component to obtain the fourth spectrum amplitude value.
- 16 . The non-transitory readable storage medium according to claim 14 , wherein when the state change parameter is a folding angle, the maximum change value of the target state is 180 degrees; when the state change parameter is a rotation angle, the maximum change value of the target state is 90 degrees or 180 degrees; or when the state change parameter is a scaling amplitude, the maximum change value of the target state is a maximum scaling amplitude of the screen of the electronic device.
- 17 . The non-transitory readable storage medium according to claim 13 , wherein the separately obtaining a first spectrum amplitude value of the first sound channel signal and a second spectrum amplitude value of the second sound channel signal comprises: separately obtaining a first amplitude characteristic of the first sound channel signal in a frequency domain and a second amplitude characteristic of the second sound channel signal in the frequency domain; and separately converting the first amplitude characteristic and the second amplitude characteristic into spectrum amplitude values, so as to obtain the first spectrum amplitude value and the second spectrum amplitude value.
Description
CROSS-REFERENCE TO RELATED APPLICATIONS This application is a continuation of PCT International Application No. PCT/CN2022/109706 filed on Aug. 2, 2022, which claims priority to Chinese Patent Application No. 202110901164.1 filed on Aug. 6, 2021, which are incorporated herein by reference in their entireties. TECHNICAL FIELD This application relates to the field of communication technologies, and specifically relates to a sound channel switching method and apparatus, and an electronic device. BACKGROUND Currently, many electronic devices are equipped with a plurality of speakers, and audio of different sound channels is played by using speakers in different orientations, to implement a stereo play effect. Taking an electronic device with four speakers as an example, a left sound channel is generally played by using two speakers at the top of the electronic device, and a right sound channel is played by using two speakers at the bottom to implement a stereo effect. However, when the electronic device switches a state, for example, is rotated or folded, an orientation of a speaker changes. In this case, sound channel signals played by some speakers do not match human ears, thereby affecting a stereo play effect. SUMMARY According to a first aspect, an embodiment of this application provides a sound channel switching method, applied to an electronic device, where the method includes: obtaining a state change parameter of the electronic device in a case that the electronic device plays audio and a target state of the electronic device changes, where the state change parameter includes a folding angle, a rotation angle, or a scaling amplitude, and the scaling amplitude is a scaling amplitude of a screen of the electronic device;fusing a first sound channel signal and a second sound channel signal according to the state change parameter in a first fusion manner to obtain a third sound channel signal, and fusing the first sound channel signal and the second sound channel signal in a second fusion manner to obtain a fourth sound channel signal; andcontrolling a first speaker to switch from playing the first sound channel signal to playing the third sound channel signal, and controlling a second speaker to switch from playing the second sound channel signal to playing the fourth sound channel signal, where before a sound channel signal is switched, sound channels played by the first speaker and the second speaker do not match orientations in which the first speaker and the second speaker are located. According to a second aspect, an embodiment of this application provides a sound channel switching apparatus, applied to an electronic device, where the sound channel switching apparatus includes: an obtaining module, configured to obtain a state change parameter of the electronic device in a case that the electronic device plays audio and a target state of the electronic device changes, where the state change parameter includes a folding angle, a rotation angle, or a scaling amplitude, and the scaling amplitude is a scaling amplitude of a screen of the electronic device;a processing module, configured to: fuse a first sound channel signal and a second sound channel signal according to the state change parameter in a first fusion manner to obtain a third sound channel signal, and fuse the first sound channel signal and the second sound channel signal in a second fusion manner to obtain a fourth sound channel signal; anda control module, configured to: control a first speaker to switch from playing the first sound channel signal to playing the third sound channel signal, and control a second speaker to switch from playing the second sound channel signal to playing the fourth sound channel signal, where before a sound channel signal is switched, sound channels played by the first speaker and the second speaker do not match orientations in which the first speaker and the second speaker are located. According to a third aspect, an embodiment of this application provides an electronic device. The electronic device includes a processor, a memory, and a program or an instruction that is stored in the memory and that can be run on the processor, and the program or the instruction is executed by the processor to implement the steps of the sound channel switching method according to the first aspect. According to a fourth aspect, an embodiment of this application provides a readable storage medium. The readable storage medium stores a program or an instruction, and the program or the instruction is executed by a processor to implement the steps of the sound channel switching method according to the first aspect. According to a fifth aspect, an embodiment of this application provides a chip. The chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is configured to run a program or an instruction to implement the steps of the sound channel switching meth