import Song.SwagSong; class SmallNote // basically Note.hx but small as fuck { public var strumTime:Float; public var noteData:Int; public function new(strum,data) { strumTime = strum; noteData = data; } } class DiffCalc { public static function CalculateDiff(song:SwagSong) { // cleaned notes var cleanedNotes:Array = []; // find all of the notes for(i in song.notes) // sections { for (ii in i.sectionNotes) // notes { var gottaHit = true; if (ii[2] >= 1) // skip helds continue; if (ii[1] > 3) // if the note data is greater than 3 gottaHit = !i.mustHitSection; if (gottaHit) cleanedNotes.push(new SmallNote(ii[0],ii[1])); } } cleanedNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime)); var firstNoteTime = cleanedNotes[0].strumTime; trace(firstNoteTime); // normalize the notes for(i in cleanedNotes) { i.strumTime = (i.strumTime - firstNoteTime) * 2; } // length in segments of the song var length = ((cleanedNotes[cleanedNotes.length - 1].strumTime / 1000) / 0.5); trace(length); // hackey way of creating a array with a length var segments:Array = new_Array(1,Std.int(length)); // algo loop for(i in cleanedNotes) { var index = Std.int(i.strumTime / 1000); if (index + 1 > segments.length) continue; segments[index] = segments[index] + 1; } // get the average of all of the segments var sum:Float = 0; var newLength = segments.length; for (i in segments) { if (i == 0) // remove empty/breaks { newLength--; continue; } sum += i / .5; // half it because otherwise instead of nps its just fucking notes per half second which is dumb and stupid } trace(sum + " - " + newLength); return HelperFunctions.truncateFloat(sum / newLength,2); } static public function new_Array( ArrayType:T, Length:Int ):Array { var empty:Null = null; var newArray:Array = new Array(); for ( i in 0...Length ) { newArray.push( empty ); } return newArray; } }