WO2017101260A1 - Method, device, and storage medium for audio switching - Google Patents

Method, device, and storage medium for audio switching Download PDF

Info

Publication number
WO2017101260A1
WO2017101260A1 PCT/CN2016/084260 CN2016084260W WO2017101260A1 WO 2017101260 A1 WO2017101260 A1 WO 2017101260A1 CN 2016084260 W CN2016084260 W CN 2016084260W WO 2017101260 A1 WO2017101260 A1 WO 2017101260A1
Authority
WO
WIPO (PCT)
Prior art keywords
audio segment
audio
segment
length
file
Prior art date
Application number
PCT/CN2016/084260
Other languages
French (fr)
Chinese (zh)
Inventor
冯穗豫
Original Assignee
广州酷狗计算机科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 广州酷狗计算机科技有限公司 filed Critical 广州酷狗计算机科技有限公司
Publication of WO2017101260A1 publication Critical patent/WO2017101260A1/en

Links

Images

Classifications

    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11BINFORMATION STORAGE BASED ON RELATIVE MOVEMENT BETWEEN RECORD CARRIER AND TRANSDUCER
    • G11B27/00Editing; Indexing; Addressing; Timing or synchronising; Monitoring; Measuring tape travel
    • G11B27/02Editing, e.g. varying the order of information signals recorded on, or reproduced from, record carriers
    • G11B27/031Electronic editing of digitised analogue information signals, e.g. audio or video signals
    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11BINFORMATION STORAGE BASED ON RELATIVE MOVEMENT BETWEEN RECORD CARRIER AND TRANSDUCER
    • G11B27/00Editing; Indexing; Addressing; Timing or synchronising; Monitoring; Measuring tape travel
    • G11B27/10Indexing; Addressing; Timing or synchronising; Measuring tape travel

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Reverberation, Karaoke And Other Acoustics (AREA)
  • Electrophonic Musical Instruments (AREA)

Abstract

Provided in the embodiments of the present invention are a method, a device, and a storage medium for audio switching. The method comprises: acquiring an audio file, the audio file being composed by splicing of a first audio clip and a second audio clip; when an audio clip switching operation is detected during the playback of the first audio clip, acquiring a current played length of the first audio clip, the current played length being the distance from the current playing position to the starting position of the audio file; and playing, in response to the audio clip switching operation, the audio from a target position of the audio file, the target position being a playing position on the second audio clip that the current played length of the first audio clip corresponds to.

Description

音频切换方法、装置以及存储介质Audio switching method, device and storage medium
本申请要求于2015年12月15日提交中国专利局、申请号为201510934171.6、发明名称为“音频切换方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 201510934171.6, entitled "Audio Switching Method and Apparatus", filed on Dec. 15, 2015, the entire disclosure of which is hereby incorporated by reference.
技术领域Technical field
本发明涉及互联网技术领域,特别涉及一种音频切换方法、装置以及存储介质。The present invention relates to the field of Internet technologies, and in particular, to an audio switching method, apparatus, and storage medium.
背景技术Background technique
随着生活水平的提高,K歌在人们的生活中已经越来越普遍,而且越来越多的用户选择通过终端应用进行K歌,从而足不出户就能享受K歌的乐趣,在K歌演唱过程中,用户一般选择播放歌曲伴奏,然而,当出现用户不会演唱的歌曲段落时,用户则需要将歌曲伴奏切换至歌曲原唱。With the improvement of living standards, K songs have become more and more popular in people's lives, and more and more users choose to use K songs through terminal applications, so that they can enjoy the fun of K songs without leaving home. During the singing process, the user generally chooses to play the song accompaniment. However, when there is a song passage that the user does not sing, the user needs to switch the song accompaniment to the original song of the song.
为了实现歌曲伴奏与歌曲原唱之间的切换,需要使用两个独立的音频文件,即伴奏文件和原唱文件,该原唱文件包括歌曲伴奏及歌曲人声演唱,并同时对这两个音频文件进行解码,当检测到用户的切换操作时,即从伴奏文件的当前播放位置跳转至原唱文件相同的播放位置,以保证播放的连续性。In order to switch between song accompaniment and song original sing, two separate audio files, accompaniment files and original vocal files, including song accompaniment and song vocals, and both audios are required. The file is decoded. When the user's switching operation is detected, the current playback position of the accompaniment file is jumped to the same playback position as the original singer file to ensure the continuity of the playback.
发明内容Summary of the invention
本发明实施例提供了一种音频切换方法、装置以及存储介质。Embodiments of the present invention provide an audio switching method, apparatus, and storage medium.
本发明实施例所提供的一种音频切换方法方法包括:An audio switching method method provided by an embodiment of the present invention includes:
获取音频文件,所述音频文件由第一音频片段和第二音频片段拼接组成;Acquiring an audio file, the audio file being composed of a first audio segment and a second audio segment;
在播放所述第一音频片段的过程中检测到音频片段切换操作,获取所述第一音频片段当前播放长度,所述当前播放长度为当前播放位置距所述音频文件起始位置的距离;And detecting an audio segment switching operation in the process of playing the first audio segment, and acquiring a current playing length of the first audio segment, where the current playing length is a distance from a starting position of the audio file of the current playing position;
响应所述音频片段切换操作,从所述音频文件的目标位置进行播放,所述目标位置为与所述第一音频片段当前播放长度所对应的第二音频片段上的播 放位置。Playing in a target position of the audio file in response to the audio segment switching operation, the target location being a broadcast on a second audio segment corresponding to a current play length of the first audio segment Put the position.
本发明实施例所提供的一种音频切换装置包括:处理器和存储有操作指令的存储介质,当运行所述存储介质中的操作指令时,所处处理器执行如下步骤:An audio switching device provided by an embodiment of the present invention includes: a processor and a storage medium storing an operation instruction, when the operation instruction in the storage medium is executed, the processor executed performs the following steps:
获取音频文件,所述音频文件由第一音频片段和第二音频片段拼接组成;Acquiring an audio file, the audio file being composed of a first audio segment and a second audio segment;
在播放所述第一音频片段的过程中检测到音频片段切换操作,获取所述第一音频片段当前播放长度,所述当前播放长度为当前播放位置距所述音频文件起始位置的距离;And detecting an audio segment switching operation in the process of playing the first audio segment, and acquiring a current playing length of the first audio segment, where the current playing length is a distance from a starting position of the audio file of the current playing position;
响应所述音频片段切换操作,从所述音频文件的目标位置进行播放,所述目标位置为与所述第一音频片段当前播放长度所对应的第二音频片段上的播放位置。In response to the audio segment switching operation, playing from a target location of the audio file, the target location being a playback location on a second audio segment corresponding to a current playback length of the first audio segment.
本发明实施例提供的一种非瞬时性的计算机可读存储介质,其上存储有计算机可执行指令,当计算机中运行这些可执行指令时,执行如下步骤:A non-transitory computer readable storage medium is provided with computer executable instructions. When the executable instructions are run in a computer, the following steps are performed:
获取音频文件,所述音频文件由第一音频片段和第二音频片段拼接组成;Acquiring an audio file, the audio file being composed of a first audio segment and a second audio segment;
在播放所述第一音频片段的过程中检测到音频片段切换操作,获取所述第一音频片段当前播放长度,所述当前播放长度为当前播放位置距所述音频文件起始位置的距离;And detecting an audio segment switching operation in the process of playing the first audio segment, and acquiring a current playing length of the first audio segment, where the current playing length is a distance from a starting position of the audio file of the current playing position;
响应所述音频片段切换操作,从所述音频文件的目标位置进行播放,所述目标位置为与所述第一音频片段当前播放长度所对应的第二音频片段上的播放位置。In response to the audio segment switching operation, playing from a target location of the audio file, the target location being a playback location on a second audio segment corresponding to a current playback length of the first audio segment.
通过提供由第一音频片段和第二音频片段拼接而成的音频文件,且当检测到音频切换操作时,在同一个音频文件内部进行播放进度的跳转,使得终端仅使用一个音频文件就可以实现第一音频片段和第二音频片段之间的切换,从而不需要同时解码两个音频文件,也不需要解码器支持多声道和多音频流的解码能力,因此对所有的应用均具有适配性。By providing an audio file spliced by the first audio segment and the second audio segment, and when an audio switching operation is detected, a playback progress jump is performed inside the same audio file, so that the terminal can use only one audio file. Realizing the switching between the first audio segment and the second audio segment, so that it is not necessary to decode two audio files at the same time, and the decoder does not need to support the decoding capability of multi-channel and multi-audio streams, so it is suitable for all applications. Matching.
附图说明DRAWINGS
图1是根据一示例性实施例示出的一种音频切换方法的流程图;FIG. 1 is a flowchart of an audio switching method according to an exemplary embodiment;
图2是根据一示例性实施例示出的一种音频切换方法的流程图; FIG. 2 is a flowchart of an audio switching method according to an exemplary embodiment;
图3是根据一示例性实施例示出的音频播放界面的示意图;FIG. 3 is a schematic diagram of an audio play interface, according to an exemplary embodiment; FIG.
图4是根据一示例性实施例示出的一种音频切换装置500框图;FIG. 4 is a block diagram of an audio switching device 500 according to an exemplary embodiment;
图5是根据一示例性实施例示出的一种音频切换装置600框图;以及FIG. 5 is a block diagram of an audio switching device 600 according to an exemplary embodiment;
图6是根据一示例性实施例示出的一种终端700的结构示意图。FIG. 6 is a schematic structural diagram of a terminal 700 according to an exemplary embodiment.
具体实施方式detailed description
为使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式作进一步地详细描述。The embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
图1是根据一示例性实施例示出的一种音频切换方法的流程图,该方法可以应用于手机、个人电脑、平板电脑等终端,如图1所示,该音频切换方法包括步骤101至步骤103。FIG. 1 is a flowchart of an audio switching method according to an exemplary embodiment. The method may be applied to a mobile phone, a personal computer, a tablet computer, etc., as shown in FIG. 1 , the audio switching method includes steps 101 to 103.
在步骤101中,终端获取音频文件,该音频文件由第一音频片段和第二音频片段拼接组成。In step 101, the terminal acquires an audio file, which is composed of a first audio segment and a second audio segment.
在步骤102中,在终端播放第一音频片段的过程中检测到音频切换操作时,,终端获取第一音频片段当前播放长度,该播放长度为当前播放位置距该音频文件起始位置的距离。In step 102, when the audio switching operation is detected in the process of playing the first audio segment, the terminal acquires the current playing length of the first audio segment, and the playing length is the distance of the current playing position from the starting position of the audio file.
在步骤103中,终端响应该音频片段切换操作,从该音频文件的目标位置进行播放,该目标位置为与第一音频片段当前播放长度所对应的第二音频片段上的播放位置。In step 103, the terminal performs playback from the target location of the audio file in response to the audio segment switching operation, the target location being a playback position on the second audio segment corresponding to the current playback length of the first audio segment.
综上所述,本实施例提供的音频切换方法,通过提供由第一音频片段和第二音频片段拼接而成的音频文件,且当检测到音频切换操作时,在同一个音频文件内部进行播放进度的跳转,使得终端仅使用一个音频文件就可以实现第一音频片段和第二音频片段之间的切换,从而不需要同时解码两个音频文件,也不需要解码器支持多声道和多音频流的解码能力,因此对所有的应用均具有适配性。In summary, the audio switching method provided by this embodiment provides an audio file formed by splicing a first audio segment and a second audio segment, and plays inside the same audio file when an audio switching operation is detected. The jump of the progress enables the terminal to switch between the first audio segment and the second audio segment using only one audio file, so that it is not necessary to decode two audio files at the same time, and the decoder does not need to support multiple channels and multiple The decoding capability of the audio stream is therefore adaptable to all applications.
在一种可能的实施方式中,第一音频片段和第二音频片段长度相同;In a possible implementation manner, the first audio segment and the second audio segment are the same length;
当第一音频片段位于第二音频片段之前时,目标位置距离音频文件起始位置的距离为第一音频片段的长度与第一音频片段当前播放长度之和;When the first audio segment is located before the second audio segment, the distance of the target location from the start position of the audio file is the sum of the length of the first audio segment and the current playing length of the first audio segment;
当第一音频片段位于第二音频片段之后时,目标位置距离音频文件起始位 置的距离为第二音频片段的长度与第一音频片段当前播放长度之差。When the first audio segment is located behind the second audio segment, the target position is away from the audio file start bit The set distance is the difference between the length of the second audio segment and the current playback length of the first audio segment.
在一种可能的实施方式中,该获取音频文件之前,上述音频切换方法还包括:In a possible implementation, before the acquiring the audio file, the audio switching method further includes:
获取第一音频片段和第二音频片段;Obtaining the first audio segment and the second audio segment;
对齐第一音频片段和第二音频片段,以使该第一音频片段和第二音频片段同步;以及Aligning the first audio segment and the second audio segment to synchronize the first audio segment with the second audio segment;
拼接第一音频片段和第二音频片段。The first audio segment and the second audio segment are spliced.
在一种可能的实施方式中,当第一音频片段和第二音频片段的长度不是预设长度的整数倍时,该音频切换方法还包括:In a possible implementation manner, when the lengths of the first audio segment and the second audio segment are not integer multiples of the preset length, the audio switching method further includes:
修整第一音频片段的长度或第二音频片段的长度至预设长度的整数倍。The length of the first audio segment or the length of the second audio segment is trimmed to an integer multiple of the preset length.
在一种可能的实施方式中,修整第一音频片段或第二音频片段的长度至预设长度的整数倍包括:In a possible implementation, trimming the length of the first audio segment or the second audio segment to an integer multiple of the preset length includes:
获取第一音频片段和第二音频片段的采样点数目;Obtaining the number of sampling points of the first audio segment and the second audio segment;
根据扩充公式计算该第一音频片段或第二音频片段的扩充采样点数目,该扩充公式为:Calculating the number of extended sampling points of the first audio segment or the second audio segment according to the expansion formula, the expansion formula is:
Lf=N×Int((Lo+N-1)/N)L f =N×Int((L o +N-1)/N)
其中,Lf为该扩充采样点数目,Lo为第一音频片段或第二音频片段的采样点数目,N为该预设长度,Int为取整运算;Wherein, L f is the number of the extended sampling points, L o is the number of sampling points of the first audio segment or the second audio segment, N is the preset length, and Int is a rounding operation;
在第一音频片段和第二音频片段的尾部拼接第一静音片段,以将第一音频片段和第二音频片段的采样点数目扩充至该扩充采样点数目。The first mute segment is spliced at the end of the first audio segment and the second audio segment to expand the number of sampling points of the first audio segment and the second audio segment to the number of the extended sampling points.
在一种可能的实施方式中,将第一音频片段和第二音频片段的长度修整至预设长度的倍数之前,上述音频切换方法还包括:In a possible implementation, before the length of the first audio segment and the second audio segment are trimmed to a multiple of the preset length, the audio switching method further includes:
检测第一音频片段和第二音频片段的长度是否相等;Detecting whether the lengths of the first audio segment and the second audio segment are equal;
若第一音频片段和第二音频片段的长度不相等,则获取长度差值,该长度差值为第一音频片段和第二音频片段的长度差;If the lengths of the first audio segment and the second audio segment are not equal, obtaining a length difference, where the length difference is a difference in length between the first audio segment and the second audio segment;
将第二静音片段拼接至第一音频片段和第二音频片段中长度较短的音频文件尾部,该第二静音片段的长度为该长度差值。The second mute segment is spliced to the shorter end of the audio file in the first audio segment and the second audio segment, the length of the second mute segment being the length difference.
在一种可能的实施方式中,获取第一音频片段和第二音频片段之后,上述音频切换方法还包括: In a possible implementation, after the acquiring the first audio segment and the second audio segment, the audio switching method further includes:
分别检测第一音频片段和第二音频片段的尾部静音片段是否超过预设阈值;Detecting whether the tail mute segment of the first audio segment and the second audio segment exceeds a preset threshold, respectively;
若超过该预设阈值,则剪切第一音频片段和第二音频片段的尾部静音片段。If the preset threshold is exceeded, the trailing mute segments of the first audio segment and the second audio segment are cut.
在一种可能的实施方式中,得到该音频文件之后,上述音频切换方法还包括:In a possible implementation, after the audio file is obtained, the audio switching method further includes:
将该修整后第一音频片段的长度添加至该音频文件的标签中。The length of the trimmed first audio segment is added to the label of the audio file.
在一种可能的实施方式中,该根据用户的播放选择操作,播放该音频文件之前,上述音频切换方法还包括:In a possible implementation, the audio switching method further includes: before the playing the audio file according to the user's play selection operation, the audio switching method further includes:
从该音频文件的标签中获取第一音频片段的长度;Obtaining the length of the first audio segment from the label of the audio file;
或者,or,
在获取该音频文件时,从音频数据库中,获取第一音频片段的长度,该音频数据库用于存储音频文件和对应第一音频片段长度;Obtaining, in the audio database, a length of the first audio segment, where the audio database is used to store the audio file and the corresponding first audio segment length;
或者,or,
获取该音频文件总长度;Get the total length of the audio file;
获取该伴奏音频片段的长度,第一音频片段的长度为该音频文件总长度的二分之一。The length of the accompaniment audio segment is obtained, and the length of the first audio segment is one-half of the total length of the audio file.
在一种可能的实施方式中,该播放该音频文件之后,上述音频切换方法还包括:In a possible implementation, after the playing the audio file, the audio switching method further includes:
在播放该音频文件时,检测该播放长度与第一音频片段的长度是否相等;When playing the audio file, detecting whether the play length is equal to the length of the first audio segment;
若该播放长度与第一音频片段的长度相等,则停止播放该音频文件。If the play length is equal to the length of the first audio segment, the playback of the audio file is stopped.
上述所有可选实施方式中,可以采用任意结合形成本发明的可选实施例,在此不再一一赘述。In any of the foregoing optional embodiments, any combination of the embodiments may be used to form an optional embodiment of the present invention, and details are not described herein again.
在上述所有可选实施方式中,第一音频片段可以是一首歌曲的伴奏音频片段,第二音频片段可以是该歌曲的原唱音频片段;或者,第一音频片段可以是一首歌曲的原唱音频片段,第二音频片段可以是该歌曲的伴奏音频片段。In all the above optional embodiments, the first audio segment may be an accompaniment audio segment of a song, and the second audio segment may be an original audio segment of the song; or the first audio segment may be the original of a song. The audio clip is sung, and the second audio clip can be an accompaniment audio clip of the song.
图2是根据一示例性实施例示出的一种音频切换方法的流程图,该方法可以应用于服务器,也可以应用于手机、个人电脑、平板电脑等终端,还可以应用于服务器和终端。本实施例以K歌场景中,伴奏和原唱之间的切换为例, 对音频切换方法进行描述,如图2所示,该音频切换方法包括步骤201至步骤210。FIG. 2 is a flowchart of an audio switching method according to an exemplary embodiment. The method may be applied to a server, and may also be applied to a terminal such as a mobile phone, a personal computer, a tablet computer, and the like, and may also be applied to a server and a terminal. In this embodiment, the switching between the accompaniment and the original vocal in the K song scene is taken as an example. The audio switching method is described. As shown in FIG. 2, the audio switching method includes steps 201 to 210.
在步骤201中,获取伴奏音频文件和原唱音频文件。In step 201, an accompaniment audio file and an original singer audio file are acquired.
需要说明的是,上述伴奏音频文件和原唱音频文件可以为立体声音频文件,上述伴奏音频文件可以是仅包括歌曲伴奏的音频文件,而上述原唱音频文件可以是包括歌曲伴奏和歌曲人声演唱的音频文件,且,上述伴奏音频文件与上述原唱音频文件具有对应关系,例如,若上述伴奏音频文件为“歌曲A”伴奏音频,则上述原唱音频文件应该是“歌曲A”原唱音频。It should be noted that the accompaniment audio file and the original singer audio file may be stereo audio files, and the accompaniment audio file may be an audio file including only song accompaniment, and the original vocal audio file may include song accompaniment and song vocal singing. The audio file, and the accompaniment audio file has a corresponding relationship with the original vocal audio file. For example, if the accompaniment audio file is the "song A" accompaniment audio, the original vocal audio file should be the "song A" original singer audio. .
另外,由于PCM(Pulse Code Modulation,脉冲编码调制)格式的音频文件便于后续补齐、剪切、拼接等操作,因此上述伴奏音频文件和原唱音频文件的格式可以为PCM格式,若上述伴奏音频文件和原唱音频文件的格式为WMA(Windows Media Audio,微软多媒体音频)格式、AAC(Advanced Audio Coding,高级音频编码)格式等其他音频格式时,可以将其转化为PCM格式,以方便进行后续的操作,当然上述伴奏音频文件和原唱音频文件的格式还可以为其他便于补齐、剪切、拼接等操作的格式,对此本发明不做具体限定。In addition, since the audio file of the PCM (Pulse Code Modulation) format facilitates subsequent operations of complementing, cutting, splicing, etc., the format of the accompaniment audio file and the original singer audio file may be in the PCM format, if the above accompaniment audio When the format of the file and the original singer audio file is WMA (Windows Media Audio, Microsoft Multimedia Audio) format, AAC (Advanced Audio Coding) format and other audio formats, it can be converted into PCM format to facilitate subsequent For example, the format of the accompaniment audio file and the original singer audio file may be other formats that are convenient to complete, cut, splicing, etc., and the invention is not specifically limited.
步骤201中获取的伴奏音频文件和原唱音频文件可能会在文件的头部或尾部存在静音片段,这些静音片段对后续伴奏音频文件和原唱音频文件的拼接等操作没有贡献,而且过长的静音片段会增加伴奏音频文件和原唱音频文件的大小,从而造成存储空间的浪费,因此,在本发明的一个实施例中,步骤201之后,上述音频切换方法还可以包括如下步骤:分别检测该伴奏音频文件和该原唱音频文件的头部静音片段和尾部静音片段是否超过预设阈值;若超过该预设阈值,则剪切该伴奏音频文件和该原唱音频文件的头部静音片段以及尾部静音片段。The accompaniment audio file and the original singer audio file acquired in step 201 may have silent segments at the head or the tail of the file, and these silent segments do not contribute to operations such as splicing of subsequent accompaniment audio files and original singer audio files, and are too long. The mute segment may increase the size of the accompaniment audio file and the original singer audio file, thereby causing waste of the storage space. Therefore, in an embodiment of the present invention, after the step 201, the audio switching method may further include the following steps: respectively detecting the Whether the accompaniment audio file and the head mute segment and the tail mute segment of the original audio file exceed a preset threshold; if the preset threshold is exceeded, the accompaniment audio file and the head mute segment of the original audio file are cut and Mute the tail.
需要注意的是,上述预设阈值可以由根据实际应用进行设定,对预设阈值的具体内容本发明不做限定。It should be noted that the preset threshold may be set according to an actual application, and the specific content of the preset threshold is not limited in the present invention.
在步骤202中,对齐该伴奏音频文件和该原唱音频文件,以使该伴奏音频文件和该原唱音频文件同步。In step 202, the accompaniment audio file and the original vocal audio file are aligned to synchronize the accompaniment audio file with the original vocal audio file.
步骤201中获取的伴奏音频文件和原唱音频文件虽然具有对应关系,但该伴奏音频文件和原唱音频文件却不一定同步,也即是伴奏音频文件可能较原唱 音频文件提前或落后,例如,在距文件起始位置同样距离的播放位置上,伴奏音频文件可能播放到“片段a”对应的伴奏,而原唱音频文件却播放到“片段b”,伴奏音频文件和原唱音频文件不同步会导致后续伴奏与原唱切换时,切换位置错误,从而无法保证播放的连续性。Although the accompaniment audio file obtained in step 201 has a corresponding relationship with the original singer audio file, the accompaniment audio file and the original singer audio file are not necessarily synchronized, that is, the accompaniment audio file may be compared with the original vocal The audio file is advanced or behind. For example, in the playback position at the same distance from the beginning of the file, the accompaniment audio file may play to the accompaniment corresponding to “segment a”, while the original audio file is played to “segment b”, accompaniment audio. If the file and the original vocal audio file are out of sync, the switching position will be wrong when the subsequent accompaniment and the original singer are switched, and the continuity of the playback cannot be guaranteed.
为了解决这一问题,执行步骤202,即对齐伴奏音频文件和原唱音频文件,具体实施时,可以采用PCM的互相关性等方式判断该伴奏音频文件和该原唱音频文件是否同步,若伴奏音频文件和原唱音频文件不同步,则可通过在文件开头添加静音片段的方式对齐伴奏音频文件和原唱音频文件,例如若伴奏音频文件较原唱音频文件提前30ms,则可以添加长度为30ms的静音片段至伴奏文件开头,从而对齐伴奏音频文件和原唱音频文件。In order to solve this problem, step 202 is performed, that is, the accompaniment audio file and the original singer audio file are aligned. In specific implementation, the PCM cross-correlation or the like can be used to determine whether the accompaniment audio file and the original singer audio file are synchronized, if the accompaniment If the audio file and the original audio file are out of sync, you can align the accompaniment audio file and the original vocal audio file by adding a mute clip at the beginning of the file. For example, if the accompaniment audio file is 30ms earlier than the original audio file, you can add a length of 30ms. The mute clip is to the beginning of the accompaniment file, thereby aligning the accompaniment audio file with the original singer audio file.
需要说明的是,步骤201中获取的伴奏音频文件和原唱音频文件可能是互相同步的音频文件,则在这种情况下,不需要再执行步骤202。It should be noted that the accompaniment audio file and the original singer audio file acquired in step 201 may be mutually synchronized audio files, and in this case, step 202 is not required to be performed.
在步骤203中,分别获取伴奏音频文件和该原唱音频文件的采样点数目。In step 203, the number of sample points of the accompaniment audio file and the original vocal audio file are respectively acquired.
当上述伴奏音频文件和原唱音频文件的格式均为PCM格式时,PCM格式下虽然方便对音频进行剪切、补齐、拼接等操作,然而这种格式的音频大小往往较大,因此,在网络传输时,需要较大的带宽,且需要较大的存储空间,因此,在通过后续拼接过程得到音频文件后,可以采用某种编码方式对该音频文件进行编码,以减小音频文件大小。When the format of the accompaniment audio file and the original singer audio file are both PCM format, although the PCM format is convenient for cutting, filling, splicing, etc., the audio size of the format is often large, so When the network is transmitted, a large bandwidth is required, and a large storage space is required. Therefore, after the audio file is obtained through the subsequent splicing process, the audio file may be encoded in a certain encoding manner to reduce the audio file size.
在编码过程中,不同的编码方式下一帧数据中包含的采样点的数目是不同的,例如,AAC编码格式中,一帧数据包括1024个采样点,这种情况下,若伴奏音频文件的采样点数目不为1024的倍数,在后续的拼接过程中,其最后一帧数据需要使用原唱音频文件的前部采样点来填充,这会导致后续伴奏与原唱切换过程中给应用程序带来复杂的计算逻辑。In the encoding process, the number of sampling points included in the next frame data of different encoding modes is different. For example, in the AAC encoding format, one frame of data includes 1024 sampling points, in this case, if the audio file is accompaniment The number of sampling points is not a multiple of 1024. In the subsequent splicing process, the last frame of data needs to be filled with the front sampling point of the original singer audio file, which causes the application to be carried during the subsequent accompaniment and original singer switching process. Come to complex calculation logic.
因此,为了避免这种情况,可以将上述伴奏音频文件和原唱音频文件的长度修整至预设长度的倍数,该预设长度由编码方式决定,对于AAC编码方式而言,该预设长度即为1024,在对长度进行修整之前,首先获取伴奏音频文件和原唱音频文件经过对齐操作后的采样点数目,也即是,执行步骤203,需要说明的是,这里和本发明下文所指的长度均为音频文件的采样点数目,在后面的叙述中本发明对此将不再赘述。 Therefore, in order to avoid this, the lengths of the accompaniment audio file and the original singer audio file may be trimmed to a multiple of a preset length, which is determined by the encoding mode. For the AAC encoding mode, the preset length is 1024, before trimming the length, first obtaining the number of sampling points after the accompaniment audio file and the original singer audio file are aligned, that is, performing step 203, which needs to be explained here and below. The length is the number of sampling points of the audio file, which will not be described in detail in the following description.
在步骤204中,根据扩充公式分别计算该伴奏音频文件和该原唱音频文件的扩充采样点数目。In step 204, the accompaniment audio file and the number of extended sampling points of the original audio file are separately calculated according to the expansion formula.
该扩充公式为:The expansion formula is:
Lf=N×Int((Lo+N-1)/N)L f =N×Int((L o +N-1)/N)
其中,Lf为该扩充采样点数目,Lo为伴奏音频文件或原唱音频文件的采样点数目,N为该预设长度,Int为取整运算。Where L f is the number of extended sampling points, L o is the number of sampling points of the accompaniment audio file or the original singer audio file, N is the preset length, and Int is a rounding operation.
上述扩充采样点数目即为上述预设长度的倍数,例如,在编码方式为AAC时,伴奏音频文件的长度为15013213个采样点,其不为1024的倍数,则可以通过上述扩充公式计算其需要扩充到多少个采样点数目才为1024的倍数,经过计算得出该伴奏音频文件的扩充采样点数目为15013888。The number of the extended sampling points is a multiple of the preset length. For example, when the encoding mode is AAC, the length of the accompaniment audio file is 15013213 sampling points, which is not a multiple of 1024, and the expansion formula can be used to calculate the need thereof. The number of sample points expanded to a multiple of 1024 is calculated, and the number of extended sample points of the accompaniment audio file is calculated to be 15013888.
在步骤205中,在该伴奏音频文件和该原唱音频文件的尾部拼接第一静音片段,以将该伴奏音频文件和该原唱音频文件的采样点数目扩充至该扩充采样点数目,从而得到修整伴奏音频文件和修整原唱音频文件。In step 205, the first mute segment is spliced at the tail of the accompaniment audio file and the original singer audio file to expand the number of sampling points of the accompaniment audio file and the original singer audio file to the number of the extended sampling points, thereby obtaining Trim the accompaniment audio file and trim the original vocal audio file.
如上述举例,伴奏音频文件原来的长度为15013213个采样点,其需要扩充至15013888个采样点,因此,需要在该伴奏音频文件的尾部拼接第一静音片段,该第一静音片段的长度即为15013888与15013213之差,也即是675个采样点。As an example, the original length of the accompaniment audio file is 15013213 sample points, which needs to be expanded to 15013888 sample points. Therefore, the first mute segment needs to be spliced at the end of the accompaniment audio file, and the length of the first mute segment is The difference between 15013888 and 15013213 is 675 sample points.
当然,步骤201中获取的伴奏音频文件和原唱音频文件的长度可能已经为上述预设长度的倍数,则在这种情况下,也可以不执行步骤203至205。Of course, the lengths of the accompaniment audio file and the original singer audio file acquired in step 201 may have been a multiple of the preset length, and in this case, steps 203 to 205 may not be performed.
为了简化后续伴奏与原唱切换过程中应用程序的计算逻辑,可以使伴奏音频文件和该原唱音频文件的长度相同,因此在本发明的一个实施例中,在步骤203之前,上述音频切换方法还可以包括如下步骤:检测该伴奏音频文件和该原唱音频文件的长度是否相等;若该伴奏音频文件和该原唱音频文件的长度不相等,则获取长度差值,该长度差值为该伴奏音频文件和该原唱音频文件的长度差;将第二静音片段拼接至该伴奏音频文件和该原唱音频文件中长度较短的音频文件尾部,该第二静音片段的长度为伴奏音频文件和原唱音频文件长度差值。In order to simplify the calculation logic of the application during the subsequent accompaniment and the original singer switching, the length of the accompaniment audio file and the original singer audio file may be the same, so in an embodiment of the present invention, before step 203, the above audio switching method The method may further include: detecting whether the length of the accompaniment audio file and the original singer audio file are equal; if the accompaniment audio file and the vocal audio file are not equal in length, acquiring a length difference, the length difference is The accompaniment audio file and the original singer audio file have a difference in length; the second mute segment is spliced to the accompaniment audio file and the shorter length of the audio file in the original singer audio file, and the length of the second mute segment is an accompaniment audio file The difference between the original and the original audio file length.
例如,伴奏音频文件的长度为1899456个采样点,而原唱音频文件的长度为1899654个采样点,则伴奏音频文件和原唱音频文件的长度不一致,通过计 算得出原唱音频文件的长度与伴奏音频文件的长度差值为198个采样点,因此,可以将第二静音片段拼接至长度较短的伴奏音频文件尾部,该第二静音片段的长度为198个采样点。For example, the length of the accompaniment audio file is 1899456 sample points, and the length of the original audio file is 1899654 sample points, the length of the accompaniment audio file and the original singer audio file are inconsistent. It can be calculated that the length of the original audio file and the length of the accompaniment audio file are 198 sample points. Therefore, the second mute segment can be stitched to the tail of the shorter length accompaniment audio file, and the length of the second mute segment is 198. Sample points.
在步骤206中,拼接该修整伴奏音频文件和该修整原唱音频文件,得到音频文件。In step 206, the trimmed accompaniment audio file and the trimmed original singer audio file are spliced to obtain an audio file.
为了使终端在利用该音频文件进行伴奏与原唱切换时对切换位置的计算准确,终端需要获知该音频文件中伴奏音频片段的长度,因此,在本发明的一个实施例中,在步骤206之后,上述音频切换方法还可以包括:将该修整伴奏音频文件的长度添加至该音频文件的标签中,该标签可以为ID3v2、APE TAG、CueSheet、MP4Chapters等,对上述标签的具体形式本发明不做限定,例如,该标签的内容可以为<ACCOMPANY-DURATION>=<15013888>,同样地,对上述标签的内容本发明也不做具体限定。In order to make the calculation of the switching position accurate when the terminal performs the accompaniment and the original singing by using the audio file, the terminal needs to know the length of the accompaniment audio segment in the audio file, and therefore, in one embodiment of the present invention, after step 206 The audio switching method may further include: adding the length of the trimmed accompaniment audio file to the label of the audio file, the label may be ID3v2, APE TAG, CueSheet, MP4Chapters, etc., and the specific form of the label does not be used in the present invention. For example, the content of the label may be <ACCOMPANY-DURATION>=<15013888>. Similarly, the content of the above label is not specifically limited in the present invention.
此外,在本发明的另一个实施例中,在步骤206之后,还可以将该修整伴奏音频文件的长度添加至音频数据库中,该音频数据库用于存储音频文件和对应的伴奏音频片段长度,当终端从该音频数据库中获取音频文件时,同时即可获取该修整伴奏音频文件的长度。In addition, in another embodiment of the present invention, after step 206, the length of the trimmed accompaniment audio file may also be added to an audio database for storing the audio file and the corresponding accompaniment audio segment length. When the terminal obtains an audio file from the audio database, the length of the trimmed accompaniment audio file can be obtained at the same time.
需要说明的是,上述步骤201至206可以由服务器执行,终端可以通过向服务器发送音频获取请求的方式获取该音频文件,在一些情况中,上述步骤201至206也可以由终端执行,即终端在播放该音频文件前,首先制作该音频文件,对此本发明不做具体限定。It should be noted that the foregoing steps 201 to 206 may be performed by the server, and the terminal may acquire the audio file by sending an audio acquisition request to the server. In some cases, the foregoing steps 201 to 206 may also be performed by the terminal, that is, the terminal is Before the audio file is played, the audio file is first created, and the present invention is not limited thereto.
需要说明的是,在具体的音频切换过程中,服务器或终端可能已经制作出了该音频文件,因此,在具体的音频切换过程中,可以不执行步骤201至206的内容。It should be noted that, in a specific audio switching process, the server or the terminal may have created the audio file, and therefore, in the specific audio switching process, the contents of steps 201 to 206 may not be performed.
在步骤207中终端音频文件,该音频文件由伴奏音频片段和原唱音频片段拼接组成。In step 207, the terminal audio file is composed of splicing of the accompaniment audio segment and the original singer audio segment.
例如,终端可以提供K歌界面,该K歌界面可以提供多个音频,当检测到对某个音频的播放选项的触发操作时,向服务器发送音频文件获取请求,该音频文件获取请求携带该音频文件的标识,服务器根据该音频文件的标识返回该音频文件。 For example, the terminal may provide a K song interface, and the K song interface may provide a plurality of audios, and when detecting a triggering operation on a certain audio playing option, send an audio file obtaining request to the server, where the audio file obtaining request carries the audio The identifier of the file, and the server returns the audio file according to the identifier of the audio file.
该音频文件还可以存储于终端中,则当终端检测到对该音频文件的播放选项的触发操作时,获取该音频文件的标识对应的存储地址,则终端可以根据该存储地址从本地获取该音频文件,本发明对音频文件的获取方式不做具体限定。The audio file may be stored in the terminal, and when the terminal detects the triggering operation of the play option of the audio file, and obtains a storage address corresponding to the identifier of the audio file, the terminal may obtain the audio locally according to the storage address. The file, the method for obtaining an audio file in the present invention is not specifically limited.
终端在获取音频文件时,也需要获取该音频文件中伴奏音频片段的长度,以方便进行伴奏与原唱之间的切换,具体实施时,可以有以下三种获取伴奏音频片段长度的方法。When acquiring the audio file, the terminal also needs to obtain the length of the accompaniment audio segment in the audio file to facilitate the switching between the accompaniment and the original vocal. In the specific implementation, there are three methods for obtaining the length of the accompaniment audio segment.
第一种方法、从该音频文件的标签中获取该伴奏音频片段的长度。In the first method, the length of the accompaniment audio segment is obtained from the label of the audio file.
通过拼接得到该音频文件后,可以将伴奏音频片段的长度添加至该音频文件的标签中,对应地,终端可以通过读取该音频文件的标签以获取该伴奏音频片段的长度。After the audio file is obtained by splicing, the length of the accompaniment audio segment can be added to the label of the audio file. Correspondingly, the terminal can read the label of the audio file to obtain the length of the accompaniment audio segment.
第二种方法、在获取该音频文件时,从音频数据库中,获取该伴奏音频片段的长度,该音频数据库用于存储音频文件和对应的伴奏音频片段长度。The second method, when acquiring the audio file, acquires the length of the accompaniment audio segment from the audio database, and the audio database is used to store the audio file and the corresponding accompaniment audio segment length.
通过拼接得到该音频文件后,可以将该伴奏音频片段的长度添加至音频数据库中,终端在从该音频数据库中获取音频文件时,即可同时获取该伴奏音频片段的长度。After the audio file is obtained by splicing, the length of the accompaniment audio segment can be added to the audio database, and when the terminal obtains the audio file from the audio database, the length of the accompaniment audio segment can be simultaneously acquired.
第三种方法、获取该音频文件总长度,该伴奏音频片段的长度为该音频文件总长度的二分之一。A third method is to obtain a total length of the audio file, and the length of the accompaniment audio segment is one-half of the total length of the audio file.
在拼接伴奏音频文件和原唱音频文件之前,可以通过拼接第二静音片段的方式令伴奏音频文件和原唱音频文件的长度一致,因此,在拼接得到的音频文件中,伴奏音频片段的长度与原唱音频片段的长度一致,也即是整个音频文件总长度的二分之一,即,可以通过获取该音频文件总长度从而获取该伴奏音频片段的长度。然而,需要说明的是,该音频文件经过终端的某些解码器进行解码后,其总长度可能会发生变化,在这种情况下,不能采用第三种方法来获取伴奏音频片段的长度。Before splicing the accompaniment audio file and the original singer audio file, the length of the accompaniment audio file and the original singer audio file can be made consistent by splicing the second mute segment. Therefore, in the spliced audio file, the length of the accompaniment audio segment is The length of the original singer audio clip is the same, that is, one-half of the total length of the entire audio file, that is, the length of the accompaniment audio clip can be obtained by acquiring the total length of the audio file. However, it should be noted that the total length of the audio file may be changed after being decoded by some decoders of the terminal. In this case, the third method cannot be used to obtain the length of the accompaniment audio segment.
在步骤208中,终端根据用户的播放选择操作,播放该音频文件。In step 208, the terminal plays the audio file according to the user's play selection operation.
当终端检测到对该音频文件的播放选项的触发操作后,可以提供音频播放界面,如图4所示,该音频播放界面中可以提供播放原唱选项及播放伴奏选项,当检测到对该播放原唱选项的触发操作后,播放原唱音频片段,当检测到对该 播放伴奏选项的触发操作后,播放伴奏音频片段。After the terminal detects the triggering operation of the playing option of the audio file, an audio playing interface may be provided. As shown in FIG. 4, the original playing option and the playing accompaniment option may be provided in the audio playing interface, when the playing is detected. After the trigger operation of the original sing option, the original singer audio segment is played, when it is detected The accompaniment audio clip is played after the trigger operation of the Style option is played.
需要说明的是,当用户开始即选择播放伴奏音频片段时,此时,终端不确定用户是否需要播放原唱音频片段,因此,为了节约终端资源,可以仅对伴奏音频片段进行解码操作。It should be noted that when the user starts to select to play the accompaniment audio segment, at this time, the terminal is not sure whether the user needs to play the original vocal audio segment. Therefore, in order to save terminal resources, only the accompaniment audio segment can be decoded.
在步骤209中,如果在播放过程中检测到音频切换操作,终端获取当前所播放的音频片段的播放长度,该播放长度为当前播放位置距该音频文件起始位置的距离。In step 209, if an audio switching operation is detected during the playing, the terminal acquires the playing length of the currently played audio segment, and the playing length is the distance of the current playing position from the starting position of the audio file.
上述音频切换操作可以分为第一音频切换操作和第二音频切换操作,该第一音频切换操作可以为从伴奏切换至原唱的操作,该第二音频切换操作可以为从原唱切换至伴奏的操作。例如,当终端当前播放歌曲伴奏时,如图4所示的音频播放界面可以提供切换原唱选项,当检测到对该切换原唱选项的触发操作后,也即是终端检测到第一音频切换操作,当终端当前播放歌曲原唱时,该音频播放界面可以提供切换伴奏选项,当检测到对该切换伴奏选项的触发操作后,也即是终端检测到第二音频切换操作。The above audio switching operation may be divided into a first audio switching operation and an second audio switching operation, and the first audio switching operation may be an operation of switching from the accompaniment to the original singing, and the second audio switching operation may be switching from the original singing to the accompaniment. Operation. For example, when the terminal currently plays the song accompaniment, the audio play interface shown in FIG. 4 can provide the switch original singer option. When the trigger operation of the switch original sing option is detected, the terminal detects the first audio switch. Operation, when the terminal currently plays the original song of the song, the audio playing interface may provide a switching accompaniment option, and when the triggering operation of the switching accompaniment option is detected, that is, the terminal detects the second audio switching operation.
在步骤210中,终端从该音频文件的目标位置进行播放,该目标位置为与该当前所播放的音频片段的播放长度所对应的另一音频片段上的播放位置。In step 210, the terminal plays from a target location of the audio file, the target location being a playback location on another audio segment corresponding to the playback length of the currently played audio segment.
当上述音频切换操作为第一音频切换操作时,终端从该音频文件的第一目标位置继续进行播放,该第一目标位置距该音频文件起始位置的距离为该伴奏音频片段的长度与该播放长度之和。When the audio switching operation is the first audio switching operation, the terminal continues to play from the first target position of the audio file, and the distance of the first target position from the start position of the audio file is the length of the accompaniment audio segment and the The sum of the playback lengths.
例如,该伴奏音频片段的长度为15132个采样点,播放长度为151个采样点,则第一目标位置距该音频文件起始位置的距离为15132+151=15283个采样点。显而易见地,当上述音频切换操作为第一音频切换操作时,播放长度一定不大于该伴奏音频片段的长度。For example, the length of the accompaniment audio segment is 15132 sample points, and the playback length is 151 sample points, and the distance of the first target position from the start position of the audio file is 15132+151=15283 sample points. Obviously, when the above audio switching operation is the first audio switching operation, the playing length must not be greater than the length of the accompaniment audio segment.
当该音频切换操作为第二音频切换操作时,从该音频文件的第二目标位置继续进行播放,该第二目标位置距该音频文件起始位置的距离为该播放长度与该伴奏音频片段的长度之差。When the audio switching operation is the second audio switching operation, the playing is continued from the second target position of the audio file, and the distance of the second target position from the starting position of the audio file is the playing length and the accompaniment audio segment. The difference in length.
例如,该伴奏音频片段的长度为15132个采样点,播放长度为15283个采样点,则第二目标位置距该音频文件起始位置的距离为15283-15132=151个采样点。显而易见地,当上述音频切换操作为第二音频切换操作时,播放长度一 定大于该伴奏音频片段的长度,且播放长度一定小于该音频文件的总长度。For example, the length of the accompaniment audio segment is 15132 sample points, and the playback length is 15283 sample points, and the distance of the second target position from the start position of the audio file is 15283-15132=151 sample points. Obviously, when the above audio switching operation is the second audio switching operation, the playing length is one. It is greater than the length of the accompaniment audio segment, and the playback length must be less than the total length of the audio file.
终端播放该伴奏音频片段时,当该伴奏音频片段播放完毕后,不允许继续播放该伴奏音频片段之后的原唱音频片段,也即是,此时终端需要停止对该音频文件的播放,因此,在本发明的一个实施例中,上述音频切换方法还包括:终端在播放该音频文件时,检测该播放长度与该伴奏音频片段的长度是否相等,若该播放长度与该伴奏音频片段的长度相等,则停止播放该音频文件。When the terminal plays the accompaniment audio segment, after the accompaniment audio segment is played, the original singer audio segment after the accompaniment audio segment is not allowed to continue playing, that is, the terminal needs to stop playing the audio file at this time, therefore, In an embodiment of the present invention, the audio switching method further includes: when the terminal plays the audio file, detecting whether the playing length is equal to the length of the accompaniment audio segment, if the playing length is equal to the length of the accompaniment audio segment , then stop playing the audio file.
综上所述,本实施例提供的音频切换方法,通过提供由伴奏音频片段和原唱音频片段拼接而成的音频文件,且当检测到音频切换操作时,在同一个音频文件内部进行播放进度的跳转,使得终端仅使用一个音频文件就可以实现伴奏与原唱之间的切换,从而不需要同时解码两个音频文件,也不需要解码器支持多声道和多音频流的解码能力,因此对所有的应用均具有适配性,进一步地,本实施通过对齐伴奏音频文件和原唱音频文件,使得当检测到音频切换操作时音频文件跳转的目标位置计算更为精确,通过使伴奏音频文件和原唱音频文件长度一致,简化了应用程序在音频切换过程中的计算逻辑,通过剪切伴奏音频文件和原唱音频文件的尾部静音片段,减小了音频文件大小,节省了网络资源和存储空间。In summary, the audio switching method provided by the embodiment provides an audio file formed by splicing an accompaniment audio segment and an original singer audio segment, and when an audio switching operation is detected, playing progress in the same audio file. The jump enables the terminal to switch between the accompaniment and the original singer using only one audio file, so that it is not necessary to decode two audio files at the same time, and the decoder does not need to support the decoding capability of multi-channel and multi-audio streams. Therefore, it is suitable for all applications. Further, the present embodiment aligns the accompaniment audio file and the original singer audio file so that the target position of the audio file jump is more accurately calculated when the audio switching operation is detected, by making the accompaniment The length of the audio file and the original audio file are the same, which simplifies the calculation logic of the application during the audio switching process. By cutting the accompaniment audio file and the tail mute segment of the original audio file, the audio file size is reduced, and the network resource is saved. And storage space.
图4是根据一示例性实施例示出的一种音频切换装置500框图,该装置可以应用于手机、个人电脑、平板电脑等终端。参照图4,该装置包括音频文件获取模块501、播放模块502和播放长度获取模块503。FIG. 4 is a block diagram of an audio switching device 500, which may be applied to a mobile phone, a personal computer, a tablet, etc., according to an exemplary embodiment. Referring to FIG. 4, the apparatus includes an audio file acquisition module 501, a play module 502, and a play length acquisition module 503.
音频文件获取模块501,用于获取音频文件,该音频文件由第一音频片段和第二音频片段拼接组成。The audio file obtaining module 501 is configured to acquire an audio file, where the audio file is composed of a first audio segment and a second audio segment.
在本公开的一个实施例中,音频文件获取模块501还用于:In an embodiment of the present disclosure, the audio file obtaining module 501 is further configured to:
从该音频文件的标签中获取第一音频片段的长度或第二音频片段的长度;Obtaining a length of the first audio segment or a length of the second audio segment from a label of the audio file;
或者,or,
在该音频文件获取模块501获取该音频文件时,从音频数据库中,获取第一音频片段的长度或第二音频片段的长度,该音频数据库用于存储音频文件和对应的第一和第二音频片段长度;When the audio file obtaining module 501 acquires the audio file, the length of the first audio segment or the length of the second audio segment is obtained from the audio database, and the audio database is used to store the audio file and the corresponding first and second audios. Fragment length
或者,or,
获取该音频文件总长度; Get the total length of the audio file;
获取音频文件的长度,其中第一音频片段和第二音频片段长度相同。The length of the audio file is obtained, wherein the first audio segment and the second audio segment are the same length.
播放模块502,用于根据用户的播放选择操作,播放第一音频片段。The playing module 502 is configured to play the first audio segment according to the user's play selection operation.
播放长度获取模块503,用于如果在该播放模块502播放过程中检测到音频切换操作,获取第一音频片段当前的播放长度,该播放长度为当前播放位置距该音频文件起始位置的距离。The play length obtaining module 503 is configured to obtain a current playing length of the first audio segment if the audio switching operation is detected during the playing of the playing module 502, where the playing length is a distance from the current playback position to the start position of the audio file.
播放模块502,还用于从该音频文件获取模块501获取的该音频文件的目标位置进行播放,该目标位置为第一音频片段当前播放长度所对应的第二音频片段上的播放位置。The playing module 502 is further configured to play the target position of the audio file acquired by the audio file acquiring module 501, where the target position is a playing position on the second audio segment corresponding to the current playing length of the first audio segment.
在本发明的一个实施例中,第一音频片段和第二音频片段长度相同,播放模块502用于:In an embodiment of the invention, the first audio segment and the second audio segment are the same length, and the playing module 502 is configured to:
当第一音频片段位于第二音频片段之前时,响应音频切换操作,从该音频文件的第一目标位置进行播放,该第一目标位置距该音频文件起始位置的距离为第一音频片段的长度与当前播放长度之和;When the first audio segment is located before the second audio segment, playing back from the first target position of the audio file in response to the audio switching operation, the distance of the first target location from the start position of the audio file is the first audio segment The sum of the length and the current play length;
或者,or,
当第一音频片段位于第二音频片段之后时,响应音频切换操作,从该音频文件的第二目标位置进行播放,该第二目标位置距该音频文件起始位置的距离为第二音频片段的长度与当前播放长度之差。When the first audio segment is located behind the second audio segment, playing in a second target position of the audio file in response to the audio switching operation, the distance of the second target position from the start position of the audio file is the second audio segment The difference between the length and the current playback length.
参见图5,在本发明的另一个实施例中,还提供了另一种音频切换装置600,该装置基于上述图4的实施例结构,还包括文件获取模块504、对齐模块505、修整模块506、拼接模块507、第一检测模块508、剪切模块509、添加模块510、第二检测模块511和停止模块512。Referring to FIG. 5, in another embodiment of the present invention, another audio switching device 600 is further provided. The device is based on the structure of the embodiment shown in FIG. 4, and further includes a file obtaining module 504, an alignment module 505, and a trimming module 506. The splicing module 507, the first detecting module 508, the cutting module 509, the adding module 510, the second detecting module 511, and the stopping module 512.
文件获取模块504,用于获取第一音频片段和第二音频片段。The file obtaining module 504 is configured to acquire the first audio segment and the second audio segment.
对齐模块505,用于对齐文件获取模块504获取的第一音频片段和第二音频片段,以使第一音频片段和第二音频片段同步。The aligning module 505 is configured to align the first audio segment and the second audio segment acquired by the file obtaining module 504 to synchronize the first audio segment and the second audio segment.
修整模块506,用于将文件获取模块504获取的第一音频片段和第二音频片段的长度修整至预设长度的整数倍,得到修整第一音频片段和修整第二音频片段。The trimming module 506 is configured to trim the lengths of the first audio segment and the second audio segment acquired by the file obtaining module 504 to an integer multiple of a preset length to obtain a trimmed first audio segment and a trimmed second audio segment.
在本发明的一个实施例中,修整模块506用于:In one embodiment of the invention, the trim module 506 is used to:
获取第一音频片段和第二音频片段的采样点数目; Obtaining the number of sampling points of the first audio segment and the second audio segment;
根据扩充公式分别计算第一音频片段或第二音频片段的扩充采样点数目,该扩充公式为:Calculating the number of extended sampling points of the first audio segment or the second audio segment according to the expansion formula, the expansion formula is:
Lf=N×Int((Lo+N-1)/N)L f =N×Int((L o +N-1)/N)
其中,Lf为该扩充采样点数目,Lo为第一音频片段或第二音频片段的采样点数目,N为该预设长度,Int为取整运算;Wherein, L f is the number of the extended sampling points, L o is the number of sampling points of the first audio segment or the second audio segment, N is the preset length, and Int is a rounding operation;
在第一音频片段和第二音频片段的尾部拼接第一静音片段,以将第一音频片段和第二音频片段的采样点数目扩充至该扩充采样点数目。The first mute segment is spliced at the end of the first audio segment and the second audio segment to expand the number of sampling points of the first audio segment and the second audio segment to the number of the extended sampling points.
拼接模块507,用于拼接该修整模块得到的该修整第一音频文件和修整第二音频文件,得到音频文件。The splicing module 507 is configured to splicing the trimmed first audio file obtained by the trimming module and trimming the second audio file to obtain an audio file.
第一检测模块508,用于检测该文件获取模块504获取的第一音频文件和第二音频文件的长度是否相等。The first detecting module 508 is configured to detect whether the lengths of the first audio file and the second audio file acquired by the file obtaining module 504 are equal.
若第一音频片段和第二音频片段的长度不相同时,文件获取模块504,还用于获取第一音频片段和第二音频片段之间的长度差值。If the lengths of the first audio segment and the second audio segment are different, the file obtaining module 504 is further configured to obtain a length difference between the first audio segment and the second audio segment.
拼接模块507,还用于将第二静音片段拼接至第一音频片段和第二音频片段中长度较短的音频文件尾部,该第二静音片段的长度为该长度差值。The splicing module 507 is further configured to splicing the second mute segment to the tail of the shorter length audio file in the first audio segment and the second audio segment, the length of the second mute segment being the length difference.
第一检测模块508,还用于分别检测第一音频片段和第二音频片段的尾部静音片段长度是否超过预设阈值。The first detecting module 508 is further configured to detect whether the length of the tail mute segment of the first audio segment and the second audio segment exceeds a preset threshold, respectively.
当第一音频片段或第二音频片段尾部静音片段长度超过预设阈值时,剪切模块509,用于剪切第一音频片段或第二音频片段的尾部静音片段。When the length of the first audio segment or the second audio segment tail mute segment exceeds a preset threshold, the clipping module 509 is configured to cut the tail mute segment of the first audio segment or the second audio segment.
添加模块510,用于将第一音频片段的长度或第二音频片段的长度添加至该音频文件的标签中。The adding module 510 is configured to add the length of the first audio segment or the length of the second audio segment to the label of the audio file.
第二检测模块511,用于在播放模块播放音频文件时,检测播放长度与第一音频片段的长度是否相等。The second detecting module 511 is configured to detect, when the playing module plays the audio file, whether the playing length is equal to the length of the first audio segment.
停止模块512,用于若播放长度与第一音频片段的长度相等,则停止播放该音频文件。The stopping module 512 is configured to stop playing the audio file if the playing length is equal to the length of the first audio segment.
在上述所有可选实施方式中,第一音频片段可以是一首歌曲的伴奏音频片段,第二音频片段可以是该歌曲的原唱音频片段;或者,第一音频片段可以是一首歌曲的原唱音频片段,第二音频片段可以是该歌曲的伴奏音频片段。In all the above optional embodiments, the first audio segment may be an accompaniment audio segment of a song, and the second audio segment may be an original audio segment of the song; or the first audio segment may be the original of a song. The audio clip is sung, and the second audio clip can be an accompaniment audio clip of the song.
综上所述,本实施例提供的音频切换装置,通过提供由第一音频片段和第 二音频片段拼接而成的音频文件,且当检测到音频切换操作时,在同一个音频文件内部进行播放进度的跳转,使得终端仅使用一个音频文件就可以实现第一音频片段和第二音频片段之间的切换,从而不需要同时解码两个音频文件,也不需要解码器支持多声道和多音频流的解码能力,因此对所有的应用均具有适配性。进一步地,本实施通过对齐第一音频片段和第二音频片段,使得当检测到音频切换操作时音频文件跳转的目标位置计算更为精确,通过使第一音频片段和第二音频片段长度一致,简化了应用程序在音频切换过程中的计算逻辑,通过剪切第一音频片段和第二音频片段的尾部静音片段,减小了音频文件大小,节省了网络资源和存储空间。In summary, the audio switching device provided by this embodiment is provided by the first audio segment and the first An audio file in which two audio segments are spliced, and when an audio switching operation is detected, a playback progress jump is performed inside the same audio file, so that the terminal can implement the first audio segment and the second audio by using only one audio file. Switching between segments eliminates the need to decode two audio files at the same time, and does not require the decoder to support the decoding capabilities of multi-channel and multi-audio streams, so it is adaptable to all applications. Further, the present embodiment aligns the first audio segment and the second audio segment such that the target position of the audio file jump is more accurately calculated when the audio switching operation is detected, by making the first audio segment and the second audio segment the same length It simplifies the calculation logic of the application during the audio switching process, and reduces the audio file size by cutting the first audio segment and the tail mute segment of the second audio segment, thereby saving network resources and storage space.
需要说明的是:上述实施例提供的音频切换装置在进行音频切换业务时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的音频切换装置与音频切换方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。It should be noted that, when performing the audio switching service, the audio switching device provided by the foregoing embodiment is only illustrated by the division of the foregoing functional modules. In actual applications, the function distribution may be completed by different functional modules as needed. The internal structure of the device is divided into different functional modules to perform all or part of the functions described above. In addition, the audio switching device and the audio switching method are provided in the same embodiment, and the specific implementation process is described in detail in the method embodiment, and details are not described herein again.
本实施例提供了一种终端参见图6,该终端可以用于执行上述各个实施例中提供的音频切换方法。This embodiment provides a terminal as shown in FIG. 6. The terminal can be used to perform the audio switching method provided in the foregoing embodiments.
终端700可以包括RF(Radio Frequency,射频)电路710、包括有一个或一个以上计算机可读存储介质的存储器720、输入单元730、显示单元740、传感器750、音频电路760、WiFi(Wireless Fidelity,无线保真)模块770、包括有一个或者一个以上处理核心的处理器780、以及电源790等部件。本领域技术人员可以理解,图7中示出的终端结构并不构成对终端的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。The terminal 700 may include an RF (Radio Frequency) circuit 710, a memory 720 including one or more computer readable storage media, an input unit 730, a display unit 740, a sensor 750, an audio circuit 760, and a WiFi (Wireless Fidelity, wireless). The fidelity module 770 includes a processor 780 having one or more processing cores, and a power supply 790 and the like. It will be understood by those skilled in the art that the terminal structure shown in FIG. 7 does not constitute a limitation to the terminal, and may include more or less components than those illustrated, or a combination of certain components, or different component arrangements.
RF电路710可用于收发信息或通话过程中,信号的接收和发送,特别地,将基站的下行信息接收后,交由一个或者一个以上处理器780处理;另外,将涉及上行的数据发送给基站。通常,RF电路710包括但不限于天线、至少一个放大器、调谐器、一个或多个振荡器、用户身份模块(SIM)卡、收发信机、耦合器、LNA(Low Noise Amplifier,低噪声放大器)、双工器等。此外,RF电路710还可以通过无线通信与网络和其他设备通信。所述无线通信可以使用 任一通信标准或协议,包括但不限于GSM(Global System of Mobile communication,全球移动通讯系统)、GPRS(General Packet Radio Service,通用分组无线服务)、CDMA(Code Division Multiple Access,码分多址)、WCDMA(Wideband Code Division Multiple Access,宽带码分多址)、LTE(Long Term Evolution,长期演进)、电子邮件、SMS(Short Messaging Service,短消息服务)等。The RF circuit 710 can be used for transmitting and receiving information or during a call, and receiving and transmitting the signal. Specifically, after receiving the downlink information of the base station, the downlink information is processed by one or more processors 780. In addition, the data related to the uplink is sent to the base station. . Generally, the RF circuit 710 includes, but is not limited to, an antenna, at least one amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier). , duplexer, etc. In addition, RF circuitry 710 can also communicate with the network and other devices via wireless communication. The wireless communication can be used Any communication standard or protocol, including but not limited to GSM (Global System of Mobile communication), GPRS (General Packet Radio Service), CDMA (Code Division Multiple Access) WCDMA (Wideband Code Division Multiple Access), LTE (Long Term Evolution), e-mail, SMS (Short Messaging Service), and the like.
存储器720可用于存储软件程序以及模块,处理器780通过运行存储在存储器720的软件程序以及模块,从而执行各种功能应用以及数据处理。存储器720可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据终端700的使用所创建的数据(比如音频数据、电话本等)等。此外,存储器720可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。相应地,存储器720还可以包括存储器控制器,以提供处理器780和输入单元730对存储器720的访问。The memory 720 can be used to store software programs and modules, and the processor 780 executes various functional applications and data processing by running software programs and modules stored in the memory 720. The memory 720 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may be stored according to The data created by the use of the terminal 700 (such as audio data, phone book, etc.) and the like. Moreover, memory 720 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, memory 720 can also include a memory controller to provide access to memory 720 by processor 780 and input unit 730.
输入单元730可用于接收输入的数字或字符信息,以及产生与用户设置以及功能控制有关的键盘、鼠标、操作杆、光学或者轨迹球信号输入。具体地,输入单元730可包括触敏表面731以及其他输入设备732。触敏表面731,也称为触摸显示屏或者触控板,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触敏表面731上或在触敏表面731附近的操作),并根据预先设定的程式驱动相应的连接装置。可选的,触敏表面731可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器780,并能接收处理器780发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触敏表面731。除了触敏表面731,输入单元730还可以包括其他输入设备732。具体地,其他输入设备732可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。 The input unit 730 can be configured to receive input numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls. In particular, input unit 730 can include touch-sensitive surface 731 as well as other input devices 732. Touch-sensitive surface 731, also referred to as a touch display or trackpad, can collect touch operations on or near the user (eg, the user uses a finger, stylus, etc., any suitable object or accessory on touch-sensitive surface 731 or The operation near the touch-sensitive surface 731) and driving the corresponding connecting device according to a preset program. Alternatively, the touch-sensitive surface 731 can include two portions of a touch detection device and a touch controller. Wherein, the touch detection device detects the touch orientation of the user, and detects a signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts the touch information into contact coordinates, and sends the touch information. The processor 780 is provided and can receive commands from the processor 780 and execute them. In addition, the touch-sensitive surface 731 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch-sensitive surface 731, the input unit 730 can also include other input devices 732. In particular, other input devices 732 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.), trackballs, mice, joysticks, and the like.
显示单元740可用于显示由用户输入的信息或提供给用户的信息以及终端700的各种图形用户接口,这些图形用户接口可以由图形、文本、图标、视频和其任意组合来构成。显示单元740可包括显示面板741,可选的,可以采用LCD(Liquid Crystal Display,液晶显示器)、OLED(Organic Light-Emitting Diode,有机发光二极管)等形式来配置显示面板741。进一步的,触敏表面731可覆盖显示面板741,当触敏表面731检测到在其上或附近的触摸操作后,传送给处理器780以确定触摸事件的类型,随后处理器780根据触摸事件的类型在显示面板741上提供相应的视觉输出。虽然在图7中,触敏表面731与显示面板741是作为两个独立的部件来实现输入和输入功能,但是在某些实施例中,可以将触敏表面731与显示面板741集成而实现输入和输出功能。 Display unit 740 can be used to display information entered by the user or information provided to the user and various graphical user interfaces of terminal 700, which can be constructed from graphics, text, icons, video, and any combination thereof. The display unit 740 can include a display panel 741. Alternatively, the display panel 741 can be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), or the like. Further, the touch-sensitive surface 731 can cover the display panel 741, and when the touch-sensitive surface 731 detects a touch operation thereon or nearby, it is transmitted to the processor 780 to determine the type of touch event, and then the processor 780 according to the touch event The type provides a corresponding visual output on display panel 741. Although in FIG. 7, touch-sensitive surface 731 and display panel 741 are implemented as two separate components to implement input and input functions, in some embodiments, touch-sensitive surface 731 can be integrated with display panel 741 for input. And output function.
终端700还可包括至少一种传感器750,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板741的亮度,接近传感器可在终端700移动到耳边时,关闭显示面板741和/或背光。作为运动传感器的一种,重力加速度传感器可检测各个方向上(一般为三轴)加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换、相关游戏、磁力计姿态校准)、振动识别相关功能(比如计步器、敲击)等;至于终端700还可配置的陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器,在此不再赘述。Terminal 700 can also include at least one type of sensor 750, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 741 according to the brightness of the ambient light, and the proximity sensor may close the display panel 741 when the terminal 700 moves to the ear. / or backlight. As a kind of motion sensor, the gravity acceleration sensor can detect the magnitude of acceleration in all directions (usually three axes). When it is stationary, it can detect the magnitude and direction of gravity. It can be used to identify the gesture of the mobile phone (such as horizontal and vertical screen switching, related Game, magnetometer attitude calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for the terminal 700 can also be configured with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors, here Let me repeat.
音频电路760、扬声器761,传声器762可提供用户与终端700之间的音频接口。音频电路760可将接收到的音频数据转换后的电信号,传输到扬声器761,由扬声器761转换为声音信号输出;另一方面,传声器762将收集的声音信号转换为电信号,由音频电路760接收后转换为音频数据,再将音频数据输出处理器780处理后,经RF电路710以发送给比如另一终端,或者将音频数据输出至存储器720以便进一步处理。音频电路760还可能包括耳塞插孔,以提供外设耳机与终端700的通信。An audio circuit 760, a speaker 761, and a microphone 762 can provide an audio interface between the user and the terminal 700. The audio circuit 760 can transmit the converted electrical data of the received audio data to the speaker 761 for conversion to the sound signal output by the speaker 761; on the other hand, the microphone 762 converts the collected sound signal into an electrical signal by the audio circuit 760. After receiving, it is converted into audio data, and then processed by the audio data output processor 780, transmitted to the terminal, for example, via the RF circuit 710, or the audio data is output to the memory 720 for further processing. The audio circuit 760 may also include an earbud jack to provide communication of the peripheral earphones with the terminal 700.
WiFi属于短距离无线传输技术,终端700通过WiFi模块770可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图7示出了WiFi模块770,但是可以理解的是,其并不属于 终端700的必须构成,完全可以根据需要在不改变发明的本质的范围内而省略。WiFi is a short-range wireless transmission technology, and the terminal 700 can help users to send and receive emails, browse web pages, and access streaming media through the WiFi module 770, which provides wireless broadband Internet access for users. Although FIG. 7 shows the WiFi module 770, it can be understood that it does not belong to The necessary configuration of the terminal 700 can be omitted as long as it does not change the essence of the invention as needed.
处理器780是终端700的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器720内的软件程序和/或模块,以及调用存储在存储器720内的数据,执行终端700的各种功能和处理数据,从而对手机进行整体监控。可选的,处理器780可包括一个或多个处理核心;优选的,处理器780可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器780中。 Processor 780 is the control center of terminal 700, which connects various portions of the entire handset using various interfaces and lines, by running or executing software programs and/or modules stored in memory 720, and recalling data stored in memory 720, The various functions and processing data of the terminal 700 are performed to perform overall monitoring of the mobile phone. Optionally, the processor 780 may include one or more processing cores; preferably, the processor 780 may integrate an application processor and a modem processor, where the application processor mainly processes an operating system, a user interface, an application, and the like. The modem processor primarily handles wireless communications. It will be appreciated that the above described modem processor may also not be integrated into the processor 780.
终端700还包括给各个部件供电的电源790(比如电池),优选的,电源可以通过电源管理系统与处理器780逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。电源790还可以包括一个或一个以上的直流或交流电源、再充电系统、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。The terminal 700 also includes a power source 790 (such as a battery) for powering various components. Preferably, the power source can be logically coupled to the processor 780 through a power management system to manage functions such as charging, discharging, and power management through the power management system. Power supply 790 may also include any one or more of a DC or AC power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
尽管未示出,终端700还可以包括摄像头、蓝牙模块等,在此不再赘述。具体在本实施例中,终端的显示单元是触摸屏显示器,终端还包括有存储器,以及一个或者一个以上的程序,其中一个或者一个以上程序存储于存储器中,且经配置以由一个或者一个以上处理器执行。所述一个或者一个以上程序包含用于执行以下操作的指令:Although not shown, the terminal 700 may further include a camera, a Bluetooth module, and the like, and details are not described herein again. Specifically, in this embodiment, the display unit of the terminal is a touch screen display, the terminal further includes a memory, and one or more programs, wherein one or more programs are stored in the memory and configured to be processed by one or more Execution. The one or more programs include instructions for performing the following operations:
获取音频文件,该音频文件由第一音频片段和第二音频片段拼接组成;Obtaining an audio file, the audio file being composed of a first audio segment and a second audio segment;
在播放第一音频片段的过程中检测到音频片段切换操作,获取第一音频片段当前播放长度,当前播放长度为当前播放位置距音频文件起始位置的距离;The audio segment switching operation is detected during the playing of the first audio segment, and the current playing length of the first audio segment is obtained, and the current playing length is the distance of the current playing position from the starting position of the audio file;
响应音频片段切换操作,从音频文件的目标位置进行播放,该目标位置为与第一音频片段当前播放长度所对应的第二音频片段上的播放位置。In response to the audio segment switching operation, the playback is performed from a target location of the audio file, the target location being a playback location on the second audio segment corresponding to the current playback length of the first audio segment.
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。 A person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium. The storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.
以上所述仅为本发明的较佳实施例,并不用以限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。 The above are only the preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalents, improvements, etc., which are within the spirit and scope of the present invention, should be included in the protection of the present invention. Within the scope.

Claims (17)

  1. 一种音频切换方法,包括:An audio switching method includes:
    获取音频文件,所述音频文件由第一音频片段和第二音频片段拼接组成;Acquiring an audio file, the audio file being composed of a first audio segment and a second audio segment;
    在播放所述第一音频片段的过程中检测到音频片段切换操作,获取所述第一音频片段当前播放长度,所述当前播放长度为当前播放位置距所述音频文件起始位置的距离;以及And detecting an audio segment switching operation in the process of playing the first audio segment, acquiring a current playing length of the first audio segment, where the current playing length is a distance from a starting position of the audio file of the current playing position;
    响应所述音频片段切换操作,从所述音频文件的目标位置进行播放,所述目标位置为与所述第一音频片段当前播放长度所对应的第二音频片段上的播放位置。In response to the audio segment switching operation, playing from a target location of the audio file, the target location being a playback location on a second audio segment corresponding to a current playback length of the first audio segment.
  2. 根据权利要求1所述的方法,所述第一音频片段和所述第二音频片段长度相同,The method of claim 1, the first audio segment and the second audio segment are the same length,
    当所述第一音频片段位于所述第二音频片段之前时,所述目标位置距离所述音频文件起始位置的距离为所述第一音频片段的长度与所述第一音频片段当前播放长度之和;When the first audio segment is located before the second audio segment, the distance of the target location from the start position of the audio file is the length of the first audio segment and the current playback length of the first audio segment. Sum;
    当所述第一音频片段位于所述第二音频片段之后时,所述目标位置距离所述音频文件起始位置的距离为所述第二音频片段的长度与所述第一音频片段当前播放长度之差。When the first audio segment is located behind the second audio segment, the distance of the target location from the start position of the audio file is the length of the second audio segment and the current playback length of the first audio segment. Difference.
  3. 根据权利要求2所述的方法,所述获取所述音频文件之前,还包括:The method of claim 2, before the obtaining the audio file, further comprising:
    获取所述第一音频片段和所述第二音频片段;Obtaining the first audio segment and the second audio segment;
    对齐所述第一音频片段和所述第二音频片段,以使所述第一音频片段和所述第二音频片段同步;以及Aligning the first audio segment and the second audio segment to synchronize the first audio segment and the second audio segment;
    拼接所述第一音频片段和所述第二音频片段。The first audio segment and the second audio segment are spliced.
  4. 根据权利要求3所述的方法,当所述第一音频片段的长度或第二音频片段的长度不是预设长度的整数倍时,还包括:The method according to claim 3, when the length of the first audio segment or the length of the second audio segment is not an integer multiple of a preset length, the method further includes:
    修整所述第一音频片段的长度或第二音频片段的长度至所述预设长度的整数倍。 The length of the first audio segment or the length of the second audio segment is trimmed to an integer multiple of the preset length.
  5. 根据权利要求4所述的方法,修整所述第一音频片段或所述第二音频片段的长度至所述预设长度的整数倍:The method according to claim 4, trimming the length of the first audio segment or the second audio segment to an integer multiple of the preset length:
    获取所述第一音频片段或所述第二音频片段的采样点数目;Obtaining a number of sampling points of the first audio segment or the second audio segment;
    根据扩充公式计算所述第一音频片段或所述第二音频片段的扩充采样点数目,所述扩充公式为:Calculating the number of extended sampling points of the first audio segment or the second audio segment according to an expansion formula, where the expansion formula is:
    Lf=N×Int((Lo+N-1)/N) L f = N × Int (( L o + N-1) / N)
    其中,Lf为所述扩充采样点数目,Lo为所述第一音频片段或第二音频片段的采样点数目,N为所述预设长度,Int为取整运算;Wherein, L f is the expansion of the number of sampling points, L o is a fragment of the first audio or the second audio segment number of sampling points, N is the length of the preset, Int is the integer operation;
    在所述第一音频片段和所述第二音频片段的尾部拼接第一静音片段,以将所述第一音频片段和所述第二音频片段的采样点数目扩充至所述扩充采样点数目。And splicing the first mute segment at the tail of the first audio segment and the second audio segment to expand the number of sampling points of the first audio segment and the second audio segment to the number of the extended sampling points.
  6. 根据权利要求3所述的方法,修整所述第一音频片段和所述第二音频片段的长度至所述预设长度的整数倍之前,还包括:The method of claim 3, before trimming the length of the first audio segment and the second audio segment to an integer multiple of the preset length, further comprising:
    检测所述第一音频片段和所述第二音频片段的长度是否相等;Detecting whether the lengths of the first audio segment and the second audio segment are equal;
    若所述第一音频片段和所述第二音频片段的长度不相等,则获取所述第一音频片段和所述第二音频片段的长度差值;以及Obtaining a difference in length between the first audio segment and the second audio segment if the lengths of the first audio segment and the second audio segment are not equal;
    将第二静音片段拼接至所述第一音频片段和所述第二音频片段中长度较短的音频片段尾部,所述第二静音片段的长度为所述第一音频片段和所述第二音频片段的长度差值。Splicing a second mute segment to a shorter length of the audio segment in the first audio segment and the second audio segment, the second mute segment having a length of the first audio segment and the second audio The difference in length of the segment.
  7. 根据权利要求3所述的方法,还包括:The method of claim 3 further comprising:
    分别检测所述第一音频片段和所述第二音频片段的尾部静音片段的长度是否超过预设阈值;Detecting respectively whether the length of the tail mute segment of the first audio segment and the second audio segment exceeds a preset threshold;
    若第一音频片段或第二音频片段的尾部静音片段的长度超过所述预设阈值,则剪切所述第一音频片段或所述第二音频片段的尾部静音片段。If the length of the tail mute segment of the first audio segment or the second audio segment exceeds the preset threshold, cutting the tail segment of the first audio segment or the second audio segment.
  8. 根据权利要求1至7中任一项所述的方法,所述第一音频片段是一首 歌曲的伴奏音频片段,所述第二音频片段是所述歌曲的原唱音频片段;或The method according to any one of claims 1 to 7, wherein the first audio segment is a An accompaniment audio segment of the song, the second audio segment being an original singer audio segment of the song; or
    所述第一音频片段是一首歌曲的原唱音频片段,所述第二音频片段是所述歌曲的伴奏音频片段。The first audio segment is an original singer audio segment of a song, and the second audio segment is an accompaniment audio segment of the song.
  9. 一种音频切换装置,包括:处理器和存储有操作指令的存储介质,当运行所述存储介质中的操作指令时,所述处理器执行如下步骤:An audio switching device includes: a processor and a storage medium storing an operation instruction, when the operation instruction in the storage medium is executed, the processor performs the following steps:
    获取音频文件,所述音频文件由第一音频片段和第二音频片段拼接组成;Acquiring an audio file, the audio file being composed of a first audio segment and a second audio segment;
    在播放所述第一音频片段的过程中检测到音频片段切换操作,获取所述第一音频片段当前播放长度,所述当前播放长度为当前播放位置距所述音频文件起始位置的距离;以及And detecting an audio segment switching operation in the process of playing the first audio segment, acquiring a current playing length of the first audio segment, where the current playing length is a distance from a starting position of the audio file of the current playing position;
    响应所述音频片段切换操作,从所述音频文件的目标位置进行播放,所述目标位置为与所述第一音频片段当前播放长度所对应的第二音频片段上的播放位置。In response to the audio segment switching operation, playing from a target location of the audio file, the target location being a playback location on a second audio segment corresponding to a current playback length of the first audio segment.
  10. 根据权利要求9所述的装置,所述第一音频片段和所述第二音频片段长度相同,The apparatus of claim 9, the first audio segment and the second audio segment are the same length,
    当所述第一音频片段位于所述第二音频片段之前时,所述目标位置距离所述音频文件起始位置的距离为所述第一音频片段的长度与所述第一音频片段当前播放长度之和;When the first audio segment is located before the second audio segment, the distance of the target location from the start position of the audio file is the length of the first audio segment and the current playback length of the first audio segment. Sum;
    当所述第一音频片段位于所述第二音频片段之后时,所述目标位置距离所述音频文件起始位置的距离为所述第二音频片段的长度与所述第一音频片段当前播放长度之差。When the first audio segment is located behind the second audio segment, the distance of the target location from the start position of the audio file is the length of the second audio segment and the current playback length of the first audio segment. Difference.
  11. 根据权利要求9所述的装置,所述处理器还执行:The apparatus of claim 9 wherein said processor further executes:
    获取所述第一音频片段和所述第二音频片段;Obtaining the first audio segment and the second audio segment;
    对齐所述第一音频片段和所述第二音频片段,以使所述第一音频片段和所述第二音频片段同步;以及Aligning the first audio segment and the second audio segment to synchronize the first audio segment and the second audio segment;
    拼接所述第一音频片段和所述第二音频片段。 The first audio segment and the second audio segment are spliced.
  12. 根据权利要求11所述的装置,所述处理器还执行:The apparatus of claim 11 wherein said processor further executes:
    修整所述第一音频片段的长度或第二音频片段的长度至所述预设长度的整数倍。The length of the first audio segment or the length of the second audio segment is trimmed to an integer multiple of the preset length.
  13. 根据权利要求12所述的装置,当所述处理器执行修整所述第一音频片段或第二音频片段的长度至所述预设长度的整数倍时,执行:The apparatus according to claim 12, when said processor performs trimming of a length of said first audio segment or said second audio segment to an integer multiple of said preset length, performing:
    获取所述第一音频片段和所述第二音频片段的采样点数目;Obtaining a number of sampling points of the first audio segment and the second audio segment;
    根据扩充公式计算所述第一音频片段或所述第二音频片段的扩充采样点数目,所述扩充公式为:Calculating the number of extended sampling points of the first audio segment or the second audio segment according to an expansion formula, where the expansion formula is:
    Lf=N×Int((Lo+N-1)/N)L f =N×Int((L o +N-1)/N)
    其中,Lf为所述扩充采样点数目,Lo为所述第一音频片段或第二音频片段的采样点数目,N为所述预设长度,Int为取整运算;Wherein, L f is the number of the extended sampling points, L o is the number of sampling points of the first audio segment or the second audio segment, N is the preset length, and Int is a rounding operation;
    在所述第一音频片段和所述第二音频片段的尾部拼接第一静音片段,以将所述第一音频片段和所述第二音频片段的采样点数目扩充至所述扩充采样点数目。And splicing the first mute segment at the tail of the first audio segment and the second audio segment to expand the number of sampling points of the first audio segment and the second audio segment to the number of the extended sampling points.
  14. 根据权利要求11所述的装置,所述处理器还执行:The apparatus of claim 11 wherein said processor further executes:
    检测所述第一音频片段和所述第二音频片段的长度是否相等;Detecting whether the lengths of the first audio segment and the second audio segment are equal;
    若所述第一音频片段和所述第二音频片段的长度不相等,则获取所述第一音频片段和所述第二音频片段的长度差值;以及Obtaining a difference in length between the first audio segment and the second audio segment if the lengths of the first audio segment and the second audio segment are not equal;
    将第二静音片段拼接至所述第一音频片段和所述第二音频片段中长度较短的音频片段尾部,所述第二静音片段的长度为所述第一音频片段和所述第二音频片段的长度差值。Splicing a second mute segment to a shorter length of the audio segment in the first audio segment and the second audio segment, the second mute segment having a length of the first audio segment and the second audio The difference in length of the segment.
  15. 根据权利要求11所述的装置,所述处理器还执行;The apparatus of claim 11 wherein said processor is further executing;
    分别检测所述第一音频片段和所述第二音频片段的尾部静音片段的长度是否超过预设阈值;Detecting respectively whether the length of the tail mute segment of the first audio segment and the second audio segment exceeds a preset threshold;
    若第一音频片段或第二音频片段的尾部静音片段的长度超过所述预设阈 值,则剪切所述第一音频片段或所述第二音频片段的尾部静音片段。If the length of the tail mute segment of the first audio segment or the second audio segment exceeds the preset threshold a value, then cutting the first audio segment or the tail mute segment of the second audio segment.
  16. 根据权利要求9至15中任一项所述的装置,所述第一音频片段是一首歌曲的伴奏音频片段,所述第二音频片段是所述歌曲的原唱音频片段;或The apparatus according to any one of claims 9 to 15, wherein the first audio segment is an accompaniment audio segment of a song, and the second audio segment is an original vocal audio segment of the song; or
    所述第一音频片段是一首歌曲的原唱音频片段,所述第二音频片段是所述歌曲的伴奏音频片段。The first audio segment is an original singer audio segment of a song, and the second audio segment is an accompaniment audio segment of the song.
  17. 一种非瞬时性的计算机可读存储介质,其上存储有计算机可执行指令,当计算机中运行这些可执行指令时,执行如下步骤:A non-transitory computer readable storage medium having computer executable instructions stored thereon. When the executable instructions are executed in a computer, the following steps are performed:
    获取音频文件,所述音频文件由第一音频片段和第二音频片段拼接组成;Acquiring an audio file, the audio file being composed of a first audio segment and a second audio segment;
    在播放所述第一音频片段的过程中检测到音频片段切换操作,获取所述第一音频片段当前播放长度,所述当前播放长度为当前播放位置距所述音频文件起始位置的距离;以及And detecting an audio segment switching operation in the process of playing the first audio segment, acquiring a current playing length of the first audio segment, where the current playing length is a distance from a starting position of the audio file of the current playing position;
    响应所述音频片段切换操作,从所述音频文件的目标位置进行播放,所述目标位置为与所述第一音频片段当前播放长度所对应的第二音频片段上的播放位置。 In response to the audio segment switching operation, playing from a target location of the audio file, the target location being a playback location on a second audio segment corresponding to a current playback length of the first audio segment.
PCT/CN2016/084260 2015-12-15 2016-06-01 Method, device, and storage medium for audio switching WO2017101260A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510934171.6 2015-12-15
CN201510934171.6A CN106887244B (en) 2015-12-15 2015-12-15 Audio switching method and device

Publications (1)

Publication Number Publication Date
WO2017101260A1 true WO2017101260A1 (en) 2017-06-22

Family

ID=59055647

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/084260 WO2017101260A1 (en) 2015-12-15 2016-06-01 Method, device, and storage medium for audio switching

Country Status (2)

Country Link
CN (1) CN106887244B (en)
WO (1) WO2017101260A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112397102A (en) * 2019-08-14 2021-02-23 腾讯科技(深圳)有限公司 Audio processing method and device and terminal
CN113473170A (en) * 2021-07-16 2021-10-01 广州繁星互娱信息科技有限公司 Live broadcast audio processing method and device, computer equipment and medium

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108831424B (en) * 2018-06-15 2021-01-08 广州酷狗计算机科技有限公司 Audio splicing method and device and storage medium
CN110989816B (en) * 2019-09-24 2022-01-14 华为技术有限公司 Application processing method and device and storage medium
CN111625677B (en) * 2020-05-12 2023-09-19 咪咕文化科技有限公司 Audio playing method, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010160289A (en) * 2009-01-07 2010-07-22 Kinki Univ Midi (r) karaoke system which automatically corrects interval
CN202871290U (en) * 2012-09-27 2013-04-10 比亚迪股份有限公司 Apparatus for automatic switching of original singing and vocal accompaniment of karaoke equipment
CN104143325A (en) * 2014-07-18 2014-11-12 腾讯科技(深圳)有限公司 Method and system for switching accompaniment/original audio data
CN104219556A (en) * 2014-09-12 2014-12-17 北京阳光视翰科技有限公司 Use method of four-soundtrack karaoke identification playing system
CN104361889A (en) * 2014-10-28 2015-02-18 百度在线网络技术(北京)有限公司 Audio file processing method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101131816B (en) * 2007-09-30 2012-01-04 炬力集成电路设计有限公司 Audio file generation method, device and digital player

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010160289A (en) * 2009-01-07 2010-07-22 Kinki Univ Midi (r) karaoke system which automatically corrects interval
CN202871290U (en) * 2012-09-27 2013-04-10 比亚迪股份有限公司 Apparatus for automatic switching of original singing and vocal accompaniment of karaoke equipment
CN104143325A (en) * 2014-07-18 2014-11-12 腾讯科技(深圳)有限公司 Method and system for switching accompaniment/original audio data
CN104219556A (en) * 2014-09-12 2014-12-17 北京阳光视翰科技有限公司 Use method of four-soundtrack karaoke identification playing system
CN104361889A (en) * 2014-10-28 2015-02-18 百度在线网络技术(北京)有限公司 Audio file processing method and device

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112397102A (en) * 2019-08-14 2021-02-23 腾讯科技(深圳)有限公司 Audio processing method and device and terminal
CN112397102B (en) * 2019-08-14 2022-07-08 腾讯科技(深圳)有限公司 Audio processing method and device and terminal
CN113473170A (en) * 2021-07-16 2021-10-01 广州繁星互娱信息科技有限公司 Live broadcast audio processing method and device, computer equipment and medium
CN113473170B (en) * 2021-07-16 2023-08-25 广州繁星互娱信息科技有限公司 Live audio processing method, device, computer equipment and medium

Also Published As

Publication number Publication date
CN106887244A (en) 2017-06-23
CN106887244B (en) 2019-08-30

Similar Documents

Publication Publication Date Title
US10649720B2 (en) Sound effect configuration method and system and related device
KR101972955B1 (en) Method and apparatus for connecting service between user devices using voice
CN105872253B (en) Live broadcast sound processing method and mobile terminal
WO2016177296A1 (en) Video generation method and apparatus
WO2016066092A1 (en) Multimedia playing controlling method and device, and storage medium
EP3614383A1 (en) Audio data processing method and apparatus, and storage medium
WO2017101260A1 (en) Method, device, and storage medium for audio switching
CN106251890B (en) A kind of methods, devices and systems of recording song audio
US10283168B2 (en) Audio file re-recording method, device and storage medium
CN105979312B (en) Information sharing method and device
WO2020249091A1 (en) Voice interaction method, apparatus, and system
US10951557B2 (en) Information interaction method and terminal
CN103391473B (en) Method and device for providing and acquiring audio and video
TWI522917B (en) Method and device for controlling start-up of applicantion and computer-readable storage medium
WO2018196588A1 (en) Information sharing method, apparatus and system
US10635388B2 (en) Sound effect processing method and mobile terminal
WO2017215661A1 (en) Scenario-based sound effect control method and electronic device
WO2017215635A1 (en) Sound effect processing method and mobile terminal
WO2017215511A1 (en) Control method of scene sound effect and related products
WO2016029351A1 (en) Method and terminal for processing media file
WO2017215615A1 (en) Sound effect processing method and mobile terminal
WO2014082553A1 (en) Multimedia playing method, device and terminal
KR101876394B1 (en) Method and device for playing media data on a terminal
CN106303616B (en) Play control method, device and terminal
WO2021248988A1 (en) Cross-terminal screen recording method, terminal device, and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16874324

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16874324

Country of ref document: EP

Kind code of ref document: A1