Music playing method, device and electronic equipment in game

By determining the beat interval of the first piece of music in the virtual game and playing the second piece of music in time with the first piece, the problem of uneven playback between narrative and non-narrative music was solved, achieving a smooth transition of game music and improving the user experience.

CN117582663BActive Publication Date: 2026-08-04NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311437498.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-31
Publication Date
2026-08-04
Estimated Expiration
2043-10-31

AI Technical Summary

Technical Problem

The separate playback methods for narrative and non-narrative music in related technologies result in choppy game music playback, causing confusion and disjointed transitions, which negatively impacts the user experience.

Method used

When playing the first piece of music in a virtual game, determine its beat interval, and play the second piece of music in time with the first piece of music. Based on the beat interval, determine the timing of the second piece of music to ensure a smoother musicality when the two pieces of music are synchronized or switched in the virtual game.

Benefits of technology

The card-based playback mechanism improves the smoothness of game music and user experience, ensuring a smooth transition of music throughout the game and enhancing the overall auditory experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117582663B_ABST
    Figure CN117582663B_ABST
Patent Text Reader

Abstract

The application discloses a music playing method and device in a game, electronic equipment and a computer readable storage medium. The method comprises the following steps: playing first music in a virtual game, and determining a beat interval of the first music; obtaining second music to be played in the virtual game; determining a playing time of the second music relative to the first music based on the beat interval according to the principle that the second music is played in sync with the first music; and playing the second music in the virtual game according to the playing time. The scheme provided by the application can make the music played in different games more smooth, thereby improving the game experience of users.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a method, apparatus, electronic device, and computer-readable storage medium for playing music in a game. Background Technology

[0002] Music is an important element in creating a good gaming experience in virtual games. The music in games usually includes narrative music and non-narrative music. Narrative music refers to the actual sounds made by virtual objects in the game scene, such as the voices of virtual characters, the sounds of instruments, and the sounds of objects colliding. Non-narrative music refers to the background music, narration, and other sounds added in post-production. Non-narrative music is used to create the game atmosphere.

[0003] When adding music to games using related technologies, non-narrative music is typically played at the appropriate times. For example, opening background music is played at the start of the game, narration is played when the narration begins (e.g., when the second stage of the game is reached), and narrative music is played when the appropriate times are reached. For example, the music emitted by an instrument is played when the player triggers it, or the song corresponding to the virtual character is played when the player triggers a singing skill or when the virtual character reaches a preset position.

[0004] However, this method of playing narrative and non-narrative music separately can easily lead to choppy game music playback. For example, playing narrative and non-narrative music simultaneously can cause game music chaos, and switching between narrative and non-narrative music can cause discontinuous transitions, affecting the user's gaming experience. Summary of the Invention

[0005] This application provides a method, apparatus, electronic device, and computer-readable storage medium for playing music in games, which enables smoother playback of different music tracks in games, thereby improving the user's gaming experience. The specific method is as follows.

[0006] In a first aspect, embodiments of this application provide a method for playing music in a game, the method comprising:

[0007] Play the first piece of music in the virtual game and determine the beat interval of the first piece of music;

[0008] Obtain the second piece of music to be played in the virtual game;

[0009] Based on the principle of playing the second music in time with respect to the first music, the timing of playing the second music relative to the first music is determined according to the beat interval.

[0010] The second music is played in the virtual game according to the specified playback timing.

[0011] Secondly, embodiments of this application also provide a music playback device for games, the device comprising:

[0012] The first playback unit is used to play the first music in the virtual game and determine the beat interval of the first music;

[0013] The acquisition unit is used to acquire the second piece of music to be played in the virtual game;

[0014] The determining unit is used to determine the timing of the second music relative to the first music based on the beat interval, with the principle that the second music is played in time with respect to the first music.

[0015] The second playback unit is used to play the second music in the virtual game according to the playback timing.

[0016] Thirdly, embodiments of this application also provide an electronic device, including:

[0017] Processor; and

[0018] A memory for storing a data processing program, which, when the electronic device is powered on and runs by the processor, executes the method described in any one of the first, second, or third aspects.

[0019] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a data processing program that is executed by a processor to perform the method described in any of the first aspects.

[0020] Compared with the prior art, this application has the following advantages:

[0021] The music playback method in the game provided in this application plays a first piece of music in a virtual game, determines the beat interval of the first piece of music, and obtains a second piece of music to be played in the virtual game. Based on the principle that the second piece of music is played in time with the first piece of music, the timing of the second piece of music relative to the first piece of music is determined based on the beat interval of the first piece of music. The second piece of music is then played in the virtual game according to the determined timing. Since the determined timing is based on the principle that the second piece of music is played in time with the first piece of music, when the second piece of music is played according to the timing, the second piece of music can be played in time with the first piece of music that is being played. This makes the simultaneous playback or switching between the second piece of music and the first piece of music more fluid and improves the user's gaming experience. Attached Figure Description

[0022] Figure 1 This is a flowchart of an example of a music playback method in a game provided in this application embodiment;

[0023] Figure 2 This is a schematic diagram of the musical beat of the first piece of music in the embodiments of this application;

[0024] Figure 3 This is a schematic diagram of the operation interface for callback settings in this application embodiment;

[0025] Figure 4 This is a structural diagram of an example of a music playback device in a game provided in this application embodiment;

[0026] Figure 5 This is a schematic diagram of the logical structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0027] Many specific details are set forth in the following description to provide a full understanding of this application. However, this application can be implemented 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 this application; therefore, this application is not limited to the specific embodiments disclosed below.

[0028] Game music is a key element in creating a good gaming experience, and the music design in a game can fully demonstrate the developer's deep understanding of the importance of music. Game music usually includes narrative music and non-narrative music. Narrative music refers to the actual sounds made by virtual objects in the game scene, such as the voices of virtual characters, the sounds of instruments, and the sounds of objects colliding. Non-narrative music refers to the sounds added in post-production, such as background music, narration, and opening music. Non-narrative music is used to create the game atmosphere.

[0029] When adding music to games using related technologies, non-narrative music is usually played when the time for non-narrative music to play is reached. For example, opening background music is played at the beginning of the game, narration is played when the time for narration to play is reached (such as when the second stage of the game is reached), and narrative music is played when the time for narrative music to play is reached. For example, the music emitted by an instrument is played when the instrument is triggered by the player, the song corresponding to the virtual character is played when the player corresponding to the virtual character triggers a singing skill, or when the virtual character reaches a preset position.

[0030] However, this method of playing narrative and non-narrative music separately can easily lead to choppy game music playback. For example, playing narrative and non-narrative music simultaneously can cause game music chaos, and switching between narrative and non-narrative music can cause discontinuous transitions, affecting the user's gaming experience.

[0031] To improve the smoothness of music playback in games and enhance the user's gaming experience, the first embodiment of this application provides a method for playing music in games. The device implementing the solution provided in this application can be an electronic device, such as a desktop computer, laptop computer, server, mobile device, smartwatch, game console, smart TV, tablet computer, or other devices capable of running games.

[0032] like Figure 1 As shown, the music playback method in the game provided in the first embodiment of this application includes the following steps S110 to S140.

[0033] Step S110: Play the first music in the virtual game and determine the beat interval of the first music.

[0034] The aforementioned virtual games can be real-time strategy games, simulation games, parkour games, card games, shooting games, etc., or any other games that require music to be added to the game. This application does not specifically limit them.

[0035] Step S110 involves playing the first piece of music during the operation of the virtual game. In this embodiment, before step S110, a virtual game scene corresponding to the virtual game can be displayed on the graphical user interface, so that the virtual game plays the first piece of music while displaying the virtual game scene.

[0036] The aforementioned first music can be non-narrative music such as background music, narration music, and sound effects music. Non-narrative music can be understood as the sounds emitted by virtual objects (including virtual characters, virtual items, virtual pets, etc.) in non-virtual game scenes. The first music can also be narrative music such as the singing voice of the player's virtual character or the playing sound of virtual instruments. For example, the first music could be the singing voice of the player's virtual character or the singing voice of a virtual radio. This application does not specifically limit this.

[0037] When playing the first piece of music in a virtual game, the timing of its playback can be determined based on its type and can be preset. For example, if the first piece is the opening background music, it can be played when the game reaches its start time or when the game finishes loading and displays the opening screen; if the first piece is a sound effect after a level is completed, it can be played when the player completes the level (in this case, the sound effect is non-narrative music); if the first piece is a singing voice from a virtual character, it can be played after the player triggers a singing command for the virtual character; if the first piece is a singing voice from a virtual radio, it can be played when the player triggers a music playback command for the virtual radio. The timing of the first piece of music varies depending on its type and function, and is not specifically limited in this field.

[0038] In this embodiment, the first music includes musical attributes such as rhythm, beat, tempo, and pitch, but is not limited to these. Once the first music is created, its corresponding musical attributes are also generated. In this embodiment, the first music has pre-set corresponding musical attributes, and the electronic device can determine the beat interval of the first music based on these attributes.

[0039] Optionally, in step S110, the beat interval of the first music can be determined by the following steps: obtaining the tempo information corresponding to the first music, and determining the beat interval of the first music based on the tempo information, wherein the tempo information is used to indicate the number of beats of the first music per unit time.

[0040] Since the total length of a piece of music is usually on the order of minutes, the above-mentioned tempo information can specifically be the number of beats per minute (BPM) for the first piece of music. For example, if the BPM for the first piece of music is 120, then the beat interval for the first piece of music is 0.5 seconds, or 500 milliseconds. That is to say, the first piece of music has one beat every 500 milliseconds, and the time interval between two adjacent beats in the first piece of music is 500 milliseconds. The beat interval of the first piece of music can be quickly and easily determined using tempo information.

[0041] Step S120: Obtain the second piece of music to be played in the virtual game.

[0042] The aforementioned second music can be non-narrative music such as background music, narration music, and sound effects music. It can also be narrative music such as singing voices from the player's virtual character, playing sounds from virtual instruments, or onomatopoeic sounds. Specific examples can be found in the explanation of the first music; they will not be detailed here.

[0043] The second piece of music can be different from the first piece. The second piece of music can be of the same type as the first piece of music, for example, both the first and second pieces of music can be narrative music or both can be non-narrative music. The second piece of music can also be of a different type than the first piece of music, for example, the first piece of music is narrative music and the second piece of music is non-narrative music.

[0044] The second music can be music with musical attributes such as rhythm, beat, tempo, and pitch; the second music can also be music without musical attributes such as rhythm, such as a percussion sound or a recitation. In this case, the second music can also be a second audio. This application does not specifically limit it.

[0045] During the operation of virtual games, it is common to overlay other music on top of background music. For example, rhythmic sounds such as drums or chimes might be overlaid on top of background music. In this case, the first piece of music can be non-narrative music such as background music or sound effects, while the second piece of music can be narrative music such as drums or chimes. When the second piece of music is music emitted by virtual instruments such as drums or chimes, it can be a single, instantaneous sound emitted by a virtual instrument triggered once. In this case, the player triggers a virtual instrument once, producing one sound, to more realistically simulate the scenario of the player playing a real instrument. Alternatively, the second piece of music can be a continuous sound of instruments. In this case, the player triggers a virtual instrument once, and the instrument can continuously emit sound, reducing the player's operational procedures. The specific settings can be determined according to actual needs, and this application does not specifically limit them.

[0046] In this embodiment of the application, the specific content of the first and second music can be determined according to the actual situation of the game's music, and is not specifically limited here.

[0047] In this embodiment, a first piece of music and a second piece of music corresponding to the virtual game are preset. In step S120, the preset second piece of music in the virtual game can be acquired. Specifically, the second piece of music can be acquired when the preset playback time corresponding to the second piece of music is reached, or when a playback command for the second piece of music is detected, or at the start of the game. This application does not limit the specific timing of acquiring the second piece of music, as long as the timing of acquiring the second piece of music does not affect the timely playback of the second piece of music.

[0048] Step S130: Based on the principle of playing the second music in time with the first music, determine the timing of playing the second music relative to the first music according to the beat interval of the first music.

[0049] In this embodiment of the application, the second music is played in time with the first music. This can be either the second music playing at a full beat point of the first music or the second music playing at a fractional beat point of the first music. Fractional beat points can be, for example, 1 / 2 beat point, 1 / 3 beat point, 1 / 4 beat point, or other fractional beat points.

[0050] Specifically, the timing of the second music relative to the first music can include: the playback time of the second music relative to the first music being the same as the time corresponding to a whole beat point of the first music, or the playback time of the second music relative to the first music being the same as the time corresponding to N equally divided time intervals (i.e., fractional beat points) between adjacent beat points of the first music. N can be an integer greater than or equal to 2. For example, the equally divided time intervals can be 2 equally divided time intervals, 3 equally divided time intervals, 4 equally divided time intervals, etc., but are not limited to these. For example, if the BPM of the first music is 120, then the beat interval of the first music is 500 milliseconds. Every 500 milliseconds is a whole beat point of the first music. The playback time of the second music relative to the first music can be the time corresponding to every 500 milliseconds during the playback of the first music, or the playback time of the second music relative to the first music can also be the time corresponding to every 250 milliseconds, every 166.67 milliseconds, every 125 milliseconds, etc. during the playback of the first music.

[0051] For example, such as Figure 2 As shown, Figure 2 In the middle, the beat markers corresponding to odd numbers represent whole beat points, and the beat markers corresponding to the half-beat points between two adjacent whole beat points represent half-beat points. The division of other fractional beat points is similar to that of half-beat points, and will not be detailed here.

[0052] In one embodiment, step S130 can be implemented by following steps S131 to S132.

[0053] Step S131: Determine the first playback time of the first music based on the above beat interval.

[0054] The aforementioned first playback moment includes the moment corresponding to a whole beat point of the first music and / or the moment corresponding to an equal time interval point between adjacent whole beat points of the first music. That is, the first playback moment includes the moment corresponding to a whole beat point of the first music, or the first playback moment includes the moment corresponding to an equal time interval point (i.e., a fractional beat point) between adjacent whole beat points of the first music, or the first playback moment includes both the moment corresponding to a whole beat point of the first music and the moment corresponding to an equal time interval point between adjacent whole beat points of the first music.

[0055] Step S132: Determine the first playback time as the playback timing of the second music relative to the first music.

[0056] The equal time intervals between adjacent whole beat points mentioned above are the 1 / 2 beat point, 1 / 3 beat point, 1 / 4 beat point, and other fractional beat points mentioned above.

[0057] In this embodiment, the trigger timing type for the second music relative to the first music can be preset by the designer. The trigger timing types include: the second music playing at a full beat of the first music, and the second music playing at a fractional beat of the first music. When the trigger timing type is that the second music plays at a full beat of the first music, the first playback time includes the time corresponding to the full beat of the first music. When the trigger timing type is that the second music plays at a fractional beat of the first music, the first playback time includes the time corresponding to the fractional beat of the first music.

[0058] In practical operation, taking the setting of music playback in a game through the Wwise audio engine as an example, when the playback timing of the second music relative to the first music is at the moment corresponding to the whole beat of the first music, the event of playing the second music can be triggered through the Beat callback function in Wwise. The Beat callback function is used to send a callback notification at the moment corresponding to the beat of the first music. For example, if the BPM of the first music is 120, the Beat callback function sends a callback notification every 500 milliseconds, and the electronic device will play the second music according to the callback notification. When the playback timing of the second music relative to the first music is at the moment corresponding to both the whole beat and the fractional beat of the first music, the event of playing the second music can be triggered through the Grid callback function in Wwise. The Grid callback function is used to send a callback notification at the moments corresponding to the fractional beat and the whole beat of the first music. For example, if the BPM of the first music is 120, and the user sets the division parameter to Triplet in the Grid callback function... If the 8th beat (which is to divide a beat into three equal parts) is used, then the Grid callback function is used to send a callback notification every 500 / 3 = 166.67 milliseconds, and the electronic device plays the second beat according to the callback notification.

[0059] For example, such as Figure 3As shown, in the music settings interface of the Wwise engine, the playback timing of the second music relative to the first music can be set in the music playback event settings window (i.e., the Post Event window) corresponding to the second music. For example, the user can set the sending timing of the callback notification relative to the first music in the callback setting control (i.e., the Callback Mask control) in the Post Event window, thereby determining the callback function used based on the sending timing of the callback notification set by the user. Specifically, the user can customize the callback function in the callback function type setting control and callback information setting control in the Custom Event window. Other parameters of the callback information can also be set in other settings windows later. This part is an introduction to the specific operation of selecting and setting the callback notification timing for the Wwise engine. Those skilled in the art can perform specific operations according to different actual needs and different music production software used. The operation process can realize the various steps of this application, and the specific operation process will not be described in detail here.

[0060] Designers can choose the type of the first playback moment according to the specific needs of the game scenario. For example, they can choose to use the Beat function mentioned above or the Grid function mentioned above to send a callback notification to notify whether the second music is ready to play. In other words, they can choose whether the second music is played at the beat point relative to the first music or at the fractional beat point of the first music.

[0061] In this embodiment, since the first playback moment of the first music includes multiple beat points and / or multiple fractional beat points of the first music, each whole beat point or each fractional beat point of the first music is determined as the playback timing of the second music relative to the first music. This allows the second music to be played flexibly at the positions of each whole beat point or fractional beat point of the first music, making the second music more flexible while playing in time with the first music. For player-triggered second music, such as the drum sound triggered by the player's virtual character's virtual drumming action or the singing voice triggered by the player's virtual character's singing action, this type of second music is played in real-time by the player. This embodiment allows for timely and time-matched playback of music triggered by the player in real-time.

[0062] In another implementation, step S130 can also be implemented according to the following steps S133 to S134.

[0063] Step S133: Obtain the preset insertion time of the second music relative to the first music.

[0064] The aforementioned preset insertion time is the timing of the first music's beat, determined based on the beat interval of the first music.

[0065] In this embodiment, the designer can pre-set the timing of the second music relative to the first music based on actual needs and the beat interval of the first music. In this case, the electronic device can obtain the preset insertion time of the second music relative to the first music set by the designer.

[0066] Step S134: Determine the preset insertion time as the playback timing of the second music relative to the first music.

[0067] This implementation method applies to situations where the second music is not triggered by the player, such as when narration or rap is added at a certain point during the playback of the first music.

[0068] In actual operation, taking the setting of music playback in the game through the Wwise audio engine as an example, when the preset insertion time is determined as the playback time of the second music relative to the first music, the event of playing the second music can be triggered by the UserCue callback function in Wwise. The UserCue callback function is used to send a callback notification at the user-set time point of the first music, for example, sending a callback notification at the 50th second of the first music. After receiving the callback notification sent by the UserCue callback function, the electronic device plays the second music.

[0069] This implementation allows users or designers to flexibly set the playback timing of the second music relative to the first music according to design needs, making it simpler and more convenient for electronic devices to trigger the second music to play at the desired timing.

[0070] Step S140: Play the second music in the virtual game according to the above playback timing.

[0071] This embodiment of the application can be understood as playing a second piece of music while the first piece of music is playing. Specifically, playing the second piece of music can be done by stopping the first piece of music and then playing the second piece of music, or the second piece of music can be played simultaneously with the first piece of music. The following will provide a detailed explanation of how to play the second piece of music.

[0072] When the above playback timing is the preset insertion time, the second music can be played when the above playback timing is reached.

[0073] When the aforementioned playback timing coincides with the first playback moment of the first music track, if the second music track only depends on the playback timing of the first music track and does not depend on other conditions, such as user triggering or a pre-set playback time, then the second music track can be played when the first playback moment of the first music track is detected. For example, if the first playback moment of the first music track is a full beat of the first music track, then the second music track can begin playing at the first full beat of the first music track while the first music track is playing.

[0074] When the aforementioned playback timing is the first playback moment of the first music, if the second music depends not only on the playback timing of the first music, but also on the user's triggering of the second music playback operation, the preset initial playback timing of the second music, etc., for example, when the user triggers the drumming action, the second music of the drum sound is played; when the user triggers the dancing action, the second music of the dance accompaniment is played; when it is preset to play the second music when the user's score reaches a preset score, in one embodiment, the second music can be played according to the following steps S141 to S143.

[0075] Step S141: Determine the initial playback time of the second music in the virtual game.

[0076] The aforementioned initial playback time can be understood as the playback time of the second piece of music before it is played in time with the first piece of music.

[0077] In this embodiment of the application, the virtual game can display a virtual game scene through a graphical user interface. The virtual game scene may include a first virtual object, which is used to emit corresponding music, and the second music is the music emitted by the first virtual object.

[0078] Optionally, in step S141, in response to a music playback command on the first virtual object, the trigger time of the music playback command can be determined as the initial playback time of the second music in the virtual game. The first virtual object can be, for example, a virtual musical instrument such as a drum, clapper, or piano in the virtual game scene, or a virtual electronic device used to play the second music, such as a virtual stereo or a virtual mobile phone, but is not limited thereto. The music playback command can include, for example, a click command on the first virtual object, a selection command for the music playback control corresponding to the first virtual object, or a music playback command triggered after selecting the first virtual object, etc., and this application does not specifically limit the scope.

[0079] Optionally, in step S141, the initial playback time can also be determined based on a pre-set initial playback time of the second music. For example, the time when the user triggers the dance operation (i.e., the initial playback time of the second music) can be determined as the initial playback time of the second music (the second music is the accompaniment corresponding to the dance), or the time when the user's score reaches a preset score (i.e., the initial playback time of the second music) can be determined as the initial playback time of the second music (the second music is the prompt music or celebration music for reaching the second score).

[0080] Step S142: Determine the second playback time of the second music in the virtual game based on the playback timing of the second music relative to the first music and the aforementioned initial playback time.

[0081] Specifically, the most recent first playback moment after the initial playback moment among all the first playback moments of the first music can be determined as the second playback moment of the second music. For example, when the initial playback moment is the trigger time of the music playback command, this step, upon receiving the music playback command triggered by the user, determines the beat point among all the beat points corresponding to the first music that is closest to the moment the user triggered the music playback command as the second playback moment. In this way, after the user triggers the music playback command, it can be played in time with the first music, providing timely feedback to the user's music playback command and enabling the second music to play in time with each other, improving the real-time performance and flow of music playback, resulting in a better user experience.

[0082] Step S143: Play the second music at the second playback moment mentioned above.

[0083] This implementation takes into account both the initial playback time of the second music and the timing of its playback in sync with the first music. This ensures that the playback of the second music not only meets the initial settings of the game scene but also improves the smoothness of the music by syncing with the first music, resulting in a better auditory experience and overall gaming experience for the user.

[0084] In another implementation, step S140 can also be implemented according to the following step S144.

[0085] Step S144: When the first music is detected to be playing at the first playback time, if the trigger state corresponding to the second music is the triggered state, then the second music is played at the first playback time.

[0086] Step S144 is that during the playback of the first music, if the first music is played to the time corresponding to the full beat point or the time corresponding to the fractional beat point, and the trigger state corresponding to the second music is the triggered state, then the second music is played at the first playback time.

[0087] Accordingly, the music playback method in the above game may also include the following steps S150 to S160.

[0088] Step S150: In response to receiving a trigger command for the second music, set the trigger state corresponding to the second music to the triggered state.

[0089] Step S160: In response to the completion of the second music playback, set the trigger state corresponding to the second music to the untriggered state.

[0090] The trigger command for the second music can be a trigger command for the first virtual object used to play the second music, such as a trigger command for a virtual drum, a trigger command for a virtual radio, etc., or a trigger command for a control displayed in the game interface to play the second music, or a trigger command for a shortcut key entered by the user to play the second music, etc. This application does not specifically limit it.

[0091] Taking the second music as a drum sound as an example, when a trigger command is received for the drum in the game scene, the trigger state corresponding to the second music can be set to the triggered state. At this time, if the first music is detected to have reached the first playback moment, a drum sound (i.e., the second music) can be played at the first playback moment. After the second music finishes playing, the trigger state of the second music is set to the untriggered state. If the user does not input a trigger command for the drum after the second music finishes playing, then when the first playback moment of the first music arrives again, the trigger state corresponding to the second music will be the untriggered state, and the second music will not be played at the first playback moment.

[0092] It is understandable that in step S144, when the second music is played at the first playback moment, it means that the second music is not yet playing at the first playback moment. That is, the second music has not yet been played at the current moment. When the second music is playing and has not finished playing, it will not be played at the first playback moment. This situation applies when the second music is a piece of music with a relatively long duration. For example, the playback of the second music will only be triggered again after the second music has finished playing.

[0093] This implementation uses each first playback moment during the first music playback process as the basis for triggering whether the second music plays. It can be understood as using each first playback moment during the first music playback process as a clock to trigger the playback of the second music, which improves the timeliness of music playback. For second music such as drum sounds, chimes, etc., which are virtual performances by the user, it can respond to the user's virtual performance more promptly, improve the interactivity with the user, and provide a better user experience.

[0094] In one specific embodiment, the triggering state corresponding to the second music in step S144 being a triggered state may include: the triggering state corresponding to the first virtual object being a triggered state. That is, when the first virtual object is in a triggered state, it indicates that the second music is in a triggered state.

[0095] The trigger command for the second music in step S150 may include a trigger command for the first virtual object. That is, when the trigger command for the first virtual object is triggered, it indicates that the trigger command for the second music has been triggered.

[0096] Setting the trigger state corresponding to the second music to the triggered state includes setting the trigger state corresponding to the first virtual object to the triggered state; setting the trigger state corresponding to the second music to the untriggered state includes setting the trigger state corresponding to the first virtual object to the untriggered state.

[0097] Specifically, the trigger state of the second music or the first virtual object can be set by setting the boolean value corresponding to the second music or the first virtual object. For example, when the boolean value corresponding to the second music or the first virtual object is False, the trigger state corresponding to the second music or the first virtual object is determined to be untriggered. When the boolean value corresponding to the second music or the first virtual object is True, the trigger state corresponding to the second music or the first virtual object is determined to be triggered.

[0098] In this embodiment, since the first virtual object is a virtual object used to emit the second music, the user's trigger command for the second music can be represented by the user's trigger command for the first virtual object, so that the user only needs to operate on the first virtual object, making the user operation simpler, more intuitive and convenient.

[0099] In step S140, the second music can be played according to the aforementioned playback timing and a preset music overlay playback method. The preset music overlay method indicates how the second music is overlaid with the first music. For example, during the playback of the second music, the playback state of the first music can remain unchanged, allowing the first and second music to play simultaneously. Alternatively, the playback state of the first and second music can be designed according to the actual scenario. For instance, the playback volume of the first music can be reduced during the playback of the second music, or the volume of the first music can be gradually reduced to 0 during the playback of the second music, or the playback of the first music can be stopped when the second music starts playing, or the second and first music can be overlaid using a preset sound effect overlay playback method, etc. Those skilled in the art can flexibly set the overlay playback state of the first and second music according to the actual situation of the game scenario; this application does not specifically limit this.

[0100] The music playback method in the game provided in this application plays a first piece of music in a virtual game, determines the beat interval of the first piece of music, and obtains a second piece of music to be played in the virtual game. Based on the principle that the second piece of music is played in time with the first piece of music, the timing of the second piece of music relative to the first piece of music is determined based on the beat interval of the first piece of music. The second piece of music is then played in the virtual game according to the determined timing. Since the determined timing is based on the principle that the second piece of music is played in time with the first piece of music, when the second piece of music is played according to the timing, the second piece of music can be played in time with the first piece of music that is being played. This makes the simultaneous playback or switching between the second piece of music and the first piece of music more fluid and improves the user's gaming experience.

[0101] In one embodiment, the virtual game scene may further include a virtual player character, which is controlled by a player or user to play the game. In step S140, the second music is played in the virtual game according to steps S145 to S147.

[0102] Step S145: Determine the position information of the first virtual object in the virtual game scene relative to the player's virtual character.

[0103] In a virtual game scene, each virtual object or virtual character has its own position within the scene. This position can be represented by coordinates or other positional methods. In this embodiment, the position information of the first virtual object relative to the player's virtual character can be determined based on the coordinates of the first virtual object and the player's virtual character. When determining the relative position information, the position difference (e.g., coordinate difference) between the first virtual object and the player's virtual character can be used as the position information of the first virtual object relative to the player's virtual character.

[0104] For example, the position information of the first virtual object relative to the player's virtual character can be (1, -2, 0), indicating that the first virtual object is located 1 meter to the right and 2 meters behind the player's virtual character; the position information of the first virtual object relative to the player's virtual character can be (-2, 1, 3), indicating that the first virtual object is located 2 meters to the left, 1 meter in front, and 3 meters above the player's virtual character.

[0105] Step S146: Determine the sounding position of the second music based on the above position information.

[0106] The position of the second piece of music also corresponds to the position information of the first virtual object relative to the player's virtual character.

[0107] Step S147: Play the second music in stereo in the virtual game according to the timing of the second music relative to the first music and the aforementioned sound position.

[0108] Among them, stereo can create a sense of spatial orientation of sound by simulating how the human ear receives sound, allowing the human ear to perceive the direction of sound. This enables users to determine the position of the first virtual object relative to themselves by listening to the second piece of music, making the user's sense of game participation and realism stronger and the user experience better.

[0109] In this embodiment, at least one stereo processing algorithm selected from Spatial Audio Coding, Head-Related Transfer Function (HRTF), Inter-Aural Time Difference (ITD), Inter-Aural Level Difference (ILD), and sound localization algorithms can be used to process the second music in stereo based on the aforementioned sound source location, and then play the stereo-processed second music so that the player or user can determine the sound source location from the played stereo second music. Those skilled in the art can configure how to play the second music in stereo according to actual conditions, which will not be detailed here.

[0110] In practice, taking the setting of game playback in a virtual game through Wwise as an example, the object parameter (Actor parameter) corresponding to the trigger node (PostEvent node) of the event that plays the second music can be set to the first virtual object, so that the electronic device can determine that the second music is the music emitted by the first virtual object.

[0111] Corresponding to the music playback method in the game provided in the first embodiment of this application, the second embodiment of this application also provides a music playback device in the game, such as... Figure 4 As shown, the music playback device for the game provided in this embodiment includes:

[0112] The first playback unit 410 is used to play the first music in the virtual game and determine the beat interval of the first music;

[0113] Acquisition unit 420 is used to acquire the second music to be played in the virtual game;

[0114] The determining unit 430 is used to determine the timing of the second music relative to the first music based on the beat interval, with the principle that the second music is played in time with the first music.

[0115] The second playback unit 440 is used to play the second music in the virtual game according to the playback timing.

[0116] Optionally, the determining unit is specifically used for:

[0117] The first playback time of the first music is determined according to the beat interval. The first playback time includes the time corresponding to the whole beat point of the first music and / or the time corresponding to the equally divided time interval point between adjacent whole beat points of the first music; the first playback time is determined as the playback timing of the second music relative to the first music.

[0118] Optionally, the determining unit is specifically used to: obtain a preset insertion time of the second music relative to the first music, wherein the preset insertion time is the beat playback time of the first music determined based on the beat interval; and determine the preset insertion time as the playback timing of the second music relative to the first music.

[0119] Optionally, the virtual game displays a virtual game scene through a graphical user interface. The virtual game scene includes a first virtual object, which is used to emit corresponding music, and the second music is the music emitted by the first virtual object.

[0120] Optionally, the second playback unit is specifically configured to: determine the initial playback time of the second music in the virtual game; determine the second playback time of the second music in the virtual game based on the playback timing and the initial playback time; and play the second music at the second playback time.

[0121] Optionally, the second playback unit is specifically configured to: in response to a music playback command for the first virtual object, determine the trigger time of the music playback command as the initial playback time of the second music in the virtual game; and determine the most recent first playback time after the initial playback time among all the first playback times of the first music as the second playback time of the second music.

[0122] Optionally, the second playback unit is specifically used to: when the first music is detected to have played to the first playback time, if the trigger state corresponding to the second music is a triggered state, then play the second music at the first playback time.

[0123] The device further includes:

[0124] The state setting unit is used to set the trigger state corresponding to the second music to a triggered state in response to receiving a trigger command for the second music; and to set the trigger state corresponding to the second music to an untriggered state in response to the completion of playback of the second music.

[0125] Optionally, the trigger state corresponding to the second music is the triggered state, which includes: the trigger state corresponding to the first virtual object is the triggered state;

[0126] The trigger command for the second music includes: a trigger command for the first virtual object;

[0127] Setting the trigger state corresponding to the second music to the triggered state includes: setting the trigger state corresponding to the first virtual object to the triggered state;

[0128] Setting the trigger state corresponding to the second music to an untriggered state includes setting the trigger state corresponding to the first virtual object to an untriggered state.

[0129] Optionally, the virtual game scene may also include a player's virtual character;

[0130] The second playback unit is specifically used to: determine the position information of the first virtual object in the virtual game scene relative to the player's virtual character; determine the sound location of the second music based on the position information; and play the second music in stereo in the virtual game according to the playback timing and the sound location.

[0131] Optionally, the first playback unit is specifically used to: obtain the tempo information corresponding to the first music, the tempo information being used to indicate the number of beats of the first music per unit time; and determine the beat interval of the first music based on the tempo information.

[0132] Optionally, the first music is non-narrative music in the virtual game, and the second music is narrative music in the virtual game.

[0133] Corresponding to the music playback method in the game provided in the first embodiment of this application, the third embodiment of this application also provides an electronic device. For example... Figure 5 As shown, the electronic device includes: a processor 501; and a memory 502 for storing a program for playing music in a game. After the electronic device is powered on and the processor runs the program for playing music in the game, it performs the following steps:

[0134] Play the first piece of music in the virtual game and determine the beat interval of the first piece of music;

[0135] Obtain the second piece of music to be played in the virtual game;

[0136] Based on the principle of playing the second music in time with respect to the first music, the timing of playing the second music relative to the first music is determined according to the beat interval.

[0137] The second music is played in the virtual game according to the specified playback timing.

[0138] Corresponding to the music playback method in the game provided in the first embodiment of this application, the fourth embodiment of this application provides a computer-readable storage medium storing a program for a music playback method in a game. This program is executed by a processor to perform the following steps:

[0139] Play the first piece of music in the virtual game and determine the beat interval of the first piece of music;

[0140] Obtain the second piece of music to be played in the virtual game;

[0141] Based on the principle of playing the second music in time with respect to the first music, the timing of playing the second music relative to the first music is determined according to the beat interval.

[0142] The second music is played in the virtual game according to the specified playback timing.

[0143] It should be noted that for a detailed description of the apparatus, electronic device and computer-readable storage medium provided in the embodiments of this application, please refer to the relevant description of the method in the first embodiment of this application, which will not be repeated here.

[0144] Although this application discloses preferred embodiments as described above, it is not intended to limit this application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this application. Therefore, the scope of protection of this application should be determined by the scope defined in the claims of this application.

[0145] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0146] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0147] 1. Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage media, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include non-transitory computer-readable media, such as modulated data signals and carrier waves.

[0148] 2. Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0149] Although this application discloses preferred embodiments as described above, it is not intended to limit this application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this application. Therefore, the scope of protection of this application should be determined by the scope defined in the claims of this application.

Claims

1. A method for playing music in a game, characterized in that, The method includes: Play the first piece of music in the virtual game and determine the beat interval of the first piece of music; Obtain the second piece of music to be played in the virtual game; Based on the principle of playing the second music in time with respect to the first music, the timing of playing the second music relative to the first music is determined according to the beat interval. The second music is played in the virtual game according to the specified playback timing; In response to a music playback command for the first virtual object, the trigger time is determined as the initial playback time, and the most recent playback time after the initial playback time of the first music is determined as the second playback time; when the first music is detected to have played to the playback time, if the trigger state corresponding to the second music is the triggered state, then the second music is played. The triggered state is set in response to the trigger command, and the state is reset after playback is complete.

2. The method according to claim 1, characterized in that, The principle of playing the second music in time with respect to the first music, and determining the timing of playing the second music relative to the first music based on the beat interval, includes: The first playback time of the first music is determined according to the beat interval. The first playback time includes the time corresponding to the whole beat point of the first music and / or the time corresponding to the equally divided time interval point between adjacent whole beat points of the first music. The first playback time is determined as the playback timing of the second music relative to the first music.

3. The method according to claim 1, characterized in that, The principle of playing the second music in time with respect to the first music, and determining the timing of playing the second music relative to the first music based on the beat interval, includes: Obtain a preset insertion time of the second music relative to the first music, wherein the preset insertion time is the beat playback time of the first music determined based on the beat interval; The preset insertion time is determined as the playback timing of the second music relative to the first music.

4. The method according to claim 2, characterized in that, The virtual game displays a virtual game scene through a graphical user interface. The virtual game scene includes a first virtual object, which is used to emit corresponding music. The second music is the music emitted by the first virtual object.

5. The method according to claim 4, characterized in that, The method further includes: In response to receiving a trigger command for the second music, the trigger state corresponding to the second music is set to the triggered state; In response to the completion of the second music playback, the trigger state corresponding to the second music is set to the untriggered state.

6. The method according to claim 5, characterized in that, The triggering state corresponding to the second music is the triggered state, which includes: the triggering state corresponding to the first virtual object is the triggered state; The trigger command for the second music includes: a trigger command for the first virtual object; Setting the trigger state corresponding to the second music to the triggered state includes: setting the trigger state corresponding to the first virtual object to the triggered state; Setting the trigger state corresponding to the second music to an untriggered state includes setting the trigger state corresponding to the first virtual object to an untriggered state.

7. The method according to any one of claims 4 to 6, characterized in that, The virtual game scene also includes player virtual characters; Playing the second music in the virtual game according to the playback timing includes: Determine the position information of the first virtual object relative to the player's virtual character in the virtual game scene; The location of the second music is determined based on the location information; The second music is played in stereo in the virtual game according to the playback timing and the sound source location.

8. The method according to any one of claims 1 to 6, characterized in that, Determining the beat interval of the first music includes: Obtain the tempo information corresponding to the first music, wherein the tempo information is used to indicate the number of beats of the first music per unit time; The beat interval of the first music is determined based on the speed information.

9. The method according to any one of claims 1 to 6, characterized in that, The first piece of music is non-narrative music in the virtual game, and the second piece of music is narrative music in the virtual game.

10. A music playback device for games, characterized in that, The device includes: The first playback unit is used to play the first music in the virtual game and determine the beat interval of the first music; The acquisition unit is used to acquire the second piece of music to be played in the virtual game; The determining unit is used to determine the timing of the second music relative to the first music based on the beat interval, with the principle that the second music is played in time with respect to the first music. The second playback unit is used to play the second music in the virtual game according to the playback timing. The second playback unit is also configured to respond to a music playback command on the first virtual object by determining the trigger time as the initial playback time and determining the most recent playback time after the initial playback time among the playback times of the first music as the second playback time; when the first music is detected to have played to the playback time, if the trigger state corresponding to the second music is the triggered state, then the second music is played. The status setting unit is used to set the triggered state in response to the trigger command and reset the state after playback is completed.

11. An electronic device, characterized in that, include: processor; as well as A memory for storing a data processing program, which, when the electronic device is powered on and runs through the processor, executes the method as described in any one of claims 1-9.

12. A computer-readable storage medium, characterized in that, The system contains a data processing program that is executed by a processor to perform the method as described in any one of claims 1-9.