Any way to crossfade music?

[BACK]
Any way to crossfade music?
Posted On: April 2, 2024

I would like to be able to create a music crossfade in an adventure map that I'm creating. The idea is to overlap two versions of the same song, one the "chill" version, another the "fight" version, and when a player gets in a fight with enemies, crossfade over to the fight version, as well as being able to nicely fade out music in general.


My original idea was to have 2 invisible armor stands act as the source for each of the tracks, then move the armor stands away/towards the player, slowly fading in/out each track. This actually works pretty well, but when the crossfade is over, I make the armor stand emitting the now faded-in song ride the player, so it just sticks with them. This also works, and when the player is running straight ahead, it sounds correct, but when the player strafes, it does like a sawtooth effect on the panning, and is REALLY distracting sounding. Any other ideas for a way to make this kind of thing work?


I've also tried messing with setting the attenuation_distance very high in the resource pack, but that doesn't change anything, though I suspect that it's because it only affects certain entity types anyways.


I am writing a server plugin, so I can do anything available in bukkit/paper, and am even perfectly fine doing things with ProtocolLib or other version specific hacks, but I am not expecting players to have to download a client side mod for this map.


Question from user LadyCailin at gaming.stackexchange.com.


Answer:

So, I ended up with a situation that works good enough for my purposes, but still has some drawbacks. Essentially, I place 4 entities (item displays) at the cardinal directions of the player, 10 blocks out, 5 blocks above, and start the music with each of the 4 in the same tick. This seems to reliably sync up the music. Then, every so often (4 times a second) I move the entities into the correct location again, so they are again 10 blocks out, 5 blocks up. This has a strange effect when the player spins around quickly, but actually, that strange effect happens with the rain and other sounds too, so I can live with that.


For the crossfade, this is simple, and just does the same as , I have the other set of 4 entities far enough away from the player that they can't hear them, but then move the first song's "speakers" down, while moving the fade in song's speakers up. This has a very nice fade effect, and while it is a bit jumpy, I could fix that with a higher frame rate.


Speaking of frame rates, because my "adjust position" logic only runs every .20 seconds, this method is pretty bad with flight and falling from high distances. However, you can turn the volume up, and this works well enough, since this decreases the amount of attenuation per unit moved. However, this means that the distance of the "fade out" state needs to be higher before it drops to 0. If you set that too high, this introduces a new problem with the "stowed away" speakers, which is that if the player gets too far away, they stop playing music, presumably because the client unloads them, and so also forgets that they were playing music. Thus, I have settled on just living with the fact that if a player moves fast enough, this system gets a bit janky. I may continue to improve on this later.


All in all though, this works surprisingly well, though I am excited to see how it performs with load testing.


Answer from user LadyCailin at gaming.stackexchange.com.


[BACK]
Any way to crossfade music?
Posted On: April 2, 2024

I would like to be able to create a music crossfade in an adventure map that I'm creating. The idea is to overlap two versions of the same song, one the "chill" version, another the "fight" version, and when a player gets in a fight with enemies, crossfade over to the fight version, as well as being able to nicely fade out music in general.


My original idea was to have 2 invisible armor stands act as the source for each of the tracks, then move the armor stands away/towards the player, slowly fading in/out each track. This actually works pretty well, but when the crossfade is over, I make the armor stand emitting the now faded-in song ride the player, so it just sticks with them. This also works, and when the player is running straight ahead, it sounds correct, but when the player strafes, it does like a sawtooth effect on the panning, and is REALLY distracting sounding. Any other ideas for a way to make this kind of thing work?


I've also tried messing with setting the attenuation_distance very high in the resource pack, but that doesn't change anything, though I suspect that it's because it only affects certain entity types anyways.


I am writing a server plugin, so I can do anything available in bukkit/paper, and am even perfectly fine doing things with ProtocolLib or other version specific hacks, but I am not expecting players to have to download a client side mod for this map.


Question from user LadyCailin at gaming.stackexchange.com.


Answer:

So, I ended up with a situation that works good enough for my purposes, but still has some drawbacks. Essentially, I place 4 entities (item displays) at the cardinal directions of the player, 10 blocks out, 5 blocks above, and start the music with each of the 4 in the same tick. This seems to reliably sync up the music. Then, every so often (4 times a second) I move the entities into the correct location again, so they are again 10 blocks out, 5 blocks up. This has a strange effect when the player spins around quickly, but actually, that strange effect happens with the rain and other sounds too, so I can live with that.


For the crossfade, this is simple, and just does the same as , I have the other set of 4 entities far enough away from the player that they can't hear them, but then move the first song's "speakers" down, while moving the fade in song's speakers up. This has a very nice fade effect, and while it is a bit jumpy, I could fix that with a higher frame rate.


Speaking of frame rates, because my "adjust position" logic only runs every .20 seconds, this method is pretty bad with flight and falling from high distances. However, you can turn the volume up, and this works well enough, since this decreases the amount of attenuation per unit moved. However, this means that the distance of the "fade out" state needs to be higher before it drops to 0. If you set that too high, this introduces a new problem with the "stowed away" speakers, which is that if the player gets too far away, they stop playing music, presumably because the client unloads them, and so also forgets that they were playing music. Thus, I have settled on just living with the fact that if a player moves fast enough, this system gets a bit janky. I may continue to improve on this later.


All in all though, this works surprisingly well, though I am excited to see how it performs with load testing.


Answer from user LadyCailin at gaming.stackexchange.com.


[BACK]

How the Hit Point color bar is calculated? How the Hit Point color bar is calculated?

Posted On: January 31, 2023
I have Silver and Gold (the 2nd gen) in mind, but I guess the logic is the same for the whole serie. I would like to know how the Hit Point color bar is calculated. I guess it would be something li...[More]


How do I use Triple Notch without triggering High Volley in Horizon Forbidden West How do I use Triple Notch without triggering High Volley in Horizon Forbidden West

Posted On: April 21, 2023
I have two skills from the Hunter tree: Triple Notch and High Volley. The weird thing is that as far as I can tell both are triggered by the same buttons, holding L2 and pressing R1. Sometimes when...[More]


What is the stat Fumble? What is the stat Fumble?

Posted On: January 24, 2023
I couldn't get a very clear explanation over the internet. Within the Dexterity stat figures "Fumble Recovery". What does it mean if the attack is "fumbled"? Question fro...[More]


Astarion hates me? Astarion hates me?

Posted On: September 28, 2023
Help, Astarion dislikes everything i do and every decision i make. Do i need to be a bad person in order him to like me? I love helping people and speaking to animals (i'm a druid) but he seems to...[More]


What happens to the essence in Ninja Gaiden Sigma 2? What happens to the essence in Ninja Gaiden Sigma 2?

Posted On: July 1, 2023
In Ninja Gaiden Sigma 2 (PS3), when you use the ultimate technique and absorb the surrounding essence, does it heal/give ki/money or is it just consumed towards the speed charging of UT? Question f...[More]


What are the optimal strategies for buying and selling matches? What are the optimal strategies for buying and selling matches?

Posted On: January 16, 2023
In Luce's Journey, a trading survival game set in the Victorian era, you play as a young child who must trade matches in order to survive. The player character earns money by trading matches, a...[More]


What games are similar to Hogwarts Legacy? What games are similar to Hogwarts Legacy?

Posted On: April 10, 2023
Looking for suggestions of what to play after I’m done with this game. Are there any games similar that would have you following a story while doing quests or battles? Question from user Harm...[More]


How do you perform a takedown in Payday 3? How do you perform a takedown in Payday 3?

Posted On: September 10, 2023
The skill "CQC Specialist" mentions performing takedowns to gain rush, and the remainder of that line is also mostly about takedowns. How do you perform a takedown to activate these skills? ...[More]


Dungeons and Dragons Online, Good for Groups? Dungeons and Dragons Online, Good for Groups?

Posted On: June 11, 2023
I see that Dungeons and Dragons Online is now free to play. How is that game structured?. Do you create parties and travel?. Or is it more free world-ish?. I ask because I am looking for g...[More]


Does a bag carried out to the escape count as a secured bag? Does a bag carried out to the escape count as a secured bag?

Posted On: September 21, 2023
If I carry a bag out to the escape, rather than securing it in a helicopter or what have you (depending on the heist), does that bag count as a bag stolen at the end? Or do I need to throw the loot in...[More]