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]

Can you use the Wii Classic Control for the Wii version of Destroy All Humans? Can you use the Wii Classic Control for the Wii version of Destroy All Humans?

Posted On: March 23, 2023
I find the controller layout of Destroy All Humans for the Wii to be too annoying to play for long, using the IR sensor to control the camera is just a pain. I really liked using dual analog sticks...[More]


How many aspects can you hold in your inventory in Diablo 4? How many aspects can you hold in your inventory in Diablo 4?

Posted On: June 14, 2023
How many aspects can you hold in your inventory in Diablo 4? Is there a max? I can't find anything on the internet about this. Question from user Merl at stackexchange. Answer: Aspect ...[More]


What is the difference between these values on Steam? What is the difference between these values on Steam?

Posted On: January 20, 2023
Downloading Warhammer: Vermintide II, I noticed how the percentages as displayed in 3 different places have 3 different values:. Download bar on the Downloads tab of the Steam client, (click for or...[More]


how do i make a stick the runs - Tick freeze how do i make a stick the runs - Tick freeze

Posted On: March 8, 2024
I want to create a Za Warudo stick but I have searched on the internet for answers and found none.Can someone help?Question from user andreas senneset-søtorp at gaming.stackexchange.com.Answer:It is ...[More]


Do I sell my legendary Kraken cloak in favour of a superb one? Do I sell my legendary Kraken cloak in favour of a superb one?

Posted On: September 24, 2023
My legendary Kraken cloak provides me with 14 defence while my Superb cloak provides me with 18 defence. Should I sell my legendary gear? I’m pretty new to this game, so don’t really know ...[More]


Does leaving the car on use up fuel? Does leaving the car on use up fuel?

Posted On: March 3, 2024
In Pacific Drive, when I put the car in park I can exit the car without turning off the engine. Does leaving the engine turned on use up fuel if the car isn't moving?Question from user Stevoisiak at g...[More]


Who's your favorite NPC with very few lines in the game? Who's your favorite NPC with very few lines in the game?

Posted On: October 10, 2025
Lots to chose from and lots of weirdly memorable ones at that.Question from user ArachaIdliMaavu at BaldursGate3 at reddit.com.Answer:I got a giggle talking to his majesty at Last Light Inn.Answer fro...[More]


What was your first and favorite party compositions? What was your first and favorite party compositions?

Posted On: October 17, 2023
Through life being so busy, I haven't quite beaten the game yet. But I have still put over 150 hours into this game with my main and favorite party being the only group in Act 3 right now with a f...[More]


How do I get SCUBA gear in GTA 5? How do I get SCUBA gear in GTA 5?

Posted On: April 25, 2023
I am looking for a way to equip Scuba gear outside of a mission. I know that you are automatically equipped with scuba gear when you exit the Submersible while in water. Can anyone other than th...[More]


What is CP in PokemonGo? What is CP in PokemonGo?

Posted On: April 24, 2023
Pokémon have a statistic called CP. What does it do, and why is it relevant? Is it a substitute for the nonexistent levels and statistics, or is it something completely different? Questio...[More]