mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-07-22 12:21:07 +00:00
Merge branch 'audio-stream' into develop-0.4.0
This commit is contained in:
commit
4f34079b98
|
@ -126,6 +126,7 @@
|
|||
<haxelib name="hxCodec" if="desktop" unless="hl" /> <!-- Video playback -->
|
||||
<haxelib name="funkin.vis"/>
|
||||
|
||||
<haxelib name="FlxPartialSound" /> <!-- Loading partial sound data -->
|
||||
|
||||
<haxelib name="json2object" /> <!-- JSON parsing -->
|
||||
<haxelib name="thx.core" /> <!-- General utility library, "the lodash of Haxe" -->
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
{
|
||||
"props": {
|
||||
"ignoreExtern": true,
|
||||
"format": "^[a-z][A-Z][A-Z0-9]*(_[A-Z0-9_]+)*$",
|
||||
"format": "^[a-zA-Z0-9]+(?:_[a-zA-Z0-9]+)*$",
|
||||
"tokens": ["INLINE", "NOTINLINE"]
|
||||
},
|
||||
"type": "ConstantName"
|
||||
|
|
7
hmm.json
7
hmm.json
|
@ -1,5 +1,12 @@
|
|||
{
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "FlxPartialSound",
|
||||
"type": "git",
|
||||
"dir": null,
|
||||
"ref": "44aa7eb",
|
||||
"url": "https://github.com/FunkinCrew/FlxPartialSound.git"
|
||||
},
|
||||
{
|
||||
"name": "discord_rpc",
|
||||
"type": "git",
|
||||
|
|
|
@ -123,9 +123,17 @@ class Paths
|
|||
return 'songs:assets/songs/${song.toLowerCase()}/Voices$suffix.${Constants.EXT_SOUND}';
|
||||
}
|
||||
|
||||
public static function inst(song:String, ?suffix:String = ''):String
|
||||
/**
|
||||
* Gets the path to an `Inst.mp3/ogg` song instrumental from songs:assets/songs/`song`/
|
||||
* @param song name of the song to get instrumental for
|
||||
* @param suffix any suffix to add to end of song name, used for `-erect` variants usually
|
||||
* @param withExtension if it should return with the audio file extension `.mp3` or `.ogg`.
|
||||
* @return String
|
||||
*/
|
||||
public static function inst(song:String, ?suffix:String = '', ?withExtension:Bool = true):String
|
||||
{
|
||||
return 'songs:assets/songs/${song.toLowerCase()}/Inst$suffix.${Constants.EXT_SOUND}';
|
||||
var ext:String = withExtension ? '.${Constants.EXT_SOUND}' : '';
|
||||
return 'songs:assets/songs/${song.toLowerCase()}/Inst$suffix$ext';
|
||||
}
|
||||
|
||||
public static function image(key:String, ?library:String):String
|
||||
|
@ -153,3 +161,11 @@ class Paths
|
|||
return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library));
|
||||
}
|
||||
}
|
||||
|
||||
enum abstract PathsFunction(String)
|
||||
{
|
||||
var MUSIC;
|
||||
var INST;
|
||||
var VOICES;
|
||||
var SOUND;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package funkin.api.newgrounds;
|
||||
|
||||
import flixel.util.FlxSignal;
|
||||
import flixel.util.FlxTimer;
|
||||
import lime.app.Application;
|
||||
import openfl.display.Stage;
|
||||
#if newgrounds
|
||||
import io.newgrounds.NG;
|
||||
import io.newgrounds.NGLite;
|
||||
|
|
|
@ -2,19 +2,11 @@ package funkin.api.newgrounds;
|
|||
|
||||
#if newgrounds
|
||||
import flixel.util.FlxSignal;
|
||||
import flixel.util.FlxTimer;
|
||||
import io.newgrounds.NG;
|
||||
import io.newgrounds.NGLite;
|
||||
import io.newgrounds.components.ScoreBoardComponent.Period;
|
||||
import io.newgrounds.objects.Error;
|
||||
import io.newgrounds.objects.Medal;
|
||||
import io.newgrounds.objects.Score;
|
||||
import io.newgrounds.objects.ScoreBoard;
|
||||
import io.newgrounds.objects.events.Response;
|
||||
import io.newgrounds.objects.events.Result.GetCurrentVersionResult;
|
||||
import io.newgrounds.objects.events.Result.GetVersionResult;
|
||||
import lime.app.Application;
|
||||
import openfl.display.Stage;
|
||||
#end
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,10 +11,14 @@ import funkin.audio.waveform.WaveformDataParser;
|
|||
import funkin.data.song.SongData.SongMusicData;
|
||||
import funkin.data.song.SongRegistry;
|
||||
import funkin.util.tools.ICloneable;
|
||||
import funkin.util.flixel.sound.FlxPartialSound;
|
||||
import funkin.Paths.PathsFunction;
|
||||
import openfl.Assets;
|
||||
import lime.app.Future;
|
||||
import lime.app.Promise;
|
||||
import openfl.media.SoundMixer;
|
||||
|
||||
#if (openfl >= "8.0.0")
|
||||
import openfl.utils.AssetType;
|
||||
#end
|
||||
|
||||
/**
|
||||
|
@ -342,23 +346,68 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
|
|||
FlxG.log.warn('Tried and failed to find music metadata for $key');
|
||||
}
|
||||
}
|
||||
|
||||
var music = FunkinSound.load(Paths.music('$key/$key'), params?.startingVolume ?? 1.0, params.loop ?? true, false, true);
|
||||
if (music != null)
|
||||
var pathsFunction = params.pathsFunction ?? MUSIC;
|
||||
var suffix = params.suffix ?? '';
|
||||
var pathToUse = switch (pathsFunction)
|
||||
{
|
||||
FlxG.sound.music = music;
|
||||
case MUSIC: Paths.music('$key/$key');
|
||||
case INST: Paths.inst('$key', suffix);
|
||||
default: Paths.music('$key/$key');
|
||||
}
|
||||
|
||||
// Prevent repeat update() and onFocus() calls.
|
||||
FlxG.sound.list.remove(FlxG.sound.music);
|
||||
var shouldLoadPartial = params.partialParams?.loadPartial ?? false;
|
||||
|
||||
return true;
|
||||
if (shouldLoadPartial)
|
||||
{
|
||||
var music = FunkinSound.loadPartial(pathToUse, params.partialParams?.start ?? 0, params.partialParams?.end ?? 1, params?.startingVolume ?? 1.0,
|
||||
params.loop ?? true, false, false, params.onComplete);
|
||||
|
||||
if (music != null)
|
||||
{
|
||||
while (partialQueue.length > 0)
|
||||
{
|
||||
@:nullSafety(Off)
|
||||
partialQueue.pop().error("Cancel loading partial sound");
|
||||
}
|
||||
|
||||
partialQueue.push(music);
|
||||
|
||||
@:nullSafety(Off)
|
||||
music.future.onComplete(function(partialMusic:Null<FunkinSound>) {
|
||||
FlxG.sound.music = partialMusic;
|
||||
FlxG.sound.list.remove(FlxG.sound.music);
|
||||
|
||||
if (params.onLoad != null) params.onLoad();
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
var music = FunkinSound.load(pathToUse, params?.startingVolume ?? 1.0, params.loop ?? true, false, true);
|
||||
if (music != null)
|
||||
{
|
||||
FlxG.sound.music = music;
|
||||
|
||||
// Prevent repeat update() and onFocus() calls.
|
||||
FlxG.sound.list.remove(FlxG.sound.music);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static var partialQueue:Array<Promise<Null<FunkinSound>>> = [];
|
||||
|
||||
/**
|
||||
* Creates a new `FunkinSound` object synchronously.
|
||||
*
|
||||
|
@ -415,6 +464,42 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
|
|||
return sound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will load a section of a sound file, useful for Freeplay where we don't want to load all the bytes of a song
|
||||
* @param path The path to the sound file
|
||||
* @param start The start time of the sound file
|
||||
* @param end The end time of the sound file
|
||||
* @param volume Volume to start at
|
||||
* @param looped Whether the sound file should loop
|
||||
* @param autoDestroy Whether the sound file should be destroyed after it finishes playing
|
||||
* @param autoPlay Whether the sound file should play immediately
|
||||
* @param onComplete Callback when the sound finishes playing
|
||||
* @param onLoad Callback when the sound finishes loading
|
||||
* @return A FunkinSound object
|
||||
*/
|
||||
public static function loadPartial(path:String, start:Float = 0, end:Float = 1, volume:Float = 1.0, looped:Bool = false, autoDestroy:Bool = false,
|
||||
autoPlay:Bool = true, ?onComplete:Void->Void, ?onLoad:Void->Void):Promise<Null<FunkinSound>>
|
||||
{
|
||||
var promise:lime.app.Promise<Null<FunkinSound>> = new lime.app.Promise<Null<FunkinSound>>();
|
||||
|
||||
// split the path and get only after first :
|
||||
// we are bypassing the openfl/lime asset library fuss
|
||||
path = Paths.stripLibrary(path);
|
||||
|
||||
var soundRequest = FlxPartialSound.partialLoadFromFile(path, start, end);
|
||||
|
||||
promise.future.onError(function(e) {
|
||||
soundRequest.error("Sound loading was errored or cancelled");
|
||||
});
|
||||
|
||||
soundRequest.future.onComplete(function(partialSound) {
|
||||
var snd = FunkinSound.load(partialSound, volume, looped, autoDestroy, autoPlay, onComplete, onLoad);
|
||||
promise.complete(snd);
|
||||
});
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
@:nullSafety(Off)
|
||||
public override function destroy():Void
|
||||
{
|
||||
|
@ -475,6 +560,12 @@ typedef FunkinSoundPlayMusicParams =
|
|||
*/
|
||||
var ?startingVolume:Float;
|
||||
|
||||
/**
|
||||
* The suffix of the music file to play. Usually for "-erect" tracks when loading an INST file
|
||||
* @default ``
|
||||
*/
|
||||
var ?suffix:String;
|
||||
|
||||
/**
|
||||
* Whether to override music if a different track is already playing.
|
||||
* @default `false`
|
||||
|
@ -498,4 +589,22 @@ typedef FunkinSoundPlayMusicParams =
|
|||
* @default `true`
|
||||
*/
|
||||
var ?mapTimeChanges:Bool;
|
||||
|
||||
/**
|
||||
* Which Paths function to use to load a song
|
||||
* @default `MUSIC`
|
||||
*/
|
||||
var ?pathsFunction:PathsFunction;
|
||||
|
||||
var ?partialParams:PartialSoundParams;
|
||||
|
||||
var ?onComplete:Void->Void;
|
||||
var ?onLoad:Void->Void;
|
||||
}
|
||||
|
||||
typedef PartialSoundParams =
|
||||
{
|
||||
var loadPartial:Bool;
|
||||
var start:Float;
|
||||
var end:Float;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package funkin.audio;
|
||||
|
||||
import funkin.audio.FunkinSound;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import funkin.audio.waveform.WaveformData;
|
||||
import funkin.audio.waveform.WaveformDataParser;
|
||||
|
||||
class VoicesGroup extends SoundGroup
|
||||
{
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package funkin.audio.visualize;
|
||||
|
||||
import funkin.audio.visualize.dsp.FFT;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.addons.plugin.taskManager.FlxTask;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
|
||||
import flixel.math.FlxMath;
|
||||
import flixel.sound.FlxSound;
|
||||
import funkin.util.MathUtil;
|
||||
import funkin.vis.dsp.SpectralAnalyzer;
|
||||
import funkin.vis.audioclip.frontends.LimeAudioClip;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package funkin.audio.visualize;
|
||||
|
||||
import funkin.audio.visualize.PolygonSpectogram;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import flixel.sound.FlxSound;
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@ import flixel.sound.FlxSound;
|
|||
import flixel.util.FlxColor;
|
||||
import funkin.audio.visualize.PolygonSpectogram.VISTYPE;
|
||||
import funkin.audio.visualize.VisShit.CurAudioInfo;
|
||||
import funkin.audio.visualize.dsp.FFT;
|
||||
import lime.system.ThreadPool;
|
||||
import lime.utils.Int16Array;
|
||||
|
||||
using Lambda;
|
||||
|
@ -38,8 +36,6 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
|
|||
lengthOfShit = amnt;
|
||||
|
||||
regenLineShit();
|
||||
|
||||
// makeGraphic(200, 200, FlxColor.BLACK);
|
||||
}
|
||||
|
||||
public function regenLineShit():Void
|
||||
|
@ -89,8 +85,6 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
|
|||
{
|
||||
checkAndSetBuffer();
|
||||
|
||||
// vis.checkAndSetBuffer();
|
||||
|
||||
if (setBuffer)
|
||||
{
|
||||
var samplesToGen:Int = Std.int(sampleRate * seconds);
|
||||
|
@ -191,7 +185,6 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
|
|||
// a value between 10hz and 100Khz
|
||||
var hzPicker:Float = Math.pow(10, powedShit);
|
||||
|
||||
// var sampleApprox:Int = Std.int(FlxMath.remapToRange(i, 0, group.members.length, startingSample, startingSample + samplesToGen));
|
||||
var remappedFreq:Int = Std.int(FlxMath.remapToRange(hzPicker, 0, 10000, 0, freqShit[0].length - 1));
|
||||
|
||||
group.members[i].x = prevLine.x;
|
||||
|
@ -211,8 +204,6 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
|
|||
var line = FlxPoint.get(prevLine.x - group.members[i].x, prevLine.y - group.members[i].y);
|
||||
|
||||
// dont draw a line until i figure out a nicer way to view da spikes and shit idk lol!
|
||||
// group.members[i].setGraphicSize(Std.int(Math.max(line.length, 1)), Std.int(1));
|
||||
// group.members[i].angle = line.degrees;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -261,9 +252,6 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
|
|||
|
||||
group.members[Std.int(remappedSample)].x = prevLine.x;
|
||||
group.members[Std.int(remappedSample)].y = prevLine.y;
|
||||
// group.members[0].y = prevLine.y;
|
||||
|
||||
// FlxSpriteUtil.drawLine(this, prevLine.x, prevLine.y, width * remappedSample, left * height / 2 + height / 2);
|
||||
prevLine.x = (curAud.balanced * swagheight / 2 + swagheight / 2) + x;
|
||||
prevLine.y = (Std.int(remappedSample) / lengthOfShit * daHeight) + y;
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package funkin.audio.visualize;
|
|||
import flixel.math.FlxMath;
|
||||
import flixel.sound.FlxSound;
|
||||
import funkin.audio.visualize.dsp.FFT;
|
||||
import lime.system.ThreadPool;
|
||||
import lime.utils.Int16Array;
|
||||
import funkin.util.MathUtil;
|
||||
|
||||
|
@ -73,9 +72,6 @@ class VisShit
|
|||
|
||||
freqOutput.push([]);
|
||||
|
||||
// if (FlxG.keys.justPressed.M)
|
||||
// trace(FFT.rfft(chunk).map(z -> z.scale(1 / fs).magnitude));
|
||||
|
||||
// find spectral peaks and their instantaneous frequencies
|
||||
for (k => s in freqs)
|
||||
{
|
||||
|
@ -91,7 +87,6 @@ class VisShit
|
|||
if (freq < maxFreq) freqOutput[indexOfArray].push(power);
|
||||
//
|
||||
}
|
||||
// haxe.Log.trace("", null);
|
||||
|
||||
indexOfArray++;
|
||||
// move to next (overlapping) chunk
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package funkin.audio.visualize.dsp;
|
||||
|
||||
import funkin.audio.visualize.dsp.Complex;
|
||||
|
||||
using funkin.audio.visualize.dsp.OffsetArray;
|
||||
using funkin.audio.visualize.dsp.Signal;
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package funkin.audio.waveform;
|
||||
|
||||
import funkin.util.MathUtil;
|
||||
|
||||
@:nullSafety
|
||||
class WaveformData
|
||||
{
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package funkin.audio.waveform;
|
||||
|
||||
import funkin.audio.waveform.WaveformData;
|
||||
import funkin.audio.waveform.WaveformDataParser;
|
||||
import funkin.graphics.rendering.MeshRender;
|
||||
import flixel.util.FlxColor;
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package funkin.data.dialogue.conversation;
|
||||
|
||||
import funkin.data.animation.AnimationData;
|
||||
|
||||
/**
|
||||
* A type definition for the data for a specific conversation.
|
||||
* It includes things like what dialogue boxes to use, what text to display, and what animations to play.
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package funkin.data.dialogue.conversation;
|
||||
|
||||
import funkin.play.cutscene.dialogue.Conversation;
|
||||
import funkin.data.dialogue.conversation.ConversationData;
|
||||
import funkin.play.cutscene.dialogue.ScriptedConversation;
|
||||
|
||||
class ConversationRegistry extends BaseRegistry<Conversation, ConversationData>
|
||||
|
|
|
@ -420,7 +420,7 @@ class Strumline extends FlxSpriteGroup
|
|||
|
||||
if (Preferences.downscroll)
|
||||
{
|
||||
holdNote.y = this.y + calculateNoteYPos(holdNote.strumTime, vwoosh) - holdNote.height + STRUMLINE_SIZE / 2;
|
||||
holdNote.y = this.y - INITIAL_OFFSET + calculateNoteYPos(holdNote.strumTime, vwoosh) - holdNote.height + STRUMLINE_SIZE / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -449,7 +449,7 @@ class Strumline extends FlxSpriteGroup
|
|||
|
||||
if (Preferences.downscroll)
|
||||
{
|
||||
holdNote.y = this.y - holdNote.height + STRUMLINE_SIZE / 2;
|
||||
holdNote.y = this.y - INITIAL_OFFSET - holdNote.height + STRUMLINE_SIZE / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -464,7 +464,7 @@ class Strumline extends FlxSpriteGroup
|
|||
|
||||
if (Preferences.downscroll)
|
||||
{
|
||||
holdNote.y = this.y + calculateNoteYPos(holdNote.strumTime, vwoosh) - holdNote.height + STRUMLINE_SIZE / 2;
|
||||
holdNote.y = this.y - INITIAL_OFFSET + calculateNoteYPos(holdNote.strumTime, vwoosh) - holdNote.height + STRUMLINE_SIZE / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1251,23 +1251,25 @@ class FreeplayState extends MusicBeatSubState
|
|||
}
|
||||
else
|
||||
{
|
||||
var potentiallyErect:String = (currentDifficulty == "erect") || (currentDifficulty == "nightmare") ? "-erect" : "";
|
||||
// TODO: Stream the instrumental of the selected song?
|
||||
var didReplace:Bool = FunkinSound.playMusic('freakyMenu',
|
||||
FunkinSound.playMusic(daSongCapsule.songData.songId,
|
||||
{
|
||||
startingVolume: 0.0,
|
||||
overrideExisting: true,
|
||||
restartTrack: false
|
||||
restartTrack: false,
|
||||
pathsFunction: INST,
|
||||
suffix: potentiallyErect,
|
||||
partialParams:
|
||||
{
|
||||
loadPartial: true,
|
||||
start: 0,
|
||||
end: 0.1
|
||||
},
|
||||
onLoad: function() {
|
||||
FlxG.sound.music.fadeIn(2, 0, 0.4);
|
||||
}
|
||||
});
|
||||
if (didReplace)
|
||||
{
|
||||
FunkinSound.playMusic('freakyMenu',
|
||||
{
|
||||
startingVolume: 0.0,
|
||||
overrideExisting: true,
|
||||
restartTrack: false
|
||||
});
|
||||
FlxG.sound.music.fadeIn(2, 0, 0.8);
|
||||
}
|
||||
}
|
||||
grpCapsules.members[curSelected].selected = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue