
**Async and, client tps and lag independent playback** Playback should work in any conditions. No matter how fast/slow or laggy or inconsistent the client is. The client itself may not hear it in the correct timing, but other players will. The way song ticks are progressed was overhauled and simplified as well. This enables changing the speed of the song or seeking it. **Overhauled tuning** Tuning got overhauled and is now much quicker. It also will try to tune the least amount possible, which makes tuning when changing songs a lot quicker. It assumes changes going through and should work on any ping. Though initial wrong ping information combined with very bad or fluctuating ping can cause the tuning to overshoot and never finish (should be very unlikely and resolve itself after some time). **Added a few variables to control playback better** Variables like didSongReachEnd, missingInstrumentBlocks and some others are used to have more fine grained control from other mods (for implementing a playback queue or getting more info about tuning issues). I'd like them preserved but can understand if they do not make much sense. speed is also not changed in the mod self right now, but i think there could be some UI element added to have fun with it. Same for instrumentMap. **Tick listener is always enabled** I stumbled upon some crashes when it was removing / adding it, so I made the tick listener permanent. It should not have any significant performance implications anyway. **Added packet rate limit** When playing back, the own packets are being kept track of. If they get very high, the client will stop sending "cosmetic" packets and if they get close to the packet rate limit of servers, it'll interrupt playback for brief periods to prevent getting packet kicked. This was added to not get kicked for playing "Rush E" or setting very high "speed"s. **Reduce amount of swining** Does not swing arm for every note played but roughly every serverside tick. This reduces wasted packets no one is going to see anyway. **Use server side distance check** Use the same check the server uses to determine if a noteblock can be reached or not. Increases range to the max allowed. **Other changes** I probably forgot some other changes here as well. Many were added a while back and there were probably numerous other fixes for stability’s sake. So excuse me for not recounting every single one.
44 lines
1.5 KiB
Java
44 lines
1.5 KiB
Java
package semmiedev.disc_jockey;
|
|
|
|
import semmiedev.disc_jockey.gui.SongListWidget;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
public class Song {
|
|
public final ArrayList<Note> uniqueNotes = new ArrayList<>();
|
|
|
|
public long[] notes = new long[0];
|
|
|
|
public short length, height, tempo, loopStartTick;
|
|
public String fileName, name, author, originalAuthor, description, displayName;
|
|
public byte autoSaving, autoSavingDuration, timeSignature, vanillaInstrumentCount, formatVersion, loop, maxLoopCount;
|
|
public int minutesSpent, leftClicks, rightClicks, blocksAdded, blocksRemoved;
|
|
public String importFileName;
|
|
|
|
public SongListWidget.SongEntry entry;
|
|
public String searchableFileName, searchableName;
|
|
|
|
@Override
|
|
public String toString() {
|
|
return displayName;
|
|
}
|
|
|
|
public double millisecondsToTicks(long milliseconds) {
|
|
// From NBS Format: The tempo of the song multiplied by 100 (for example, 1225 instead of 12.25). Measured in ticks per second.
|
|
double songSpeed = (tempo / 100.0) / 20.0; // 20 Ticks per second (temp / 100 = 20) would be 1x speed
|
|
double oneMsTo20TickFraction = 1.0 / 50.0;
|
|
return milliseconds * oneMsTo20TickFraction * songSpeed;
|
|
}
|
|
|
|
public double ticksToMilliseconds(double ticks) {
|
|
double songSpeed = (tempo / 100.0) / 20.0;
|
|
double oneMsTo20TickFraction = 1.0 / 50.0;
|
|
return ticks / oneMsTo20TickFraction / songSpeed;
|
|
}
|
|
|
|
public double getLengthInSeconds() {
|
|
return ticksToMilliseconds(length) / 1000.0;
|
|
}
|
|
|
|
}
|