Audio playing method and device in task scenario
By calculating the playback time and rhythm information of audio data in a task scenario, smooth switching of audio data is achieved, solving the problem of stiff and abrupt audio switching and improving the user experience.
Patent Information
- Application Number
- CN202410118159.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-26
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2044-01-26
AI Technical Summary
In existing technologies, audio switching appears stiff and abrupt in task scenarios, lacking smoothness and resulting in a sense of disjointedness and an inconsistent user experience.
By acquiring multiple audio data associated with the target task scenario, the playback time and rhythm information of the current audio data are determined, the remaining time is calculated, and the target audio data is switched when the remaining time is less than a preset threshold, thus achieving a smooth switch.
It reduces the abruptness and disjointedness of audio switching, improves the user experience, and provides a more natural audio switching experience.
Smart Images

Figure CN117942569B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Internet technology, and in particular to an audio playback method and apparatus for a task scenario. Background Technology
[0002] In the field of internet technology, playing audio data is a common requirement.
[0003] In related technologies, it is often necessary to switch the currently playing audio. The methods involved usually switch the currently playing audio immediately when a switching operation is detected or a switching condition is met. For example, the currently playing audio may be switched as the task scenario changes. However, the immediate switching usually appears stiff and abrupt, and cannot provide a smooth and natural audio switching experience.
[0004] Therefore, there is an urgent need for an audio playback method that can play smoothly in task scenarios and reduce the sense of audio fragmentation. Summary of the Invention
[0005] In view of this, embodiments of the present invention provide an audio playback method in a task scenario. One or more embodiments of the present invention simultaneously relate to an audio playback method in a game scenario, an audio playback device in a task scenario, an audio playback device in a game scenario, a computing device, a computer-readable storage medium, and a computer program, to address the technical deficiencies existing in the prior art.
[0006] According to a first aspect of the present invention, an audio playback method in a task scenario is provided, comprising:
[0007] Acquire multiple audio data associated with the target task scenario, wherein each audio data is triggered to play in response to a different task event, and each audio data includes rhythm information;
[0008] During the playback of the current audio data, in response to the target task event, the playback time of the current audio data is determined, and based on the playback time and the rhythm information of the current audio data, the target end time for the current audio data to play a complete measure is determined;
[0009] Based on the already played time and the target end time, determine the remaining time for the current audio data to be played;
[0010] If the remaining time is less than a preset threshold, the current audio data will be switched to the target audio data corresponding to the target task event for playback.
[0011] According to a second aspect of the present invention, an audio playback method in a game scene is provided, comprising:
[0012] Acquire multiple audio data associated with the target game scene, wherein each audio data is triggered to play in response to different player operations, and each audio data includes rhythm information;
[0013] During the playback of the current audio data, in response to the target player's operation, the playback time of the current audio data is determined, and based on the playback time and the rhythm information of the current audio data, the target end time for the current audio data to play a complete measure is determined;
[0014] Based on the already played time and the target end time, determine the remaining time for the current audio data to be played;
[0015] If the remaining time is less than a preset threshold, the current audio data will be switched to the target audio data corresponding to the target player's operation for playback.
[0016] According to a third aspect of the present invention, an audio playback device for a task scenario is provided, comprising:
[0017] The first acquisition module is configured to acquire multiple audio data associated with the target task scene, wherein each audio data is triggered to play in response to a different task event, and each audio data includes rhythm information;
[0018] The first determining module is configured to, during the playback of the current audio data, respond to a target task event, determine the playback time of the current audio data, and determine the target end time for the current audio data to play a complete measure based on the playback time and the rhythm information of the current audio data.
[0019] The second determining module is configured to determine the remaining time to be played for the current audio data based on the already played time and the target end time.
[0020] The first switching module is configured to switch the current audio data to the target audio data corresponding to the target task event for playback when the remaining time is less than a preset threshold.
[0021] According to a fourth aspect of the present invention, an audio playback device for a game scene is provided, comprising:
[0022] The second acquisition module is configured to acquire multiple audio data associated with the target game scene, wherein each audio data is triggered to play in response to different player operations, and each audio data includes rhythm information;
[0023] The third determining module is configured to, in response to the target player's operation during the playback of the current audio data, determine the playback time of the current audio data, and based on the playback time and the rhythm information of the current audio data, determine the target end time for the current audio data to play a complete measure.
[0024] The fourth determining module is configured to determine the remaining time to be played for the current audio data based on the already played time and the target end time.
[0025] The second switching module is configured to switch the current audio data to the target audio data corresponding to the target player's operation when the remaining time is less than a preset threshold.
[0026] According to a fifth aspect of the present invention, a computing device is provided, comprising:
[0027] Memory and processor;
[0028] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the first or second aspect of the method described above.
[0029] According to a sixth aspect of the present invention, a computer-readable storage medium is provided that stores computer-executable instructions, which, when executed by a processor, implement the steps of the methods described in the first or second aspect.
[0030] According to a seventh aspect of the present invention, a computer program is provided, wherein when the computer program is executed in a computer, the computer is caused to perform the steps of the method described in the first or second aspect.
[0031] An embodiment of the present invention provides an audio playback method in a task scenario. This method acquires multiple audio data associated with a target task scenario, where each audio data is triggered for playback in response to a different task event, and each audio data includes rhythm information. During the playback of the current audio data, in response to a target task event, the method determines the elapsed playback time of the current audio data, and based on the elapsed playback time and the rhythm information of the current audio data, determines the target end time for the current audio data to complete one measure. Based on the elapsed playback time and the target end time, the method determines the remaining playback time of the current audio data. If the remaining time is less than a preset threshold, the method switches the current audio data to the target audio data corresponding to the target task event for playback. By calculating the target end time for the currently playing audio to complete one measure, the method can play the target audio data corresponding to the target task scenario at an appropriate time, making the switch between the currently playing audio data and the target audio data smoother, reducing the abruptness and disjointedness of the switch, and improving the user experience. Attached Figure Description
[0032] Figure 1 This is an architecture diagram of an audio playback system in a task scenario provided by an embodiment of the present invention;
[0033] Figure 2 This is a flowchart of an audio playback method in a task scenario provided by an embodiment of the present invention;
[0034] Figure 3 This is a flowchart of an audio playback method in a game scene provided by an embodiment of the present invention;
[0035] Figure 4 This is a flowchart illustrating the processing steps of an audio playback method applied to a task scenario in game development, according to an embodiment of the present invention.
[0036] Figure 5 This is a schematic diagram of the structure of an audio playback device in a task scenario provided by an embodiment of the present invention;
[0037] Figure 6 This is a schematic diagram of the structure of an audio playback device in a game scene according to an embodiment of the present invention;
[0038] Figure 7 This is a structural block diagram of a computing device provided in one embodiment of the present invention. Detailed Implementation
[0039] Numerous specific details are set forth in the following description to provide a full understanding of the invention. However, the invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.
[0040] The terminology used in one or more embodiments of the present invention is for the purpose of describing particular embodiments only and is not intended to limit the scope of the invention. The singular forms “a,” “the,” and “the” used in one or more embodiments of the invention and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” used in one or more embodiments of the invention refers to and includes any or all possible combinations of one or more associated listed items.
[0041] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of the present invention, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of the present invention, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0042] Furthermore, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties. Moreover, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0043] First, the terminology used in one or more embodiments of the present invention will be explained.
[0044] A measure is a unit of time measurement. In music, strong and weak beats always appear in a regular cycle, and the section between one strong beat and the next is called a measure.
[0045] Beat: In terms of hearing, the volume can be perceived as having periodic strong and weak phases. This strong and weak phase is called a beat.
[0046] Bpm stands for beats per measure, which is the number of beats per measure.
[0047] Dynamic scenes: Dynamic scenes refer to virtual environments that are interactive and dynamic in real time. Compared to static scenes, dynamic scenes can change based on user behavior and preset rules. Such scenes typically include elements such as real-time physics simulations, particle effects, weather changes, day-night cycles, and the behavior of AI characters. In some embodiments described herein, dynamic scenes are interactive scenes within games.
[0048] In the field of internet technology, playing audio data is a common requirement, often necessitating an immediate switch when a switching operation is detected or a switching condition is met. However, this immediate switching method often feels rigid and abrupt, lacking flexibility and failing to provide a smooth and natural audio switching experience. For example, the immediate switching method lacks a smooth transition; upon detecting a switching operation or meeting a preset condition, the current audio stops playing and immediately a new audio is played. This sudden audio change can create a disjointed feeling for the user, especially when there are significant differences between the audio tracks, such as in rhythm, pitch, or emotion.
[0049] Therefore, there is an urgent need for an audio playback method that can smoothly reduce audio fragmentation in task scenarios.
[0050] This invention provides an audio playback method for a task scenario, and also relates to an audio playback method for a game scenario, an audio playback device for a task scenario, an audio playback device for a game scenario, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.
[0051] See Figure 1 , Figure 1 This is an architecture diagram of an audio playback system in a task scenario provided by an embodiment of the present invention. Specifically, it includes a user, an operation interface, and a backend. The operation interface is used to respond to user operations and trigger a target task event. The backend is used to play the current audio data, detect the target task event, determine the switching timing, and play the target audio data corresponding to the target task event. Specifically, the backend is used to acquire multiple audio data associated with the target task scenario. During the playback of the current audio data, when the target task event is detected, it determines the played time of the current audio data, and based on the played time and the rhythm information of the current audio data, determines the target end time for the current audio data to complete one measure. Based on the played time and the target end time, it determines the remaining time for the current audio data to be played. If the remaining time is less than a preset threshold, the current audio data is switched to the target audio data corresponding to the target task event for playback.
[0052] By using the audio playback system in this task scenario, the target end time for the complete playback of a section of the currently playing audio can be calculated. This allows the target audio data corresponding to the target task scenario to be played at the appropriate time, making the switch between the currently playing audio data and the target audio data smoother, reducing the abruptness and disjointedness of the switch, and improving the user experience.
[0053] See Figure 2 , Figure 2 This is a flowchart of an audio playback method in a task scenario provided by an embodiment of the present invention, which specifically includes the following steps.
[0054] Step 202: Obtain multiple audio data associated with the target task scene, wherein each audio data is triggered to play in response to different task events, and each audio data includes rhythm information.
[0055] The rhythm information includes details such as the rhythm, beat, and tempo of the audio data. For example, the target task scene could be a dynamic scene in a game, and the audio data could be a collection of all audio files that need to be played within that dynamic scene.
[0056] In practical applications, the system first needs to determine the target task scenario, and then obtain audio data associated with the scenario by downloading from the cloud server, reading from the local storage device, or through the network. Each audio data corresponds to a different task event in the target task scenario, and the audio data also includes rhythm information such as tempo, beat, and rhythm.
[0057] In a specific embodiment of this specification, taking a dynamic scene in a game as an example, the target task scene is associated with a player's first interactive operation and a second interactive operation. After determining the dynamic scene, the system obtains the first audio data and the second audio data associated with the dynamic scene. The first audio data is played in response to the player's first interactive operation, and the second audio data is played in response to the player's second interactive operation.
[0058] It is understood that a task scenario can be any scenario involving audio data playback, such as work, study, or entertainment scenarios. In different scenarios, multiple audio data are associated with different task events. These audio data may include background music, prompts, reminders, etc., which are matched with the needs and goals of the task scenario to provide audio support for the task or enhance the experience. For example, in work scenarios such as offices or factories, different audio data, such as reminders and alarms, are played when different task events are triggered; in study scenarios, audio data related to learning, such as background music, study guidance audio, and time reminders, are played according to different learning tasks; in leisure and entertainment scenarios, audio data related to entertainment activities, such as music and game sound effects, are played according to different entertainment tasks. This manual does not specifically limit the task scenario.
[0059] Furthermore, before acquiring multiple audio data associated with the target task scenario, the method further includes: acquiring multiple candidate task events pre-set for the target task scenario, and audio data pre-selected for each candidate task event; determining the rhythm information of each audio data; and binding each candidate task event, each audio data, and each rhythm information based on the correspondence between the candidate task events, audio data, and rhythm information.
[0060] In practical applications, firstly, for the target task scenario, the system pre-sets multiple candidate task events. These candidate events represent various situations or behaviors that may be triggered in the task scenario, such as the start of a battle, task completion, plot twists, etc. These candidate task events can be obtained through analysis of the task scenario, including a comprehensive judgment of user behavior, system status, or other contextual information. Secondly, for each candidate task event, corresponding audio data is pre-selected, that is, matching corresponding audio data for each candidate task event. This audio data can be sound effects, music, or voice prompts related to the event. These selections can be based on the needs of the scenario, emotional tone, or audio characteristics. Then, for each pre-selected audio data, the rhythm information needs to be determined. This can be done by analyzing the audio file to extract its rhythm, beat, and tempo features for subsequent audio switching and playback control. Finally, based on the correspondence between candidate task events, audio data, and rhythm information, they are bound together, that is, each candidate task event is associated with the corresponding audio data and rhythm information, so that the corresponding audio data can be quickly selected and played according to the current task event triggering situation.
[0061] In a specific embodiment of this specification, following the example above, for dynamic scenes in the game, the system pre-sets a first interactive event and a second interactive event; secondly, for each interactive event, corresponding audio data is pre-selected, with the first interactive operation corresponding to the first audio data and the second interactive operation corresponding to the second audio data; then, the first audio data and the second audio data are analyzed to obtain information such as the rhythm and beat of the first and second audio files; finally, based on the correspondence between the interactive events, audio data, and rhythm information, they are bound together.
[0062] Based on this, by pre-setting candidate task events, selecting corresponding audio data, and binding rhythm information, a more flexible and intelligent strategy can be provided for audio playback in the target task scenario to adapt to diverse task scenario requirements.
[0063] Furthermore, determining the rhythm information of each audio data includes: calling an audio processing tool to perform rhythm analysis on each audio data to obtain the rhythm information of each audio data.
[0064] Audio processing tools refer to software, libraries, or toolkits used to process, analyze, and extract features from audio data. Rhythm analysis refers to the analysis of rhythm information in audio data, including the analysis of the audio's beat, tempo, and rhythmic patterns.
[0065] In practical applications, the first step is to determine the audio processing tool. This can be audio processing software, an audio processing library, or a toolkit specifically designed for audio feature extraction. These tools typically provide rich application programming interfaces (APIs) or functional interfaces for audio analysis and feature extraction. The second step is to import the audio data to be analyzed into the selected audio processing tool. This can be done through the tool's built-in import function or programming interface, ensuring the tool can access and manipulate the required audio files. Next, the rhythm analysis function provided by the audio processing tool is used to process the imported audio data. This may involve operations such as audio spectrum analysis, rhythm detection, and beat recognition to obtain rhythm information. Finally, after analysis, the rhythm information corresponding to each audio data point is obtained. This rhythm information may include the number of beats per measure (BPM), beat type (e.g., 4 / 4 time), and strong / weak rhythm patterns. This information helps to understand the rhythmic characteristics of the audio.
[0066] In a specific embodiment of this specification, following the example above, firstly, an audio processing tool is determined; secondly, the first audio data and the second audio data are imported into the audio processing tool; then, the first audio data and the second audio data are analyzed for rhythm using the audio processing tool; finally, it is determined that the first audio data and the second audio data have 4 beats per measure and 120 beats per minute as rhythm information.
[0067] Based on this, we can obtain more accurate and detailed audio feature information, and provide a foundation for subsequent audio processing, analysis and application.
[0068] Furthermore, the step of binding each candidate task event, each audio data, and each rhythm information based on the correspondence between candidate task events, audio data, and rhythm information includes: creating binding information for a target candidate task event, wherein the target candidate task event is any one of the plurality of candidate task events; obtaining data information and rhythm information of audio data pre-selected for the target candidate task event; adding the data information and rhythm information to the binding information to obtain a binding result for the target candidate task event.
[0069] The binding information can be a class or data structure used to bind candidate task events, audio data, and rhythm information.
[0070] In practical applications, firstly, a binding information is created to store the correspondence between candidate task events, audio data, and rhythm information. This binding information can be a data structure, using key-value pairs where candidate task events are the keys and the corresponding audio data and rhythm information are the values. Secondly, for all candidate task events, the data information and rhythm information of the pre-selected audio data for each candidate task event are retrieved. Finally, the retrieved audio data information and rhythm information are added to the binding information and associated with the corresponding candidate task event. For example, the data information and rhythm information can be used as values and the target candidate task event as keys, added to the binding information to obtain the binding result for the target candidate task event, which is the binding information containing the candidate task event, audio data, and rhythm information.
[0071] In a specific embodiment of this specification, following the previous example, an audio data structure is defined. For the first interaction event and the second interaction event, the first audio data and the rhythm information of the first audio data corresponding to the first interaction event are obtained, and the second audio data and the rhythm information of the second audio data corresponding to the second interaction event are obtained. The first interaction event, the first audio data and the rhythm information corresponding to the first audio data are added to the audio data structure for binding to obtain a first binding result. The second interaction event, the second audio data and the rhythm information corresponding to the second audio data are added to the audio data structure for binding to obtain a second binding result.
[0072] Based on this, by creating and updating binding information, the relationship between candidate task events, audio data, and rhythm information can be established, enabling flexible selection of appropriate audio data and rhythm information for binding and playback according to the needs of the task scenario.
[0073] Step 204: During the playback of the current audio data, in response to the target task event, determine the playback time of the current audio data, and based on the playback time and the rhythm information of the current audio data, determine the target end time for the current audio data to play a complete measure.
[0074] The current audio data includes multiple sections. The section containing the time corresponding to the played time of the current audio data is the current section, and the target end time indicates the expected end time of the current section.
[0075] In practical applications, firstly, timing begins when the current audio data starts playing. During the playback of the current audio data, if the target task event is triggered, the system determines the playback time of the current audio data based on the timing result, or records the start time of the current audio data playback and calculates the playback time of the current audio data based on the current time and the start time of the current audio data playback. Secondly, based on the rhythm information of the current audio data, the duration of a measure of the current audio data is determined, and the target end time for the current audio data to play the current measure completely is calculated.
[0076] In a specific embodiment of this specification, following the example above, taking a measure with a duration of 2 seconds as an example, firstly, timing begins when the first audio data is played. During the playback of the first audio data, the system detects that the player triggers a second interactive operation. Based on the timing result, the playback time of the current audio data is determined to be 35.9 seconds. Based on the duration of a measure of 2 seconds, the target end time for the complete playback of the current 18th measure of the first audio data is calculated to be 36 seconds.
[0077] In another specific embodiment of this specification, if the system is not currently playing any audio data, it can immediately play the target audio file corresponding to the target task event in response to the target task event, without needing to calculate the target end time.
[0078] Furthermore, determining the target end time for the complete playback of a measure of the current audio data based on the played time and the rhythm information of the current audio data includes: determining the measure duration of the current audio data based on the rhythm information; and calculating the end time of the current measure played by the current audio data based on the played time and the measure duration, as the target end time for the complete playback of a measure of the current audio data.
[0079] The current section refers to the section containing the time corresponding to the current playback time of the audio data.
[0080] In practical applications, firstly, rhythm information is obtained from the current audio data, which may include information such as the number of beats per measure and the number of beats per minute; secondly, the measure duration of the current audio data is calculated based on the rhythm information; then, based on the played time and measure duration, the end time of the current measure is calculated; finally, the end time of the current measure is used as the target end time for the current audio data to play a complete measure. This target end time can be used as a reference to help control the playback progress of the audio or achieve interactive effects synchronized with the beat.
[0081] In a specific embodiment of this specification, following the example above, firstly, the rhythm information of the first audio data is determined to be 4 beats per measure and 120 beats per minute; secondly, based on the rhythm information, the measure length of the first audio data is calculated to be (60 / 120)*4 = 2 seconds, where 60 is 60 seconds per minute; then, based on the already played time of 35.9 seconds and the measure length of 2 seconds, the current measure is calculated to be the 18th measure, and the end time of the current 18th measure is the 36th second; finally, the 36th second is taken as the target end time, that is, the second audio data is switched at the 36th second.
[0082] Based on this, by using the playback time and the rhythm information of the current audio data, the target end time for the current audio data to play a complete measure can be determined, achieving a more accurate rhythm perception and synchronization with the beat.
[0083] Furthermore, the rhythm information includes the tempo and number of beats per measure of the audio data; determining the measure duration of the current audio data based on the rhythm information includes: calculating the measure duration of the current audio data based on the tempo and number of beats per measure of the current audio data.
[0084] In practical applications, the tempo and number of beats per measure of the current audio data are obtained from the rhythm information. The tempo represents the number of beats per minute, while the number of beats per measure represents the number of beats contained in each measure. Based on the tempo and number of beats per measure of the current audio data, the measure duration of the current audio data is calculated as follows:
[0085] First, calculate the duration of each beat, which is 60 seconds divided by the tempo.
[0086] Then, multiply the duration of each beat by the number of beats per measure to obtain the measure duration of the current audio data.
[0087] In a specific embodiment of this specification, following the example above, the tempo of the current audio data (120 beats / minute) and the number of beats per measure (4) are obtained from the rhythm information, and the measure duration of the first audio data is calculated as follows:
[0088] First, calculate the duration of each beat: 60 / 120 = 0.5 seconds.
[0089] Then, multiply the duration of each beat (0.5) by the number of beats per measure (4) to get the measure length of the current audio data as 0.5 × 4 = 2 seconds.
[0090] Based on this, determining the duration of each measure in the audio data can further enable precise rhythm control and synchronization with the beat.
[0091] Further, the step of calculating the end time of the current segment played by the current audio data based on the played time and the segment duration, as the target end time for the complete playback of a segment of the current audio data, includes: determining the start time of the current segment played by the current audio data based on the played time and the segment duration; and determining the end time of the current segment played by the current audio data based on the start time and the segment duration, as the target end time for the complete playback of a segment of the current audio data.
[0092] In practical applications, the start time of the current segment played by the current audio data is calculated based on the played time and the segment duration. The end time of the current segment played by the current audio data is obtained by adding the segment duration to the determined start time of the current audio data. The end time of the current segment played by the current audio data is taken as the target end time for the current audio data to play a complete segment.
[0093] In a specific embodiment of this specification, following the example above, the result of dividing the played time by the measure length and rounding down is the number of measures that have been fully played, i.e., 35.9 / 2 = 17.95. Rounding down gives 17, meaning 17 measures have been fully played. Multiplying the number of measures played (17) by the measure length (2 seconds) gives the start time of the current measure, 17 × 2 = 34 seconds, meaning the 34th second is the start time of the current measure. Adding the start time of the current measure to the target end time of the first audio data being fully played for one measure gives 34 + 2 = 36 seconds.
[0094] Based on this, and using the playback time and the duration of the measure, the start and end times of the current measure played by the current audio data can be calculated, thus obtaining the target end time of a measure, which provides a basis for determining the appropriate switching time later.
[0095] Step 206: Determine the remaining time for the current audio data to be played based on the already played time and the target end time.
[0096] The remaining time is the absolute value of the difference between the time already played and the target end time.
[0097] In practical applications, after obtaining the played time and the target end time, the difference between the played time and the target end time is used to obtain the remaining time of the current audio data to be played.
[0098] In a specific embodiment of this specification, following the example above, after determining that the played time is 35.9 seconds and the target end time is the 36th second, the difference between the played time and the target end time is taken as the absolute value to obtain the remaining time as 0.1 seconds.
[0099] Step 208: If the remaining time is less than a preset threshold, switch the current audio data to the target audio data corresponding to the target task event for playback.
[0100] The preset threshold is used to determine whether the current playback time is a suitable time to switch.
[0101] In practical applications, the remaining time can be calculated in real time after the target task event is triggered. If the remaining time is less than the preset threshold, it means that the current segment has been played almost completely. At this time, switching the audio will not bring abruptness or disjointedness to the user. It is a suitable time to switch the current audio data to the target audio data corresponding to the target task event and start playing it. The time when the target audio data starts playing is recorded, and we wait for the next task event to be triggered.
[0102] In a specific embodiment of this specification, following the example above, taking a preset threshold of 0.2 seconds as an example, after calculating the remaining time to be 0.1 seconds, the remaining time is less than the preset threshold, indicating that the current playback moment has basically finished playing the current section. At this time, switching the audio will not bring a sense of abruptness or discontinuity to the player. It is a suitable time to switch, so the first audio data is switched to the second audio data corresponding to the second interactive operation and the playback starts, and the time when the second audio data starts playing is recorded, waiting for the next interactive operation to be triggered.
[0103] Furthermore, after determining the remaining time to be played for the current audio data based on the played time and the target end time, the method further includes: if the remaining time is greater than or equal to the preset threshold, continuing to play the current audio data and obtaining the played time of the current audio data in real time; until the remaining time is less than the preset threshold, switching the current audio data to the target audio data corresponding to the target task event for playback.
[0104] In practical applications, if the remaining time is greater than or equal to the preset threshold, it means that the current section is playing. This is not a suitable time to switch. The system will continue to play the current audio data and calculate the remaining time in real time as the current audio data continues to play, until the playback time of the current audio data is less than the preset threshold and then stop the real-time calculation.
[0105] In a specific embodiment of this specification, following the example above, taking a remaining time of 0.3 seconds as an example, after determining that the remaining time of 0.3 seconds is greater than the preset threshold of 0.2 seconds, the system will continue to play the first audio data and calculate the remaining time in real time as the first audio data continues to play, until the playback time of the first audio data is less than the preset threshold and the real-time calculation stops.
[0106] Based on this, the current audio data can be played continuously until the remaining time approaches the preset threshold, thereby achieving smooth playback and timely switching of audio data.
[0107] Furthermore, continuing to play the current audio data includes: obtaining the current playback volume of the current audio data; calculating the volume attenuation coefficient of the current audio data based on the remaining time and the current playback volume; and adjusting the current playback volume in real time based on the volume attenuation coefficient.
[0108] The attenuation factor is a proportional value used to represent the degree of volume reduction of an audio signal during playback. Its value is usually between 0 and 1. The closer it is to 1, the smaller the attenuation and the slower the volume decreases; while the closer it is to 0, the larger the attenuation and the faster the volume decreases.
[0109] In practical applications, firstly, the system obtains the current playback volume of the audio data, which can be obtained through an audio player or related audio processing tools. Secondly, based on the remaining time and the current playback volume, the system calculates a volume attenuation coefficient. The volume attenuation coefficient represents the proportion by which the volume of the current audio data should be adjusted as the remaining time decreases. Generally, the less time remaining, the larger the volume attenuation coefficient, indicating that the playback volume of the current audio data should be reduced. Finally, based on the calculated volume attenuation coefficient, the system adjusts the playback volume of the current audio data in real time. By multiplying by the volume attenuation coefficient, the playback volume of the current audio data can be gradually reduced to achieve a gradual attenuation effect before switching.
[0110] Based on this, audio playback can be made more natural, and the volume can be adjusted adaptively as the playback progress changes, creating a better audio experience.
[0111] By using the audio playback method in this task scenario, the target end time for the complete playback of one section of the currently playing audio is calculated. This allows the target audio data corresponding to the target task scenario to be played at the appropriate time, making the switch between the currently playing audio data and the target audio data smoother, reducing the abruptness and disjointedness of the switch, and improving the user experience.
[0112] See Figure 3 , Figure 3 This is a flowchart of an audio playback method in a game scene provided by an embodiment of the present invention, which specifically includes the following steps.
[0113] Step 302: Obtain multiple audio data associated with the target game scene, wherein each audio data is triggered to play in response to different player operations, and each audio data includes rhythm information.
[0114] In a specific embodiment of this specification, taking a dynamic scene in the game as an example, the target game scene is associated with the player's combat operation and escape operation. After determining the dynamic scene, the system obtains the combat audio and escape audio associated with the dynamic scene. The combat audio is played in response to the player's combat operation, and the escape audio is played in response to the player's escape operation.
[0115] Step 304: During the playback of the current audio data, in response to the target player's operation, determine the playback time of the current audio data, and based on the playback time and the rhythm information of the current audio data, determine the target end time for the current audio data to play a complete measure.
[0116] In a specific embodiment of this specification, taking a 2-second duration as an example, the timing begins when the battle audio starts playing. During the playback of the battle audio, the system detects that the player triggers an escape operation. Based on the timing result, the playback time of the current audio data is determined to be 35.9 seconds. Based on the 2-second duration of a 2-second duration, the target end time for the complete playback of the current 18th 2-second duration of the battle audio is calculated to be 36 seconds.
[0117] Step 306: Determine the remaining time for the current audio data to be played based on the already played time and the target end time.
[0118] In a specific embodiment of this specification, following the example above, after determining that the played time is 35.9 seconds and the target end time is the 36th second, the difference between the played time and the target end time is taken as the absolute value to obtain the remaining time as 0.1 seconds.
[0119] Step 308: If the remaining time is less than a preset threshold, switch the current audio data to the target audio data corresponding to the target player's operation for playback.
[0120] In a specific embodiment of this specification, following the example above, taking a preset threshold of 0.2 seconds as an example, after calculating the remaining time to be 0.1 seconds, the remaining time is less than the preset threshold, indicating that the current playback moment has basically finished playing the current section. At this time, switching the audio will not bring the player abruptness or sense of discontinuity. It is a suitable time to switch, so the combat audio is switched to the escape audio corresponding to the escape operation and the time when the escape audio starts playing is recorded, waiting for the next interactive operation to be triggered.
[0121] By using the audio playback method in this game scenario, the target end time of a complete segment of the currently playing audio is calculated. This allows the target audio data corresponding to the player's actions to be played at the appropriate time, making the transition between the currently playing audio data and the target audio data smoother, reducing the abruptness and disjointedness of the transition, and improving the player experience.
[0122] The following is in conjunction with the appendix Figure 4 Taking the application of the audio playback method in a task scenario provided by this invention in game development as an example, the audio playback method in the task scenario will be further explained. Figure 4 This is a flowchart of an audio playback method for a game development task scenario provided by an embodiment of the present invention, which specifically includes the following steps.
[0123] Step 402: Obtain the rhythm information corresponding to the game audio file.
[0124] Specifically, audio analysis software is used to analyze game audio files and obtain rhythm information corresponding to the game audio files, such as the number of beats per minute and the number of beats per measure.
[0125] Step 404: Definition of data structure.
[0126] Specifically, a class named AudioData is defined in the game program. This class contains member variables for storing audio information, such as AudioClip (the file name of the audio file), tempo (beats per minute), and beats per measure (beats per measure), and a calling method is set.
[0127] Step 406: Set parameters.
[0128] Specifically, when the game scene loads, the audio file is bound to relevant parameters by calling the setting method of the AudioData class.
[0129] Step 408: Real-time calculation and triggering.
[0130] Specifically, during the playback of any audio file in a dynamic scene (i.e., the summary of the current audio data playback process), after detecting that the player has triggered an attack on an enemy or other key game events, the playback time (the playback time of the current audio data) is obtained in real time, the current measure number and the remaining time before the start of the next measure are calculated, and the currently playing audio file is switched when the remaining time is less than a preset threshold, to ensure that the audio file is triggered accurately and smoothly in the dynamic scene.
[0131] This audio playback method, applied to task scenarios in game development, enables game developers to precisely trigger audio elements at crucial moments, enhancing the gaming experience. It is suitable for dynamic scenarios, such as combat and story sequences, ensuring a high degree of coordination between audio elements and the game environment. Compared to traditional instant playback methods, it offers greater flexibility, meeting the precise audio control requirements of various application domains.
[0132] Corresponding to the above method embodiments, the present invention also provides an audio playback device embodiment for a task scenario. Figure 5 This is a schematic diagram of the structure of an audio playback device in a task scenario provided by an embodiment of the present invention. Figure 5 As shown, the device includes:
[0133] The first acquisition module 502 is configured to acquire multiple audio data associated with the target task scene, wherein each audio data is triggered to play in response to a different task event, and each audio data includes rhythm information;
[0134] The first determining module 504 is configured to, in response to a target task event during the playback of the current audio data, determine the playback time of the current audio data, and based on the playback time and the rhythm information of the current audio data, determine the target end time for the current audio data to play a complete measure.
[0135] The second determining module 506 is configured to determine the remaining time to be played for the current audio data based on the already played time and the target end time.
[0136] The first switching module 508 is configured to switch the current audio data to the target audio data corresponding to the target task event for playback when the remaining time is less than a preset threshold.
[0137] Optionally, the audio playback device in the task scenario further includes a continue playback module, configured to continue playing the current audio data and obtain the playback time of the current audio data in real time when the remaining time is greater than or equal to the preset threshold; until the remaining time is less than the preset threshold, the current audio data is switched to the target audio data corresponding to the target task event for playback.
[0138] Optionally, the continue playback module is further configured to retrieve the current playback volume of the current audio data; calculate the volume attenuation coefficient of the current audio data based on the remaining time and the current playback volume; and adjust the current playback volume in real time based on the volume attenuation coefficient.
[0139] Optionally, the first determining module 504 is further configured to determine the measure duration of the current audio data based on the rhythm information; and to calculate the end time of the current measure played by the current audio data based on the playback time and the measure duration, as the target end time for the current audio data to play a complete measure.
[0140] Optionally, the first determining module 504 is further configured to calculate the measure duration of the current audio data based on the beat speed and the number of beats per measure of the current audio data.
[0141] Optionally, the first determining module 504 is further configured to determine the start time of the current section to which the current audio data is played based on the played time and the section duration; and to determine the end time of the current section to which the current audio data is played based on the start time and the section duration, as the target end time for the current audio data to play a complete section.
[0142] Optionally, the audio playback device in the task scenario further includes a binding module, configured to acquire multiple candidate task events pre-set for the target task scenario, and audio data pre-selected for each candidate task event; determine the rhythm information of each audio data; and bind each candidate task event, each audio data, and each rhythm information based on the correspondence between the candidate task events, audio data, and rhythm information.
[0143] Optionally, the binding module is further configured to invoke an audio processing tool to perform rhythm analysis on each audio data to obtain the rhythm information of each audio data.
[0144] Optionally, the binding module is further configured to create binding information for a target candidate task event, wherein the target candidate task event is any one of the plurality of candidate task events; obtain data information and rhythm information of audio data pre-selected for the target candidate task event; add the data information and rhythm information to the binding information to obtain a binding result for the target candidate task event.
[0145] By using the audio playback device in this task scenario, the target end time for the complete playback of a section of the currently playing audio can be calculated. This allows the target audio data corresponding to the target task scenario to be played at the appropriate time, making the switch between the currently playing audio data and the target audio data smoother, reducing the abruptness and disjointedness of the switch, and improving the user experience.
[0146] The above is an illustrative scheme of an audio playback device in a task scenario according to this embodiment. It should be noted that the technical solution of the audio playback device in this task scenario and the technical solution of the audio playback method in the task scenario described above belong to the same concept. For details not described in detail in the technical solution of the audio playback device in the task scenario, please refer to the description of the technical solution of the audio playback method in the task scenario described above.
[0147] Corresponding to the above method embodiments, the present invention also provides an embodiment of an audio playback device in a game scene. Figure 6 This is a schematic diagram of the structure of an audio playback device in a game scene according to an embodiment of the present invention. Figure 6 As shown, the device includes:
[0148] The second acquisition module 602 is configured to acquire multiple audio data associated with the target game scene, wherein each audio data is triggered to play in response to different player operations, and each audio data includes rhythm information;
[0149] The third determining module 604 is configured to, in response to the target player's operation during the playback of the current audio data, determine the playback time of the current audio data, and determine the target end time for the current audio data to play a complete measure based on the playback time and the rhythm information of the current audio data.
[0150] The fourth determining module 606 is configured to determine the remaining time to be played for the current audio data based on the already played time and the target end time.
[0151] The second switching module 608 is configured to switch the current audio data to the target audio data corresponding to the target player's operation when the remaining time is less than a preset threshold.
[0152] By using the audio playback device in the game scene, the target end time of a complete segment of the currently playing audio is calculated. The target audio data corresponding to the target player's operation can be played at the appropriate time, making the switch between the currently playing audio data and the target audio data smoother, reducing the abruptness and disjointedness of the switch, and improving the player experience.
[0153] The above is an illustrative scheme of an audio playback device in a game scene according to this embodiment. It should be noted that the technical solution of the audio playback device in the game scene and the technical solution of the audio playback method in the game scene described above belong to the same concept. For details not described in detail in the technical solution of the audio playback device in the game scene, please refer to the description of the technical solution of the audio playback method in the game scene described above.
[0154] Figure 7 A structural block diagram of a computing device 700 according to an embodiment of the present invention is shown. The components of the computing device 700 include, but are not limited to, a memory 710 and a processor 720. The processor 720 is connected to the memory 710 via a bus 730, and a database 770 is used to store data.
[0155] The computing device 700 also includes an access device 740, which enables the computing device 700 to communicate via one or more networks 760. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. The access device 740 may include one or more of any type of wired or wireless network interface (e.g., a network interface card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Wi-MAX (Worldwide Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, or a Near Field Communication (NFC) interface.
[0156] In one embodiment of the present invention, the above-described components of the computing device 700 and Figure 7 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 7 The illustrated block diagram of the computing device is for illustrative purposes only and is not intended to limit the scope of the invention. Those skilled in the art can add or replace other components as needed.
[0157] The computing device 700 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or personal computers (PCs). The computing device 700 can also be a mobile or stationary server.
[0158] The processor 720 is configured to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the audio playback method in the above-described task scenario or the audio playback method in the game scenario.
[0159] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device belongs to the same concept as the audio playback method in the above-described task scenario or audio playback method in the game scenario. For details not described in detail in the technical solution of the computing device, please refer to the description of the audio playback method in the above-described task scenario or audio playback method in the game scenario.
[0160] An embodiment of the present invention also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the audio playback method in the above-described task scenario or the audio playback method in the game scenario.
[0161] The above is an illustrative embodiment of a computer-readable storage medium. It should be noted that the technical solution of this storage medium belongs to the same concept as the audio playback method in the above-described task scenario or game scenario. Details not described in detail in the technical solution of the storage medium can be found in the descriptions of the audio playback method in the above-described task scenario or game scenario.
[0162] An embodiment of the present invention also provides a computer program, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the audio playback method in the above-described task scenario or the audio playback method in the game scenario.
[0163] The above is an illustrative example of a computer program according to this embodiment. It should be noted that the technical solution of this computer program belongs to the same concept as the audio playback method in the above-described task scenario or game scenario. Details not described in detail in the computer program's technical solution can be found in the descriptions of the audio playback method in the above-described task scenario or game scenario.
[0164] The foregoing has described specific embodiments of the invention. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0165] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added or removed according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0166] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments of the present invention.
[0167] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0168] The preferred embodiments of the present invention disclosed above are merely illustrative of the invention. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the embodiments of the present invention. These embodiments are selected and specifically described to better explain the principles and practical applications of the present invention, thereby enabling those skilled in the art to better understand and utilize the invention. The present invention is limited only by the claims and their full scope and equivalents.
Claims
1. An audio playback method in a task scenario, characterized in that, include: Acquire multiple audio data associated with the target task scenario, wherein each audio data is triggered to play in response to a different task event, and each audio data includes rhythm information; During the playback of the current audio data, in response to the target task event, the playback time of the current audio data is determined, and based on the playback time and the rhythm information of the current audio data, the target end time for the current audio data to play a complete measure is determined; Based on the already played time and the target end time, determine the remaining time for the current audio data to be played; If the remaining time is greater than or equal to a preset threshold, the volume attenuation coefficient of the current audio data is calculated based on the remaining time and the current playback volume, and the current playback volume is adjusted in real time based on the volume attenuation coefficient. If the remaining time is less than a preset threshold, the current audio data will be switched to the target audio data corresponding to the target task event for playback.
2. The method according to claim 1, characterized in that, Before calculating the volume attenuation coefficient of the current audio data based on the remaining time and the current playback volume, the method further includes: Real-time acquisition of the playback time of the current audio data; If the remaining time is less than the preset threshold, the current audio data will be switched to the target audio data corresponding to the target task event for playback.
3. The method according to claim 1, characterized in that, The step of determining the target end time for the complete playback of one measure of the current audio data based on the already played time and the rhythm information of the current audio data includes: Based on the rhythm information, the measure duration of the current audio data is determined; Based on the played time and the duration of the segment, the end time of the current segment played by the current audio data is calculated, which is used as the target end time for the current audio data to play a complete segment.
4. The method according to claim 3, characterized in that, The rhythm information includes the tempo and number of beats per measure of the audio data; determining the measure duration of the current audio data based on the rhythm information includes: Calculate the duration of a measure in the current audio data based on the tempo and number of beats per measure.
5. The method according to claim 3, characterized in that, The step of calculating the end time of the current segment played by the current audio data, based on the already played time and the segment duration, as the target end time for the current audio data to complete a segment, includes: Based on the already played time and the duration of the segment, determine the start time of the current segment to which the current audio data is being played; Based on the start time and the duration of the measure, the end time of the current measure played by the current audio data is determined as the target end time for the current audio data to play a complete measure.
6. The method according to claim 1, characterized in that, Before acquiring the multiple audio data associated with the target task scene, the method further includes: Acquire multiple candidate task events pre-set for the target task scenario, and audio data pre-selected for each candidate task event; Determine the rhythm information of each audio data; Based on the correspondence between candidate task events, audio data, and rhythm information, each candidate task event, each audio data, and each rhythm information is bound together.
7. The method according to claim 6, characterized in that, Determining the rhythm information of each audio data includes: The audio processing tool is invoked to perform rhythm analysis on each audio data to obtain the rhythm information of each audio data.
8. The method according to claim 6, characterized in that, The process of binding each candidate task event, each piece of audio data, and each piece of rhythm information based on the correspondence between candidate task events, audio data, and rhythm information includes: Create binding information for a target candidate task event, wherein the target candidate task event is any one of the plurality of candidate task events; Acquire data information and rhythm information of audio data pre-selected for the target candidate task event; The data information and rhythm information are added to the binding information to obtain the binding result for the target candidate task event.
9. An audio playback method in a game scene, characterized in that, include: Acquire multiple audio data associated with the target game scene, wherein each audio data is triggered to play in response to different player operations, and each audio data includes rhythm information; During the playback of the current audio data, in response to the target player's operation, the playback time of the current audio data is determined, and based on the playback time and the rhythm information of the current audio data, the target end time for the current audio data to play a complete measure is determined; Based on the already played time and the target end time, determine the remaining time for the current audio data to be played; If the remaining time is greater than or equal to a preset threshold, the volume attenuation coefficient of the current audio data is calculated based on the remaining time and the current playback volume, and the current playback volume is adjusted in real time based on the volume attenuation coefficient. If the remaining time is less than a preset threshold, the current audio data will be switched to the target audio data corresponding to the target player's operation for playback.
10. An audio playback device for a task scenario, characterized in that, include: The first acquisition module is configured to acquire multiple audio data associated with the target task scene, wherein each audio data is triggered to play in response to a different task event, and each audio data includes rhythm information; The first determining module is configured to, during the playback of the current audio data, respond to a target task event, determine the playback time of the current audio data, and determine the target end time for the current audio data to play a complete measure based on the playback time and the rhythm information of the current audio data. The second determining module is configured to determine the remaining time to be played for the current audio data based on the already played time and the target end time. The first adjustment module is configured to, when the remaining time is greater than or equal to a preset threshold, calculate the volume attenuation coefficient of the current audio data based on the remaining time and the current playback volume, and adjust the current playback volume in real time based on the volume attenuation coefficient. The first switching module is configured to switch the current audio data to the target audio data corresponding to the target task event for playback when the remaining time is less than a preset threshold.
11. An audio playback device for a game scene, characterized in that, include: The second acquisition module is configured to acquire multiple audio data associated with the target game scene, wherein each audio data is triggered to play in response to different player operations, and each audio data includes rhythm information; The third determining module is configured to, in response to the target player's operation during the playback of the current audio data, determine the playback time of the current audio data, and based on the playback time and the rhythm information of the current audio data, determine the target end time for the current audio data to play a complete measure. The fourth determining module is configured to determine the remaining time for the current audio data to be played based on the already played time and the target end time; The second adjustment module is configured to, when the remaining time is greater than or equal to a preset threshold, calculate the volume attenuation coefficient of the current audio data based on the remaining time and the current playback volume, and adjust the current playback volume in real time based on the volume attenuation coefficient. The second switching module is configured to switch the current audio data to the target audio data corresponding to the target player's operation when the remaining time is less than a preset threshold.
12. A computing device, characterized in that, include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, they implement the steps of the audio playback method in the task scenario of any one of claims 1-8 or the audio playback method in the game scenario of claim 9.
13. A computer-readable storage medium, characterized in that, It stores computer-executable instructions, which, when executed by a processor, implement the steps of the audio playback method in the task scenario described in any one of claims 1-8 or the audio playback method in the game scenario described in claim 9.
Citation Information
Patent Citations
Music edit device and music edit method
CN101322180A
Audio playing control method and device in game scenes
CN108355356A
