diff --git a/assets/preload/data/characters/bf-holding-gf.hx b/assets/preload/data/characters/bf-holding-gf.hx
index 009c04a4..ef2e70ab 100644
--- a/assets/preload/data/characters/bf-holding-gf.hx
+++ b/assets/preload/data/characters/bf-holding-gf.hx
@@ -1,32 +1,25 @@
import funkin.objects.HealthIcon;
-var gfIcon:HealthIcon;
-var doStuff:Bool = false; // Prevent null error
+
+var gfIcon;
+var hasIcon = false; // Prevent null error
function createPost():Void {
- doStuff = ScriptChar.iconSpr != null;
- if (doStuff) {
+ hasIcon = ScriptChar.iconSpr != null;
+ if (hasIcon) {
gfIcon = new HealthIcon('gf');
- gfIcon.cameras = [State.camHUD];
State.iconGroup.add(gfIcon);
setObjMap(gfIcon, 'gfIcon');
-
ScriptChar.iconSpr.staticSize = 0.75;
}
}
-function beatHit():Void {
- if (doStuff) {
- ScriptChar.iconSpr.bumpIcon(1.3/1.25);
- }
-}
-
function updatePost():Void {
- if (doStuff) {
+ if (hasIcon) {
gfIcon.flipX = ScriptChar.iconSpr.flipX;
- var offset:Float = 50;
- if (!ScriptChar.isPlayer) {
- offset *= -1;
- }
+
+ var offset = 50 * ScriptChar.iconSpr.lodDiv;
+ if (!ScriptChar.isPlayer)
+ offset = -offset;
gfIcon.x = ScriptChar.iconSpr.x + offset;
gfIcon.y = ScriptChar.iconSpr.y;
diff --git a/assets/shared/images/skins/default/ratings/nums.png b/assets/shared/images/skins/default/ratings/nums.png
index cf60412b..15c448c8 100644
Binary files a/assets/shared/images/skins/default/ratings/nums.png and b/assets/shared/images/skins/default/ratings/nums.png differ
diff --git a/assets/shared/images/skins/pixel/ratings/nums.png b/assets/shared/images/skins/pixel/ratings/nums.png
index 6cc0c0ed..17625224 100644
Binary files a/assets/shared/images/skins/pixel/ratings/nums.png and b/assets/shared/images/skins/pixel/ratings/nums.png differ
diff --git a/project.xml b/project.xml
index 50682453..0d9814e9 100644
--- a/project.xml
+++ b/project.xml
@@ -78,13 +78,12 @@
-
-
-
+
+
+
-
-
+
+
diff --git a/source/funkin/sound/AudioWaveform.hx b/source/funkin/sound/AudioWaveform.hx
index 8ce3db6d..c9f0200f 100644
--- a/source/funkin/sound/AudioWaveform.hx
+++ b/source/funkin/sound/AudioWaveform.hx
@@ -13,6 +13,8 @@ class AudioWaveform extends FlxSpriteExt
var graphics:Graphics;
var bounds:Rectangle;
+ var waveformWidth:Float;
+
public function new(X:Float = 0.0, Y:Float = 0.0, Width:Float = 250.0, Height:Float = 500.0, ?sound:Sound):Void
{
super(X, Y);
@@ -22,6 +24,8 @@ class AudioWaveform extends FlxSpriteExt
canvas = new Sprite();
graphics = canvas.graphics;
+ waveformWidth = Width * 0.5;
+
if (sound != null)
setSound(sound);
}
@@ -34,42 +38,54 @@ class AudioWaveform extends FlxSpriteExt
static inline var QUALITY:Int = 250;
var sampleRate:Float = 0.0;
- var avgBytes:Array = [];
-
+ var data:Array<#if cpp cpp.Float32 #else Float #end> = [];
+
override function destroy():Void {
super.destroy();
- avgBytes = null;
+ data = null;
canvas = null;
graphics = null;
bounds = null;
}
-
- public function setSound(sound:Sound):Void
- {
- sampleRate = sound.__buffer.sampleRate / QUALITY;
- var bytes:Bytes = sound.__buffer.data.toBytes();
- avgBytes.splice(0, avgBytes.length);
-
+
+ public function setSound(sound:Sound):Void {
+ data.clear();
+
+ var buffer = sound.__buffer;
+ if (buffer == null || buffer.data == null)
+ return;
+
+ sampleRate = buffer.sampleRate / QUALITY;
+ var bytes:Bytes = buffer.data.toBytes();
+
var i:Int = 0;
var l:Int = bytes.length;
- var bigByte:Int = 0;
-
- while(i < l)
- {
+ var sum:Int = 0;
+ var count:Int = 0;
+
+ while(i < l) {
var byte = bytes.getUInt16(i);
if (byte > (65535 / 2))
byte -= 65535;
-
- if (Math.abs(byte) > Math.abs(bigByte))
- bigByte = byte;
-
- if (i % QUALITY == 0) {
- avgBytes.push(Std.int((bigByte / 65535) * 50));
- bigByte = 0;
+
+ sum += FlxMath.absInt(byte);
+ count++;
+
+ if (count == QUALITY) {
+ var average = sum / count;
+ data.push(average * (1 / 65535 * waveformWidth));
+ sum = 0;
+ count = 0;
}
-
+
i++;
}
+
+ // Handle any remaining samples
+ if (count > 0) {
+ var average = sum / count;
+ data.push(average * (1 / 65535 * waveformWidth));
+ }
}
public var audioOffset:Float;
@@ -86,40 +102,29 @@ class AudioWaveform extends FlxSpriteExt
public function redrawWaveform():Void
{
- graphics.__bounds = bounds;
+ //graphics.__bounds = bounds;
- if (!visible || avgBytes.length <= 0 || end <= 0) {
+ if (!visible || data.length <= 0 || end <= 0) {
return;
}
- final w:Int = Std.int(width * .5);
- final h:Int = Std.int(height);
+ var w:Int = Std.int(width * .5);
- graphics.beginFill();
- graphics.lineStyle(0.7, -1, 1.0);
- graphics.moveTo(w, 0);
+ graphics.beginFill(FlxColor.WHITE);
var i:Int = start;
- var l:Int = FlxMath.minInt(end, avgBytes.length);
- var lastByte:Int = 0;
+ var l:Int = FlxMath.minInt(end, data.length);
while (i < l)
{
- final byte:Int = avgBytes.unsafeGet(i);
-
- if (byte != lastByte)
- {
- lastByte = byte;
+ var byte = data.unsafeGet(i);
- final y:Float = inline FlxMath.remapToRange((i - start), 0, (l - start), 0, h);
- lineTo(w + byte, y);
- //lineTo(w, y);
- }
+ var y:Float = inline FlxMath.remapToRange((i - start), 0, (l - start), 0, height);
+ graphics.drawRect(w - (byte * 0.5), y, byte, 1);
- i = (i + 1);
+ i++;
}
- lineTo(w, h);
graphics.endFill();
graphics.__dirty = true;
@@ -141,10 +146,4 @@ class AudioWaveform extends FlxSpriteExt
}
return super.set_visible(value);
}
-
- inline function lineTo(x:Float, y:Float):Void {
- graphics.__positionX = x;
- graphics.__positionY = y;
- graphics.__commands.lineTo(x, y);
- }
}
\ No newline at end of file
diff --git a/source/funkin/states/LoadingState.hx b/source/funkin/states/LoadingState.hx
index 0677e46e..d09a9581 100644
--- a/source/funkin/states/LoadingState.hx
+++ b/source/funkin/states/LoadingState.hx
@@ -42,8 +42,8 @@ class LoadingState extends MusicBeatState
});
}
else {
- //var sound:Sound = streamSounds ? AssetManager.__streamSound(key) : AssetManager.__getFileSound(key);
- assetCache.set(key, {sound: AssetManager.__getFileSound(key)});
+ var sound:Sound = streamSounds ? AssetManager.__streamSound(key) : AssetManager.__getFileSound(key);
+ assetCache.set(key, {sound: sound});
}
}
diff --git a/source/funkin/states/editors/chart/ChartTabs.hx b/source/funkin/states/editors/chart/ChartTabs.hx
index 2ae4c6cf..302b01ce 100644
--- a/source/funkin/states/editors/chart/ChartTabs.hx
+++ b/source/funkin/states/editors/chart/ChartTabs.hx
@@ -518,16 +518,18 @@ class ChartTabs extends FlxUITabMenu
var check_waveform_inst = new FlxUICheckBox(check_mute_inst.x + 125, check_mute_inst.y, null, null, "Instrumental Waveform", 100);
check_waveform_inst.checked = false;
- check_waveform_inst.callback = function() {
- ChartingState.instance.mainGrid.instWaveform.visible = check_waveform_inst.checked;
- ChartingState.instance.mainGrid.instWaveform.redrawWaveform();
+ check_waveform_inst.callback = () -> {
+ var waveform = ChartingState.instance.mainGrid.instWaveform;
+ waveform.visible = check_waveform_inst.checked;
+ waveform.redrawWaveform();
};
var check_waveform_voices = new FlxUICheckBox(check_waveform_inst.x, check_waveform_inst.y + 30, null, null, "Voices Waveform", 100);
check_waveform_voices.checked = false;
- check_waveform_voices.callback = function() {
- ChartingState.instance.mainGrid.voicesWaveform.visible = check_waveform_voices.checked;
- ChartingState.instance.mainGrid.voicesWaveform.redrawWaveform();
+ check_waveform_voices.callback = () -> {
+ var waveform = ChartingState.instance.mainGrid.voicesWaveform;
+ waveform.visible = check_waveform_voices.checked;
+ waveform.redrawWaveform();
};
check_hitsound = new FlxUICheckBox(check_mute_inst.x, check_mute_voices.y + 30, null, null, "Use Hitsounds", 100);
diff --git a/source/funkin/states/editors/chart/grid/ChartNoteGrid.hx b/source/funkin/states/editors/chart/grid/ChartNoteGrid.hx
index 73edd3cb..0a1451de 100644
--- a/source/funkin/states/editors/chart/grid/ChartNoteGrid.hx
+++ b/source/funkin/states/editors/chart/grid/ChartNoteGrid.hx
@@ -118,9 +118,6 @@ class ChartNoteGrid extends ChartGridBase
sustainsGroup = new TypedGroup();
insert(members.indexOf(group), sustainsGroup);
-
- //textGroup = new TypedGroup();
- //insert(members.indexOf(gridShadow), textGroup);
}
public function updateWaveform():Void
diff --git a/source/funkin/states/menus/TitleState.hx b/source/funkin/states/menus/TitleState.hx
index e142a0bd..9d266b83 100644
--- a/source/funkin/states/menus/TitleState.hx
+++ b/source/funkin/states/menus/TitleState.hx
@@ -315,7 +315,7 @@ class TitleState extends MusicBeatState
case 'gay':
if (!gay) {
FlxG.camera.flash(flashy ? FlxColor.WHITE : 0x79ffffff, 3);
- CoolUtil.playMusic("gay", 0);
+ CoolUtil.playMusic("gay", 0, true, true); // Stream this if possible :p
FlxG.sound.music.fadeIn();
codes.remove("gay");
gay = true;
diff --git a/source/funkin/util/CoolUtil.hx b/source/funkin/util/CoolUtil.hx
index dd5c3c2a..3f4f1765 100644
--- a/source/funkin/util/CoolUtil.hx
+++ b/source/funkin/util/CoolUtil.hx
@@ -218,8 +218,8 @@ class CoolUtil {
lil shortcut to play music
itll also change the conductor bpm to the music's data text file thing
*/
- public static function playMusic(music:String, volume:Float = 1, looped:Bool = true):Void {
- FlxG.sound.playMusic(Paths.music(music), volume, looped);
+ public static function playMusic(music:String, volume:Float = 1, looped:Bool = true, ?stream:Bool):Void {
+ FlxG.sound.playMusic(Paths.music(music, null, null, stream), volume, looped);
var musicDataPath:String = Paths.getPath('music/$music-data.txt', MUSIC, null);
if (Paths.exists(musicDataPath, TEXT)) {
diff --git a/source/funkin/util/Paths.hx b/source/funkin/util/Paths.hx
index e395afa9..d42ee4a6 100644
--- a/source/funkin/util/Paths.hx
+++ b/source/funkin/util/Paths.hx
@@ -167,9 +167,9 @@ class Paths
return soundExt(key, "music", library, level);
}
- inline static public function music(key:String, ?library:String, ?level:String):Sound {
+ inline static public function music(key:String, ?library:String, ?level:String, ?stream:Bool):Sound {
var musicPath = musicFolder(key, library, level);
- return AssetManager.cacheSoundPath(musicPath);
+ return AssetManager.cacheSoundPath(musicPath, false, null, stream);
}
/*
@@ -189,7 +189,7 @@ class Paths
return songAudioAssetPath(song, "Voices", globalAsset);
}
- inline static public function voices(song:String, ?globalAsset:Bool, stream:Bool = false):Sound {
+ inline static public function voices(song:String, ?globalAsset:Bool, ?stream:Bool):Sound {
var voicesPath:String = voicesPath(song, globalAsset);
return AssetManager.cacheSoundPath(voicesPath, false, null, stream);
}
@@ -198,7 +198,7 @@ class Paths
return songAudioAssetPath(song, "Inst", globalAsset);
}
- inline static public function inst(song:String, ?globalAsset:Bool, stream:Bool = false):Sound {
+ inline static public function inst(song:String, ?globalAsset:Bool, ?stream:Bool):Sound {
var instPath:String = instPath(song, globalAsset);
return AssetManager.cacheSoundPath(instPath, false, null, stream);
}
diff --git a/source/funkin/util/backend/AssetManager.hx b/source/funkin/util/backend/AssetManager.hx
index 6e896d44..3b1efc47 100644
--- a/source/funkin/util/backend/AssetManager.hx
+++ b/source/funkin/util/backend/AssetManager.hx
@@ -345,7 +345,7 @@ class AssetManager
* SOUND CACHE
*/
- public static function cacheSoundPath(path:String, staticAsset:Bool = false, ?key:String, stream:Bool = false):Sound
+ public static function cacheSoundPath(path:String, staticAsset:Bool = false, ?key:String, ?stream:Bool):Sound
{
if (key == null)
key = path;
@@ -354,6 +354,7 @@ class AssetManager
if (asset != null)
return asset.asset;
+ stream ??= false;
var sound = stream ? __streamSound(path) : __getFileSound(path);
var asset = Asset.fromAsset(sound, key);
@@ -434,8 +435,15 @@ class AssetManager
asset.dispose();
assetsMap.remove(key);
- if (tempAssets.contains(key)) tempAssets.removeAt(tempAssets.indexOf(key));
- else if (staticAssets.contains(key)) staticAssets.removeAt(staticAssets.indexOf(key));
+ var tempIndex:Int = tempAssets.indexOf(key);
+ if (tempIndex != -1) {
+ tempAssets.removeAt(tempIndex);
+ }
+ else {
+ var staticIndex:Int = staticAssets.indexOf(key);
+ if (staticIndex != -1)
+ staticAssets.removeAt(staticIndex);
+ }
return true;
}