Merge branch 'rewrite/master' of https://github.com/FunkinCrew/Funkin-secret into feature/focusCameraTweening

This commit is contained in:
Jenny Crowe 2024-03-03 02:51:01 -07:00
commit abb4400e41
17 changed files with 207 additions and 143 deletions

View file

@ -3,21 +3,46 @@ description: "sets up haxe shit, using HMM!"
runs: runs:
using: "composite" using: "composite"
steps: steps:
- uses: funkincrew/ci-haxe@v3 - name: Install Haxe lol
uses: funkincrew/ci-haxe@v3.1.0
with: with:
haxe-version: 4.3.3 haxe-version: 4.3.3
- name: Config haxelib - name: Config haxelib
run: | run: |
haxelib config haxelib --never install haxelib 4.1.0 --global
haxelib --never deleterepo || true
haxelib --never newrepo
echo "HAXEPATH=$(haxelib config)" >> "$GITHUB_ENV"
haxelib --never git haxelib https://github.com/HaxeFoundation/haxelib.git master
shell: bash shell: bash
- name: Installing Haxe lol - name: Gather debug info
run: |
cat << EOF >> "$GITHUB_STEP_SUMMARY"
## haxe
- version: \`$(haxe -version)\`
- exe: \`$(which haxe)\`
## haxelib
- version: \`$(haxelib version)\`
- exe: \`$(which haxelib)\`
- path: \`$HAXEPATH\`
### local
- config: \`$(haxelib config)\`
- path: \`$(haxelib path haxelib || true)\`
### global
- config: \`$(haxelib config --global)\`
- path: \`$(haxelib path haxelib --global || true)\`
### system
- version: \`$(haxelib --system version)\`
- local: \`$(haxelib --system config)\`
- global: \`$(haxelib --system config --global)\`
EOF
shell: bash
- name: Install hmm
# hmm only supports global installs
run: | run: |
haxe -version
haxelib git haxelib https://github.com/HaxeFoundation/haxelib.git master
haxelib version
haxelib --global install hmm haxelib --global install hmm
shell: bash shell: bash
- name: dependency install cache - name: Restore cached dependencies
id: cache-hmm id: cache-hmm
uses: actions/cache@v4 uses: actions/cache@v4
with: with:

View file

@ -8,71 +8,80 @@ jobs:
runs-on: [self-hosted, linux] runs-on: [self-hosted, linux]
container: ubuntu:23.10 container: ubuntu:23.10
steps: steps:
- name: prepare container - name: Install tools missing in container
run: | run: |
apt update apt update
apt install sudo git curl unzip -y apt install -y sudo git curl unzip
git config --global --add safe.directory $GITHUB_WORKSPACE - name: Fix git config on posix runner
- name: get token from gh app run: |
git config --global --add safe.directory ${{ github.workspace }}
- name: Get checkout token
uses: actions/create-github-app-token@v1 uses: actions/create-github-app-token@v1
id: app_token id: app_token
with: with:
app-id: ${{ vars.APP_ID }} app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PEM }} private-key: ${{ secrets.APP_PEM }}
owner: ${{ github.repository_owner }} owner: ${{ github.repository_owner }}
- name: checkout repo - name: Checkout repo
uses: funkincrew/ci-checkout@v6 uses: funkincrew/ci-checkout@v6
with: with:
submodules: 'recursive' submodules: 'recursive'
token: ${{ steps.app_token.outputs.token }} token: ${{ steps.app_token.outputs.token }}
- uses: ./.github/actions/setup-haxeshit - name: Install Haxe, dependencies
- name: gather game dependencies uses: ./.github/actions/setup-haxeshit
- name: Install native dependencies
run: | run: |
sudo apt-get install -y libx11-dev xorg-dev libgl-dev libxi-dev libxext-dev libasound2-dev libxinerama-dev libxrandr-dev libgl1-mesa-dev apt install -y \
- name: build game libx11-dev libxi-dev libxext-dev libxinerama-dev libxrandr-dev \
libgl-dev libgl1-mesa-dev \
libasound2-dev
- name: Build game
run: | run: |
haxelib run lime build html5 -release --times -DGITHUB_BUILD haxelib run lime build html5 -release --times -DGITHUB_BUILD
ls - name: Upload build artifacts
- uses: ./.github/actions/upload-itch uses: ./.github/actions/upload-itch
with: with:
butler-key: ${{ secrets.BUTLER_API_KEY}} butler-key: ${{ secrets.BUTLER_API_KEY}}
build-dir: export/release/html5/bin build-dir: export/release/html5/bin
target: html5 target: html5
create-nightly-win: create-nightly-win:
runs-on: [self-hosted, windows] runs-on: [self-hosted, windows]
defaults:
run:
shell: bash
steps: steps:
- name: get token from gh app - name: Get checkout token
uses: actions/create-github-app-token@v1 uses: actions/create-github-app-token@v1
id: app_token id: app_token
with: with:
app-id: ${{ vars.APP_ID }} app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PEM }} private-key: ${{ secrets.APP_PEM }}
owner: ${{ github.repository_owner }} owner: ${{ github.repository_owner }}
- name: checkout repo - name: Checkout repo
uses: funkincrew/ci-checkout@v6 uses: funkincrew/ci-checkout@v6
with: with:
submodules: 'recursive' submodules: 'recursive'
token: ${{ steps.app_token.outputs.token }} token: ${{ steps.app_token.outputs.token }}
- uses: ./.github/actions/setup-haxeshit - name: Install Haxe, dependencies
- name: Make HXCPP cache dir uses: ./.github/actions/setup-haxeshit
- name: Setup build cache
run: | run: |
mkdir -p ${{ runner.temp }}\hxcpp_cache mkdir -p ${{ runner.temp }}/hxcpp_cache
- name: Restore build cache - name: Restore build cache
id: cache-build-win id: cache-build-win
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: | path: |
.haxelib
export export
${{ runner.temp }}\hxcpp_cache ${{ runner.temp }}/hxcpp_cache
key: ${{ runner.os }}-build-win-${{ github.ref_name }}-${{ hashFiles('**/hmm.json') }} key: ${{ runner.os }}-build-win-${{ github.ref_name }}
- name: build game - name: Build game
run: | run: |
haxelib run lime build windows -release -DNO_REDIRECT_ASSETS_FOLDER -DGITHUB_BUILD haxelib run lime build windows -v -release -DNO_REDIRECT_ASSETS_FOLDER -DGITHUB_BUILD
dir
env: env:
HXCPP_COMPILE_CACHE: "${{ runner.temp }}\\hxcpp_cache" HXCPP_COMPILE_CACHE: "${{ runner.temp }}\\hxcpp_cache"
- uses: ./.github/actions/upload-itch - name: Upload build artifacts
uses: ./.github/actions/upload-itch
with: with:
butler-key: ${{ secrets.BUTLER_API_KEY }} butler-key: ${{ secrets.BUTLER_API_KEY }}
build-dir: export/release/windows/bin build-dir: export/release/windows/bin
@ -80,78 +89,42 @@ jobs:
create-nightly-mac: create-nightly-mac:
runs-on: [self-hosted, macos] runs-on: [self-hosted, macos]
steps: steps:
- name: prepare container - name: Fix git config on posix runner
run: | run: |
git config --global --add safe.directory $GITHUB_WORKSPACE git config --global --add safe.directory ${{ github.workspace }}
- name: get token from gh app - name: Get checkout token
uses: actions/create-github-app-token@v1 uses: actions/create-github-app-token@v1
id: app_token id: app_token
with: with:
app-id: ${{ vars.APP_ID }} app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PEM }} private-key: ${{ secrets.APP_PEM }}
owner: ${{ github.repository_owner }} owner: ${{ github.repository_owner }}
- name: checkout repo - name: Checkout repo
uses: funkincrew/ci-checkout@v6 uses: funkincrew/ci-checkout@v6
with: with:
submodules: 'recursive' submodules: 'recursive'
token: ${{ steps.app_token.outputs.token }} token: ${{ steps.app_token.outputs.token }}
- uses: ./.github/actions/setup-haxeshit - name: Install Haxe, dependencies
- name: Make HXCPP cache dir uses: ./.github/actions/setup-haxeshit
- name: Setup build cache
run: | run: |
mkdir -p ${{ runner.temp }}/hxcpp_cache mkdir -p ${{ runner.temp }}/hxcpp_cache
- name: restore build cache - name: Restore build cache
id: cache-build-win id: cache-build-win
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: | path: |
.haxelib
export export
${{ runner.temp }}/hxcpp_cache ${{ runner.temp }}/hxcpp_cache
key: ${{ runner.os }}-build-mac-${{ github.ref_name }}-${{ hashFiles('**/hmm.json') }} key: ${{ runner.os }}-build-mac-${{ github.ref_name }}
- name: Build game - name: Build game
run: | run: |
haxelib run lime build macos -release --times -DGITHUB_BUILD haxelib run lime build macos -release --times -DGITHUB_BUILD
ls
env: env:
HXCPP_COMPILE_CACHE: "${{ runner.temp }}/hxcpp_cache" HXCPP_COMPILE_CACHE: "${{ runner.temp }}/hxcpp_cache"
- uses: ./.github/actions/upload-itch - name: Upload build artifacts
uses: ./.github/actions/upload-itch
with: with:
butler-key: ${{ secrets.BUTLER_API_KEY}} butler-key: ${{ secrets.BUTLER_API_KEY}}
build-dir: export/release/macos/bin build-dir: export/release/macos/bin
target: macos target: macos
# test-unit-win:
# needs: create-nightly-win
# runs-on: windows-latest
# steps:
# - name: get token from gh app
# uses: actions/create-github-app-token@v1
# id: app_token
# with:
# app-id: ${{ vars.APP_ID }}
# private-key: ${{ secrets.APP_PEM }}
# owner: ${{ github.repository_owner }}
# - name: checkout repo
# uses: funkincrew/ci-checkout@v6
# with:
# submodules: 'recursive'
# token: ${{ steps.app_token.outputs.token }}
# - name: Make HXCPP cache dir
# run: |
# mkdir -p ${{ runner.temp }}\hxcpp_cache
# - name: Restore build cache
# id: cache-build-win
# uses: actions/cache@v4
# with:
# path: |
# .haxelib
# export
# ${{ runner.temp }}\hxcpp_cache
# key: ${{ runner.os }}-test-win-${{ github.ref_name }}-${{ hashFiles('**/hmm.json') }}
# - uses: ./.github/actions/setup-haxeshit
# - name: Run unit tests
# run: |
# cd ./tests/unit/
# ./start-win-native.bat
# env:
# HXCPP_COMPILE_CACHE: "${{ runner.temp }}\\hxcpp_cache"

1
.gitignore vendored
View file

@ -6,3 +6,4 @@ dump/
export/ export/
RECOVER_*.fla RECOVER_*.fla
shitAudio/ shitAudio/
.build_time

2
assets

@ -1 +1 @@
Subproject commit 8b914574fc4724c5fe483f4f9d81081bb1518c12 Subproject commit b152ad83868ff77307abb24893ddd5f74ed324d7

View file

@ -1,11 +1,37 @@
package source; // Yeah, I know... package source; // Yeah, I know...
import sys.FileSystem;
import sys.io.File;
class Postbuild class Postbuild
{ {
static inline final buildTimeFile = '.build_time';
static function main() static function main()
{ {
trace('Postbuild'); printBuildTime();
}
// TODO: Maybe put a 'Build took X seconds' message here? static function printBuildTime()
{
// get buildEnd before fs operations since they are blocking
var end:Float = Sys.time();
if (FileSystem.exists(buildTimeFile))
{
var fi = File.read(buildTimeFile);
var start:Float = fi.readDouble();
fi.close();
sys.FileSystem.deleteFile(buildTimeFile);
var buildTime = roundToTwoDecimals(end - start);
trace('Build took: ${buildTime} seconds');
}
}
private static function roundToTwoDecimals(value:Float):Float
{
return Math.round(value * 100) / 100;
} }
} }

View file

@ -1,9 +1,22 @@
package source; // Yeah, I know... package source; // Yeah, I know...
import sys.io.File;
class Prebuild class Prebuild
{ {
static inline final buildTimeFile = '.build_time';
static function main() static function main()
{ {
trace('Prebuild'); saveBuildTime();
trace('Building...');
}
static function saveBuildTime()
{
var fo = File.write(buildTimeFile);
var now = Sys.time();
fo.writeDouble(now);
fo.close();
} }
} }

View file

@ -30,6 +30,7 @@ import funkin.modding.module.ModuleHandler;
import funkin.ui.title.TitleState; import funkin.ui.title.TitleState;
import funkin.util.CLIUtil; import funkin.util.CLIUtil;
import funkin.util.CLIUtil.CLIParams; import funkin.util.CLIUtil.CLIParams;
import funkin.util.tools.TimerTools;
import funkin.ui.transition.LoadingState; import funkin.ui.transition.LoadingState;
#if discord_rpc #if discord_rpc
import Discord.DiscordClient; import Discord.DiscordClient;
@ -219,7 +220,7 @@ class InitState extends FlxState
// NOTE: Registries must be imported and not referenced with fully qualified names, // NOTE: Registries must be imported and not referenced with fully qualified names,
// to ensure build macros work properly. // to ensure build macros work properly.
trace('Parsing game data...'); trace('Parsing game data...');
var perfStart = haxe.Timer.stamp(); var perfStart:Float = TimerTools.start();
SongEventRegistry.loadEventCache(); // SongEventRegistry is structured differently so it's not a BaseRegistry. SongEventRegistry.loadEventCache(); // SongEventRegistry is structured differently so it's not a BaseRegistry.
SongRegistry.instance.loadEntries(); SongRegistry.instance.loadEntries();
LevelRegistry.instance.loadEntries(); LevelRegistry.instance.loadEntries();
@ -236,9 +237,7 @@ class InitState extends FlxState
ModuleHandler.loadModuleCache(); ModuleHandler.loadModuleCache();
ModuleHandler.callOnCreate(); ModuleHandler.callOnCreate();
var perfEnd = haxe.Timer.stamp(); trace('Parsing game data took: ${TimerTools.ms(perfStart)}');
trace('Parsing game data took ${Math.floor((perfEnd - perfStart) * 1000)}ms.');
} }
/** /**

View file

@ -10,7 +10,6 @@ import flixel.util.FlxColor;
import funkin.audio.visualize.PolygonSpectogram.VISTYPE; import funkin.audio.visualize.PolygonSpectogram.VISTYPE;
import funkin.audio.visualize.VisShit.CurAudioInfo; import funkin.audio.visualize.VisShit.CurAudioInfo;
import funkin.audio.visualize.dsp.FFT; import funkin.audio.visualize.dsp.FFT;
import haxe.Timer;
import lime.system.ThreadPool; import lime.system.ThreadPool;
import lime.utils.Int16Array; import lime.utils.Int16Array;

View file

@ -3,7 +3,6 @@ package funkin.audio.visualize;
import flixel.math.FlxMath; import flixel.math.FlxMath;
import flixel.sound.FlxSound; import flixel.sound.FlxSound;
import funkin.audio.visualize.dsp.FFT; import funkin.audio.visualize.dsp.FFT;
import haxe.Timer;
import lime.system.ThreadPool; import lime.system.ThreadPool;
import lime.utils.Int16Array; import lime.utils.Int16Array;
import funkin.util.MathUtil; import funkin.util.MathUtil;

View file

@ -1,5 +1,7 @@
package funkin.audio.waveform; package funkin.audio.waveform;
import funkin.util.tools.TimerTools;
class WaveformDataParser class WaveformDataParser
{ {
static final INT16_MAX:Int = 32767; static final INT16_MAX:Int = 32767;
@ -71,7 +73,7 @@ class WaveformDataParser
var outputData:Array<Int> = []; var outputData:Array<Int> = [];
var perfStart = haxe.Timer.stamp(); var perfStart:Float = TimerTools.start();
for (pointIndex in 0...outputPointCount) for (pointIndex in 0...outputPointCount)
{ {
@ -108,8 +110,7 @@ class WaveformDataParser
var outputDataLength:Int = Std.int(outputData.length / channels / 2); var outputDataLength:Int = Std.int(outputData.length / channels / 2);
var result = new WaveformData(null, channels, sampleRate, samplesPerPoint, bitsPerSample, outputPointCount, outputData); var result = new WaveformData(null, channels, sampleRate, samplesPerPoint, bitsPerSample, outputPointCount, outputData);
var perfEnd = haxe.Timer.stamp(); trace('[WAVEFORM] Interpreted audio buffer in ${TimerTools.seconds(perfStart)}.');
trace('[WAVEFORM] Interpreted audio buffer in ${perfEnd - perfStart} seconds.');
return result; return result;
} }

View file

@ -338,8 +338,8 @@ class GameOverSubState extends MusicBeatSubState
} }
else else
{ {
isStarting = false;
onComplete = function() { onComplete = function() {
isStarting = false;
// We need to force to ensure that the non-starting music plays. // We need to force to ensure that the non-starting music plays.
startDeathMusic(1.0, true); startDeathMusic(1.0, true);
}; };

View file

@ -3,9 +3,10 @@ package funkin.play.components;
import flixel.FlxSprite; import flixel.FlxSprite;
import flixel.group.FlxGroup.FlxTypedGroup; import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.tweens.FlxTween; import flixel.tweens.FlxTween;
import flixel.util.FlxDirection;
import funkin.graphics.FunkinSprite; import funkin.graphics.FunkinSprite;
import funkin.play.PlayState; import funkin.play.PlayState;
import flixel.util.FlxDirection; import funkin.util.tools.TimerTools;
class PopUpStuff extends FlxTypedGroup<FlxSprite> class PopUpStuff extends FlxTypedGroup<FlxSprite>
{ {
@ -16,9 +17,7 @@ class PopUpStuff extends FlxTypedGroup<FlxSprite>
public function displayRating(daRating:String) public function displayRating(daRating:String)
{ {
#if sys var perfStart:Float = TimerTools.start();
var perfStart:Float = Sys.time();
#end
if (daRating == null) daRating = "good"; if (daRating == null) daRating = "good";
@ -60,17 +59,12 @@ class PopUpStuff extends FlxTypedGroup<FlxSprite>
startDelay: Conductor.instance.beatLengthMs * 0.001 startDelay: Conductor.instance.beatLengthMs * 0.001
}); });
#if sys trace('displayRating took: ${TimerTools.seconds(perfStart)}');
var perfEnd:Float = Sys.time();
trace("displayRating took: " + (perfEnd - perfStart));
#end
} }
public function displayCombo(?combo:Int = 0):Int public function displayCombo(?combo:Int = 0):Int
{ {
#if sys var perfStart:Float = TimerTools.start();
var perfStart:Float = Sys.time();
#end
if (combo == null) combo = 0; if (combo == null) combo = 0;
@ -163,10 +157,7 @@ class PopUpStuff extends FlxTypedGroup<FlxSprite>
daLoop++; daLoop++;
} }
#if sys trace('displayCombo took: ${TimerTools.seconds(perfStart)}');
var perfEnd:Float = Sys.time();
trace("displayCombo took: " + (perfEnd - perfStart));
#end
return combo; return combo;
} }

View file

@ -7,6 +7,7 @@ import funkin.audio.FunkinSound;
import funkin.play.character.BaseCharacter.CharacterType; import funkin.play.character.BaseCharacter.CharacterType;
import funkin.util.FileUtil; import funkin.util.FileUtil;
import funkin.util.assets.SoundUtil; import funkin.util.assets.SoundUtil;
import funkin.util.tools.TimerTools;
import funkin.audio.waveform.WaveformData; import funkin.audio.waveform.WaveformData;
import funkin.audio.waveform.WaveformDataParser; import funkin.audio.waveform.WaveformDataParser;
import funkin.audio.waveform.WaveformSprite; import funkin.audio.waveform.WaveformSprite;
@ -128,41 +129,41 @@ class ChartEditorAudioHandler
public static function switchToInstrumental(state:ChartEditorState, instId:String = '', playerId:String, opponentId:String):Bool public static function switchToInstrumental(state:ChartEditorState, instId:String = '', playerId:String, opponentId:String):Bool
{ {
var perfA = haxe.Timer.stamp(); var perfA:Float = TimerTools.start();
var result:Bool = playInstrumental(state, instId); var result:Bool = playInstrumental(state, instId);
if (!result) return false; if (!result) return false;
var perfB = haxe.Timer.stamp(); var perfB:Float = TimerTools.start();
stopExistingVocals(state); stopExistingVocals(state);
var perfC = haxe.Timer.stamp(); var perfC:Float = TimerTools.start();
result = playVocals(state, BF, playerId, instId); result = playVocals(state, BF, playerId, instId);
var perfD = haxe.Timer.stamp(); var perfD:Float = TimerTools.start();
// if (!result) return false; // if (!result) return false;
result = playVocals(state, DAD, opponentId, instId); result = playVocals(state, DAD, opponentId, instId);
// if (!result) return false; // if (!result) return false;
var perfE = haxe.Timer.stamp(); var perfE:Float = TimerTools.start();
state.hardRefreshOffsetsToolbox(); state.hardRefreshOffsetsToolbox();
var perfF = haxe.Timer.stamp(); var perfF:Float = TimerTools.start();
state.hardRefreshFreeplayToolbox(); state.hardRefreshFreeplayToolbox();
var perfG = haxe.Timer.stamp(); var perfG:Float = TimerTools.start();
trace('Switched to instrumental in ${perfB - perfA} seconds.'); trace('Switched to instrumental in ${TimerTools.seconds(perfA, perfB)}.');
trace('Stopped existing vocals in ${perfC - perfB} seconds.'); trace('Stopped existing vocals in ${TimerTools.seconds(perfB, perfC)}.');
trace('Played BF vocals in ${perfD - perfC} seconds.'); trace('Played BF vocals in ${TimerTools.seconds(perfC, perfD)}.');
trace('Played DAD vocals in ${perfE - perfD} seconds.'); trace('Played DAD vocals in ${TimerTools.seconds(perfD, perfE)}.');
trace('Hard refreshed offsets toolbox in ${perfF - perfE} seconds.'); trace('Hard refreshed offsets toolbox in ${TimerTools.seconds(perfE, perfF)}.');
trace('Hard refreshed freeplay toolbox in ${perfG - perfF} seconds.'); trace('Hard refreshed freeplay toolbox in ${TimerTools.seconds(perfF, perfG)}.');
return true; return true;
} }
@ -174,10 +175,9 @@ class ChartEditorAudioHandler
{ {
if (instId == '') instId = 'default'; if (instId == '') instId = 'default';
var instTrackData:Null<Bytes> = state.audioInstTrackData.get(instId); var instTrackData:Null<Bytes> = state.audioInstTrackData.get(instId);
var perfA = haxe.Timer.stamp(); var perfStart:Float = TimerTools.start();
var instTrack:Null<FunkinSound> = SoundUtil.buildSoundFromBytes(instTrackData); var instTrack:Null<FunkinSound> = SoundUtil.buildSoundFromBytes(instTrackData);
var perfB = haxe.Timer.stamp(); trace('Built instrumental track in ${TimerTools.seconds(perfStart)} seconds.');
trace('Built instrumental track in ${perfB - perfA} seconds.');
if (instTrack == null) return false; if (instTrack == null) return false;
stopExistingInstrumental(state); stopExistingInstrumental(state);
@ -205,10 +205,9 @@ class ChartEditorAudioHandler
{ {
var trackId:String = '${charId}${instId == '' ? '' : '-${instId}'}'; var trackId:String = '${charId}${instId == '' ? '' : '-${instId}'}';
var vocalTrackData:Null<Bytes> = state.audioVocalTrackData.get(trackId); var vocalTrackData:Null<Bytes> = state.audioVocalTrackData.get(trackId);
var perfStart = haxe.Timer.stamp(); var perfStart:Float = TimerTools.start();
var vocalTrack:Null<FunkinSound> = SoundUtil.buildSoundFromBytes(vocalTrackData); var vocalTrack:Null<FunkinSound> = SoundUtil.buildSoundFromBytes(vocalTrackData);
var perfEnd = haxe.Timer.stamp(); trace('Built vocal track in ${TimerTools.seconds(perfStart)}.');
trace('Built vocal track in ${perfEnd - perfStart} seconds.');
if (state.audioVocalTrackGroup == null) state.audioVocalTrackGroup = new VoicesGroup(); if (state.audioVocalTrackGroup == null) state.audioVocalTrackGroup = new VoicesGroup();
@ -219,10 +218,9 @@ class ChartEditorAudioHandler
case BF: case BF:
state.audioVocalTrackGroup.addPlayerVoice(vocalTrack); state.audioVocalTrackGroup.addPlayerVoice(vocalTrack);
var perfStart = haxe.Timer.stamp(); var perfStart:Float = TimerTools.start();
var waveformData:Null<WaveformData> = vocalTrack.waveformData; var waveformData:Null<WaveformData> = vocalTrack.waveformData;
var perfEnd = haxe.Timer.stamp(); trace('Interpreted waveform data in ${TimerTools.seconds(perfStart)}.');
trace('Interpreted waveform data in ${perfEnd - perfStart} seconds.');
if (waveformData != null) if (waveformData != null)
{ {
@ -246,10 +244,9 @@ class ChartEditorAudioHandler
case DAD: case DAD:
state.audioVocalTrackGroup.addOpponentVoice(vocalTrack); state.audioVocalTrackGroup.addOpponentVoice(vocalTrack);
var perfStart = haxe.Timer.stamp(); var perfStart:Float = TimerTools.start();
var waveformData:Null<WaveformData> = vocalTrack.waveformData; var waveformData:Null<WaveformData> = vocalTrack.waveformData;
var perfEnd = haxe.Timer.stamp(); trace('Interpreted waveform data in ${TimerTools.seconds(perfStart)}.');
trace('Interpreted waveform data in ${perfEnd - perfStart} seconds.');
if (waveformData != null) if (waveformData != null)
{ {

View file

@ -1,21 +1,22 @@
package funkin.ui.debug.charting.toolboxes; package funkin.ui.debug.charting.toolboxes;
import flixel.addons.display.FlxTiledSprite;
import flixel.math.FlxMath;
import funkin.audio.SoundGroup; import funkin.audio.SoundGroup;
import funkin.audio.waveform.WaveformDataParser;
import funkin.ui.debug.charting.commands.SetFreeplayPreviewCommand;
import funkin.ui.haxeui.components.WaveformPlayer;
import funkin.ui.freeplay.FreeplayState;
import funkin.util.tools.TimerTools;
import haxe.ui.backend.flixel.components.SpriteWrapper;
import haxe.ui.components.Button; import haxe.ui.components.Button;
import haxe.ui.components.HorizontalSlider; import haxe.ui.components.HorizontalSlider;
import haxe.ui.components.Label; import haxe.ui.components.Label;
import flixel.addons.display.FlxTiledSprite;
import flixel.math.FlxMath;
import haxe.ui.components.NumberStepper; import haxe.ui.components.NumberStepper;
import haxe.ui.components.Slider; import haxe.ui.components.Slider;
import haxe.ui.backend.flixel.components.SpriteWrapper;
import funkin.ui.debug.charting.commands.SetFreeplayPreviewCommand;
import funkin.ui.haxeui.components.WaveformPlayer;
import funkin.audio.waveform.WaveformDataParser;
import haxe.ui.containers.VBox; import haxe.ui.containers.VBox;
import haxe.ui.containers.Absolute; import haxe.ui.containers.Absolute;
import haxe.ui.containers.ScrollView; import haxe.ui.containers.ScrollView;
import funkin.ui.freeplay.FreeplayState;
import haxe.ui.containers.Frame; import haxe.ui.containers.Frame;
import haxe.ui.core.Screen; import haxe.ui.core.Screen;
import haxe.ui.events.DragEvent; import haxe.ui.events.DragEvent;
@ -288,12 +289,12 @@ class ChartEditorFreeplayToolbox extends ChartEditorBaseToolbox
// Build player waveform. // Build player waveform.
// waveformMusic.waveform.forceUpdate = true; // waveformMusic.waveform.forceUpdate = true;
var perfStart = haxe.Timer.stamp(); var perfStart:Float = TimerTools.start();
var waveformData1 = playerVoice?.waveformData; var waveformData1 = playerVoice?.waveformData;
var waveformData2 = opponentVoice?.waveformData ?? playerVoice?.waveformData; // this null check is for songs that only have 1 vocals file! var waveformData2 = opponentVoice?.waveformData ?? playerVoice?.waveformData; // this null check is for songs that only have 1 vocals file!
var waveformData3 = chartEditorState.audioInstTrack.waveformData; var waveformData3 = chartEditorState.audioInstTrack.waveformData;
var waveformData = waveformData3.merge(waveformData1).merge(waveformData2); var waveformData = waveformData3.merge(waveformData1).merge(waveformData2);
trace('Waveform data merging took: ${haxe.Timer.stamp() - perfStart} seconds'); trace('Waveform data merging took: ${TimerTools.seconds(perfStart)}');
waveformMusic.waveform.waveformData = waveformData; waveformMusic.waveform.waveformData = waveformData;
// Set the width and duration to render the full waveform, with the clipRect applied we only render a segment of it. // Set the width and duration to render the full waveform, with the clipRect applied we only render a segment of it.

View file

@ -1,6 +1,7 @@
package funkin.util.plugins; package funkin.util.plugins;
import flixel.FlxBasic; import flixel.FlxBasic;
import funkin.util.tools.TimerTools;
/** /**
* A plugin which adds functionality to press `Ins` to immediately perform memory garbage collection. * A plugin which adds functionality to press `Ins` to immediately perform memory garbage collection.
@ -23,10 +24,9 @@ class MemoryGCPlugin extends FlxBasic
if (FlxG.keys.justPressed.INSERT) if (FlxG.keys.justPressed.INSERT)
{ {
var perfStart:Float = Sys.time(); var perfStart:Float = TimerTools.start();
funkin.util.MemoryUtil.collect(true); funkin.util.MemoryUtil.collect(true);
var perfEnd:Float = Sys.time(); trace('Memory GC took: ${TimerTools.seconds(perfStart)}');
trace("Memory GC took " + (perfEnd - perfStart) + " seconds");
} }
} }

View file

@ -12,4 +12,13 @@ class FloatTools
{ {
return Math.max(min, Math.min(max, value)); return Math.max(min, Math.min(max, value));
} }
/**
Round a float to a certain number of decimal places.
**/
public static function round(number:Float, ?precision = 2):Float
{
number *= Math.pow(10, precision);
return Math.round(number) / Math.pow(10, precision);
}
} }

View file

@ -0,0 +1,30 @@
package funkin.util.tools;
import funkin.util.tools.FloatTools;
import haxe.Timer;
class TimerTools
{
public static function start():Float
{
return Timer.stamp();
}
private static function took(start:Float, ?end:Float):Float
{
var endOrNow:Float = end != null ? end : Timer.stamp();
return endOrNow - start;
}
public static function seconds(start:Float, ?end:Float, ?precision = 2):String
{
var seconds:Float = FloatTools.round(took(start, end), precision);
return '${seconds} seconds';
}
public static function ms(start:Float, ?end:Float):String
{
var seconds:Float = took(start, end);
return '${seconds * 1000} ms';
}
}