player vis in progress

This commit is contained in:
Cameron Taylor 2023-11-29 06:17:01 -05:00
parent eea614b4f5
commit df427c8ecb
4 changed files with 85 additions and 8 deletions

View file

@ -26,11 +26,11 @@ class PolygonSpectogram extends MeshRender
public var thickness:Float = 2;
public var waveAmplitude:Int = 100;
public function new(daSound:FlxSound, ?col:FlxColor = FlxColor.WHITE, ?height:Float = 720, ?detail:Float = 1)
public function new(?daSound:FlxSound, ?col:FlxColor = FlxColor.WHITE, ?height:Float = 720, ?detail:Float = 1)
{
super(0, 0, col);
setSound(daSound);
if (daSound != null) setSound(daSound);
if (height != null) this.daHeight = height;

View file

@ -0,0 +1,70 @@
package funkin.audio.visualize;
import funkin.audio.visualize.PolygonSpectogram;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.sound.FlxSound;
class PolygonVisGroup extends FlxTypedGroup<PolygonSpectogram>
{
var playerVis:PolygonSpectogram;
var opponentVis:PolygonSpectogram;
var instVis:PolygonSpectogram;
public function new()
{
super();
playerVis = new PolygonSpectogram();
opponentVis = new PolygonSpectogram();
}
/**
* Adds the player's visualizer to the group.
* @param visSnd The visualizer to add.
*/
public function addPlayerVis(visSnd:FlxSound):Void
{
var vis:PolygonSpectogram = new PolygonSpectogram(visSnd);
super.add(vis);
playerVis = vis;
}
/**
* Adds the opponent's visualizer to the group.
* @param visSnd The visualizer to add.
*/
public function addOpponentVis(visSnd:FlxSound):Void
{
var vis:PolygonSpectogram = new PolygonSpectogram(visSnd);
super.add(vis);
opponentVis = vis;
}
/**
* Adds the instrument's visualizer to the group.
* @param visSnd The visualizer to add.
*/
public function addInstVis(visSnd:FlxSound):Void
{
var vis:PolygonSpectogram = new PolygonSpectogram(visSnd);
super.add(vis);
instVis = vis;
}
/**
* Overrides the add function to add a visualizer to the group.
* @param vis The visualizer to add.
* @return The added visualizer.
*/
public override function add(vis:PolygonSpectogram):PolygonSpectogram
{
var result:PolygonSpectogram = super.add(vis);
return result;
}
public override function destroy():Void
{
playerVis.destroy();
opponentVis.destroy();
super.destroy();
}
}

View file

@ -112,6 +112,7 @@ import haxe.ui.focus.FocusManager;
import openfl.display.BitmapData;
import funkin.audio.visualize.PolygonSpectogram;
import flixel.group.FlxGroup.FlxTypedGroup;
import funkin.audio.visualize.PolygonVisGroup;
using Lambda;
@ -902,6 +903,13 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
*/
var audioVocalTrackGroup:Null<VoicesGroup> = null;
/**
* The audio vis for the inst/vocals.
* `null` until vocal track(s) are loaded.
* When switching characters, the elements of the PolygonVisGroup will be swapped to match the new character.
*/
var audioVisGroup:Null<PolygonVisGroup> = null;
/**
* A map of the audio tracks for each character's vocals.
* - Keys are `characterId-variation` (with `characterId` being the default variation).
@ -1877,8 +1885,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
add(healthIconBF);
healthIconBF.zIndex = 30;
visulizerGrps = new FlxTypedGroup<PolygonSpectogram>();
add(visulizerGrps);
audioVisGroup = new PolygonVisGroup();
add(audioVisGroup);
}
function buildNotePreview():Void
@ -5058,10 +5066,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
gridPlayheadScrollArea.setGraphicSize(Std.int(gridPlayheadScrollArea.width), songLengthInPixels);
gridPlayheadScrollArea.updateHitbox();
}
var vis:PolygonSpectogram = new PolygonSpectogram(audioInstTrack);
vis.realtimeVisLenght = 1;
visulizerGrps.add(vis);
}
else
{

View file

@ -3,6 +3,7 @@ package funkin.ui.debug.charting.handlers;
import flixel.system.FlxAssets.FlxSoundAsset;
import flixel.system.FlxSound;
import funkin.audio.VoicesGroup;
import funkin.audio.visualize.PolygonVisGroup;
import funkin.play.character.BaseCharacter.CharacterType;
import funkin.util.FileUtil;
import funkin.util.assets.SoundUtil;
@ -168,6 +169,7 @@ class ChartEditorAudioHandler
var vocalTrack:Null<FlxSound> = SoundUtil.buildFlxSoundFromBytes(vocalTrackData);
if (state.audioVocalTrackGroup == null) state.audioVocalTrackGroup = new VoicesGroup();
if (state.audioVisGroup == null) state.audioVisGroup = new PolygonVisGroup();
if (vocalTrack != null)
{
@ -175,6 +177,7 @@ class ChartEditorAudioHandler
{
case BF:
state.audioVocalTrackGroup.addPlayerVoice(vocalTrack);
state.audioVisGroup.addPlayerVis(vocalTrack);
return true;
case DAD:
state.audioVocalTrackGroup.addOpponentVoice(vocalTrack);