mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-03-23 10:29:29 +00:00
polygon spectogram stuff redo
This commit is contained in:
parent
ef67aacf86
commit
804e084668
|
@ -113,18 +113,17 @@ class InitState extends FlxTransitionableState
|
||||||
FlxTransitionableState.skipNextTransIn = true;
|
FlxTransitionableState.skipNextTransIn = true;
|
||||||
|
|
||||||
#if song
|
#if song
|
||||||
|
|
||||||
var song = getSong();
|
var song = getSong();
|
||||||
|
|
||||||
var weeks =
|
var weeks = [
|
||||||
[ ['bopeebo', 'fresh', 'dadbattle']
|
['bopeebo', 'fresh', 'dadbattle'],
|
||||||
, ['spookeez', 'south', 'monster']
|
['spookeez', 'south', 'monster'],
|
||||||
, ['spooky', 'spooky', 'monster']
|
['spooky', 'spooky', 'monster'],
|
||||||
, ['pico', 'philly', 'blammed']
|
['pico', 'philly', 'blammed'],
|
||||||
, ['satin-panties', 'high', 'milf']
|
['satin-panties', 'high', 'milf'],
|
||||||
, ['cocoa', 'eggnog', 'winter-horrorland']
|
['cocoa', 'eggnog', 'winter-horrorland'],
|
||||||
, ['senpai', 'roses', 'thorns']
|
['senpai', 'roses', 'thorns'],
|
||||||
, ['ugh', 'guns', 'stress']
|
['ugh', 'guns', 'stress']
|
||||||
];
|
];
|
||||||
|
|
||||||
var week = 0;
|
var week = 0;
|
||||||
|
@ -141,21 +140,18 @@ class InitState extends FlxTransitionableState
|
||||||
throw 'Invalid -D song=$song';
|
throw 'Invalid -D song=$song';
|
||||||
|
|
||||||
startSong(week, song, false);
|
startSong(week, song, false);
|
||||||
|
|
||||||
#elseif week
|
#elseif week
|
||||||
|
|
||||||
var week = getWeek();
|
var week = getWeek();
|
||||||
|
|
||||||
var songs =
|
var songs = [
|
||||||
[ 'bopeebo', 'spookeez', 'spooky', 'pico'
|
'bopeebo', 'spookeez', 'spooky', 'pico',
|
||||||
, 'satin-panties', 'cocoa', 'senpai', 'ugh'
|
'satin-panties', 'cocoa', 'senpai', 'ugh'
|
||||||
];
|
];
|
||||||
|
|
||||||
if (week <= 0 || week >= songs.length)
|
if (week <= 0 || week >= songs.length)
|
||||||
throw "invalid -D week=" + week;
|
throw "invalid -D week=" + week;
|
||||||
|
|
||||||
startSong(week, songs[week - 1], true);
|
startSong(week, songs[week - 1], true);
|
||||||
|
|
||||||
#elseif FREEPLAY
|
#elseif FREEPLAY
|
||||||
FlxG.switchState(new FreeplayState());
|
FlxG.switchState(new FreeplayState());
|
||||||
#elseif ANIMATE
|
#elseif ANIMATE
|
||||||
|
@ -194,9 +190,14 @@ class InitState extends FlxTransitionableState
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|
||||||
function getWeek() return Std.parseInt(getDefine("week"));
|
function getWeek()
|
||||||
function getSong() return getDefine("song");
|
return Std.parseInt(getDefine("week"));
|
||||||
function getDif() return Std.parseInt(getDefine("dif", "1"));
|
|
||||||
|
function getSong()
|
||||||
|
return getDefine("song");
|
||||||
|
|
||||||
|
function getDif()
|
||||||
|
return Std.parseInt(getDefine("dif", "1"));
|
||||||
|
|
||||||
macro function getDefine(key:String, defaultValue:String = null):haxe.macro.Expr
|
macro function getDefine(key:String, defaultValue:String = null):haxe.macro.Expr
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,6 +13,7 @@ class PolygonSpectogram extends MeshRender
|
||||||
var sampleRate:Int;
|
var sampleRate:Int;
|
||||||
|
|
||||||
public var vis:VisShit;
|
public var vis:VisShit;
|
||||||
|
public var visType:VISTYPE = UPDATED;
|
||||||
public var daHeight:Float = FlxG.height;
|
public var daHeight:Float = FlxG.height;
|
||||||
|
|
||||||
var numSamples:Int = 0;
|
var numSamples:Int = 0;
|
||||||
|
@ -23,7 +24,7 @@ class PolygonSpectogram extends MeshRender
|
||||||
|
|
||||||
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);
|
super(0, 0, col);
|
||||||
|
|
||||||
vis = new VisShit(daSound);
|
vis = new VisShit(daSound);
|
||||||
|
|
||||||
|
@ -35,6 +36,20 @@ class PolygonSpectogram extends MeshRender
|
||||||
// col not in yet
|
// col not in yet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override function update(elapsed:Float)
|
||||||
|
{
|
||||||
|
super.update(elapsed);
|
||||||
|
|
||||||
|
switch (visType)
|
||||||
|
{
|
||||||
|
case UPDATED:
|
||||||
|
realtimeVis();
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var prevAudioData:Int16Array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates and draws a section of the audio data to a visual waveform
|
* Generates and draws a section of the audio data to a visual waveform
|
||||||
* @param start start of the song in milliseconds
|
* @param start start of the song in milliseconds
|
||||||
|
@ -54,18 +69,25 @@ class PolygonSpectogram extends MeshRender
|
||||||
|
|
||||||
var prevPoint:FlxPoint = new FlxPoint();
|
var prevPoint:FlxPoint = new FlxPoint();
|
||||||
|
|
||||||
for (i in 0...500)
|
var funnyPixels:Int = Std.int(daHeight); // sorta redundant but just need it for different var...
|
||||||
|
|
||||||
|
if (prevAudioData == audioData.subarray(startSample, startSample + samplesToGen))
|
||||||
|
return; // optimize / finish funciton here, no need to re-render
|
||||||
|
|
||||||
|
prevAudioData = audioData.subarray(startSample, samplesToGen);
|
||||||
|
|
||||||
|
for (i in 0...funnyPixels)
|
||||||
{
|
{
|
||||||
var sampleApprox:Int = Std.int(FlxMath.remapToRange(i, 0, 500, startSample, startSample + samplesToGen));
|
var sampleApprox:Int = Std.int(FlxMath.remapToRange(i, 0, funnyPixels, startSample, startSample + samplesToGen));
|
||||||
var curAud:CurAudioInfo = VisShit.getCurAud(audioData, sampleApprox);
|
var curAud:CurAudioInfo = VisShit.getCurAud(audioData, sampleApprox);
|
||||||
|
|
||||||
var waveAmplitude:Int = 200;
|
var waveAmplitude:Int = 200;
|
||||||
|
|
||||||
var coolPoint:FlxPoint = new FlxPoint();
|
var coolPoint:FlxPoint = new FlxPoint();
|
||||||
coolPoint.x = (curAud.balanced * waveAmplitude / 2 + waveAmplitude / 2);
|
coolPoint.x = (curAud.balanced * waveAmplitude / 2 + waveAmplitude / 2);
|
||||||
coolPoint.y = (i / 500 * daHeight);
|
coolPoint.y = (i / funnyPixels * daHeight);
|
||||||
|
|
||||||
add_quad(prevPoint.x, prevPoint.y, prevPoint.x + 1, prevPoint.y, coolPoint.x, coolPoint.y, coolPoint.x + 1, coolPoint.y + 1);
|
add_quad(prevPoint.x, prevPoint.y, prevPoint.x + 2, prevPoint.y, coolPoint.x, coolPoint.y, coolPoint.x + 2, coolPoint.y + 2);
|
||||||
|
|
||||||
prevPoint.x = coolPoint.x;
|
prevPoint.x = coolPoint.x;
|
||||||
prevPoint.y = coolPoint.y;
|
prevPoint.y = coolPoint.y;
|
||||||
|
@ -73,6 +95,31 @@ class PolygonSpectogram extends MeshRender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var curTime:Float = 0;
|
||||||
|
|
||||||
|
function realtimeVis():Void
|
||||||
|
{
|
||||||
|
if (vis.snd != null)
|
||||||
|
{
|
||||||
|
if (curTime != vis.snd.time)
|
||||||
|
{
|
||||||
|
trace("DOIN SHIT" + FlxG.random.int(0, 200));
|
||||||
|
|
||||||
|
if (vis.snd.playing)
|
||||||
|
curTime = vis.snd.time;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Math.abs(curTime - vis.snd.time) > 10)
|
||||||
|
curTime = FlxMath.lerp(curTime, vis.snd.time, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
curTime = vis.snd.time;
|
||||||
|
|
||||||
|
generateSection(vis.snd.time, 0.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function checkAndSetBuffer()
|
public function checkAndSetBuffer()
|
||||||
{
|
{
|
||||||
vis.checkAndSetBuffer();
|
vis.checkAndSetBuffer();
|
||||||
|
@ -86,3 +133,10 @@ class PolygonSpectogram extends MeshRender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum VISTYPE
|
||||||
|
{
|
||||||
|
STATIC;
|
||||||
|
UPDATED;
|
||||||
|
FREQUENCIES;
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package audiovis;
|
package audiovis;
|
||||||
|
|
||||||
|
import audiovis.PolygonSpectogram.VISTYPE;
|
||||||
import audiovis.VisShit.CurAudioInfo;
|
import audiovis.VisShit.CurAudioInfo;
|
||||||
import audiovis.dsp.FFT;
|
import audiovis.dsp.FFT;
|
||||||
import flixel.FlxSprite;
|
import flixel.FlxSprite;
|
||||||
|
@ -298,10 +299,3 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum VISTYPE
|
|
||||||
{
|
|
||||||
STATIC;
|
|
||||||
UPDATED;
|
|
||||||
FREQUENCIES;
|
|
||||||
}
|
|
||||||
|
|
|
@ -422,7 +422,7 @@ class ChartingState extends MusicBeatState
|
||||||
|
|
||||||
FlxG.sound.playMusic(Paths.inst(daSong), 0.6);
|
FlxG.sound.playMusic(Paths.inst(daSong), 0.6);
|
||||||
|
|
||||||
var musSpec:SpectogramSprite = new SpectogramSprite(FlxG.sound.music, FlxColor.RED, FlxG.height / 2, Math.floor(FlxG.height / 2));
|
var musSpec:PolygonSpectogram = new PolygonSpectogram(FlxG.sound.music, FlxColor.RED, FlxG.height / 2, Math.floor(FlxG.height / 2));
|
||||||
musSpec.x += 70;
|
musSpec.x += 70;
|
||||||
musSpec.scrollFactor.set();
|
musSpec.scrollFactor.set();
|
||||||
// musSpec.visType = FREQUENCIES;
|
// musSpec.visType = FREQUENCIES;
|
||||||
|
@ -451,7 +451,7 @@ class ChartingState extends MusicBeatState
|
||||||
|
|
||||||
for (index => voc in vocals.members)
|
for (index => voc in vocals.members)
|
||||||
{
|
{
|
||||||
var vocalSpec:SpectogramSprite = new SpectogramSprite(voc, FlxG.random.color(0xFFAAAAAA, FlxColor.WHITE, 100), musSpec.daHeight,
|
var vocalSpec:PolygonSpectogram = new PolygonSpectogram(voc, FlxG.random.color(0xFFAAAAAA, FlxColor.WHITE, 100), musSpec.daHeight,
|
||||||
Math.floor(FlxG.height / 2));
|
Math.floor(FlxG.height / 2));
|
||||||
vocalSpec.x = 70 - (50 * index);
|
vocalSpec.x = 70 - (50 * index);
|
||||||
// vocalSpec.visType = FREQUENCIES;
|
// vocalSpec.visType = FREQUENCIES;
|
||||||
|
@ -467,7 +467,7 @@ class ChartingState extends MusicBeatState
|
||||||
if (index == 1)
|
if (index == 1)
|
||||||
staticVocal.x = gridBG.width;
|
staticVocal.x = gridBG.width;
|
||||||
|
|
||||||
// staticVocal.visType = STATIC;
|
staticVocal.visType = STATIC;
|
||||||
staticSpecGrp.add(staticVocal);
|
staticSpecGrp.add(staticVocal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package rendering;
|
package rendering;
|
||||||
|
|
||||||
import flixel.FlxStrip;
|
import flixel.FlxStrip;
|
||||||
|
import flixel.util.FlxColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Yoinked from AustinEast, thanks hopefully u dont mind me using some of ur good code
|
* Yoinked from AustinEast, thanks hopefully u dont mind me using some of ur good code
|
||||||
|
@ -13,10 +14,10 @@ class MeshRender extends FlxStrip
|
||||||
|
|
||||||
var tri_offset:Int = 0;
|
var tri_offset:Int = 0;
|
||||||
|
|
||||||
public function new(x, y)
|
public function new(x, y, ?col:FlxColor = FlxColor.WHITE)
|
||||||
{
|
{
|
||||||
super(x, y);
|
super(x, y);
|
||||||
makeGraphic(1, 1);
|
makeGraphic(1, 1, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
public inline function start()
|
public inline function start()
|
||||||
|
|
Loading…
Reference in a new issue