mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-25 08:13:45 +00:00
new spectro vis in progress + sustain note charting ed vis
This commit is contained in:
parent
c73e8e1a4d
commit
5c45f7a092
|
@ -23,6 +23,17 @@ class Note extends FlxSprite
|
|||
altNote: false
|
||||
};
|
||||
|
||||
/**
|
||||
* code colors for.... code....
|
||||
* i think goes in order of left to right
|
||||
*
|
||||
* left 0
|
||||
* down 1
|
||||
* up 2
|
||||
* right 3
|
||||
*/
|
||||
public static var codeColors:Array<Int> = [0xFFFF22AA, 0xFF00EEFF, 0xFF00CC00, 0xFFCC1111];
|
||||
|
||||
public var mustPress:Bool = false;
|
||||
public var followsTime:Bool = true; // used if you want the note to follow the time shit!
|
||||
public var canBeHit:Bool = false;
|
||||
|
|
88
source/audiovis/PolygonSpectogram.hx
Normal file
88
source/audiovis/PolygonSpectogram.hx
Normal file
|
@ -0,0 +1,88 @@
|
|||
package audiovis;
|
||||
|
||||
import audiovis.VisShit.CurAudioInfo;
|
||||
import flixel.math.FlxMath;
|
||||
import flixel.math.FlxPoint;
|
||||
import flixel.system.FlxSound;
|
||||
import flixel.util.FlxColor;
|
||||
import lime.utils.Int16Array;
|
||||
import rendering.MeshRender;
|
||||
|
||||
class PolygonSpectogram extends MeshRender
|
||||
{
|
||||
var sampleRate:Int;
|
||||
|
||||
public var vis:VisShit;
|
||||
public var daHeight:Float = FlxG.height;
|
||||
|
||||
var numSamples:Int = 0;
|
||||
var setBuffer:Bool = false;
|
||||
|
||||
public var audioData:Int16Array;
|
||||
public var detail:Float = 1;
|
||||
|
||||
public function new(daSound:FlxSound, ?col:FlxColor = FlxColor.WHITE, ?height:Float = 720, ?detail:Float = 1)
|
||||
{
|
||||
super(0, 0);
|
||||
|
||||
vis = new VisShit(daSound);
|
||||
|
||||
if (height != null)
|
||||
this.daHeight = height;
|
||||
|
||||
this.detail = detail;
|
||||
|
||||
// col not in yet
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates and draws a section of the audio data to a visual waveform
|
||||
* @param start start of the song in milliseconds
|
||||
* @param seconds how long to generate (also in milliseconds)
|
||||
*/
|
||||
public function generateSection(start:Float = 0, seconds:Float = 1):Void
|
||||
{
|
||||
checkAndSetBuffer();
|
||||
|
||||
if (setBuffer)
|
||||
{
|
||||
clear();
|
||||
|
||||
var samplesToGen:Int = Std.int(sampleRate * seconds);
|
||||
// gets which sample to start at
|
||||
var startSample:Int = Std.int(FlxMath.remapToRange(start, 0, vis.snd.length, 0, numSamples));
|
||||
|
||||
var prevPoint:FlxPoint = new FlxPoint();
|
||||
|
||||
for (i in 0...500)
|
||||
{
|
||||
var sampleApprox:Int = Std.int(FlxMath.remapToRange(i, 0, 500, startSample, startSample + samplesToGen));
|
||||
var curAud:CurAudioInfo = VisShit.getCurAud(audioData, sampleApprox);
|
||||
|
||||
var waveAmplitude:Int = 200;
|
||||
|
||||
var coolPoint:FlxPoint = new FlxPoint();
|
||||
coolPoint.x = (curAud.balanced * waveAmplitude / 2 + waveAmplitude / 2);
|
||||
coolPoint.y = (i / 500 * daHeight);
|
||||
|
||||
add_quad(prevPoint.x, prevPoint.y, coolPoint.x, coolPoint.y, prevPoint.x, prevPoint.x + 1, coolPoint.x, coolPoint.y + 1);
|
||||
|
||||
prevPoint.x = coolPoint.x;
|
||||
prevPoint.y = coolPoint.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function checkAndSetBuffer()
|
||||
{
|
||||
vis.checkAndSetBuffer();
|
||||
|
||||
if (vis.setBuffer)
|
||||
{
|
||||
audioData = vis.audioData;
|
||||
sampleRate = vis.sampleRate;
|
||||
setBuffer = vis.setBuffer;
|
||||
numSamples = Std.int(audioData.length / 2);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package audiovis;
|
||||
|
||||
import audiovis.VisShit.CurAudioInfo;
|
||||
import audiovis.dsp.FFT;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.group.FlxGroup;
|
||||
|
@ -101,17 +102,14 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
|
|||
for (i in 0...group.members.length)
|
||||
{
|
||||
var sampleApprox:Int = Std.int(FlxMath.remapToRange(i, 0, group.members.length, startingSample, startingSample + samplesToGen));
|
||||
|
||||
var left = audioData[sampleApprox] / 32767;
|
||||
var right = audioData[sampleApprox + 1] / 32767;
|
||||
var curAud:CurAudioInfo = VisShit.getCurAud(audioData, sampleApprox);
|
||||
|
||||
var swagheight:Int = 200;
|
||||
var balanced = (left + right) / 2;
|
||||
|
||||
group.members[i].x = prevLine.x;
|
||||
group.members[i].y = prevLine.y;
|
||||
|
||||
prevLine.x = (balanced * swagheight / 2 + swagheight / 2) + x;
|
||||
prevLine.x = (curAud.balanced * swagheight / 2 + swagheight / 2) + x;
|
||||
prevLine.y = (i / group.members.length * daHeight) + y;
|
||||
|
||||
var line = FlxVector.get(prevLine.x - group.members[i].x, prevLine.y - group.members[i].y);
|
||||
|
@ -193,15 +191,11 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
|
|||
|
||||
for (sample in remappedShit...remappedShit + (Std.int((44100 * (1 / 144)))))
|
||||
{
|
||||
var left = audioData[i] / 32767;
|
||||
var right = audioData[i + 1] / 32767;
|
||||
|
||||
var balanced = (left + right) / 2;
|
||||
|
||||
var curAud:CurAudioInfo = VisShit.getCurAud(audioData, i);
|
||||
i += 2;
|
||||
|
||||
// var remappedSample:Float = FlxMath.remapToRange(sample, remappedShit, remappedShit + lengthOfShit, 0, lengthOfShit - 1);
|
||||
fftSamples.push(balanced);
|
||||
fftSamples.push(curAud.balanced);
|
||||
}
|
||||
|
||||
var freqShit = vis.funnyFFT(fftSamples);
|
||||
|
@ -281,10 +275,7 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
|
|||
|
||||
for (sample in remappedShit...remappedShit + lengthOfShit)
|
||||
{
|
||||
var left = audioData[i] / 32767;
|
||||
var right = audioData[i + 1] / 32767;
|
||||
|
||||
var balanced = (left + right) / 2;
|
||||
var curAud:CurAudioInfo = VisShit.getCurAud(audioData, i);
|
||||
|
||||
i += 2;
|
||||
|
||||
|
@ -295,7 +286,7 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
|
|||
// group.members[0].y = prevLine.y;
|
||||
|
||||
// FlxSpriteUtil.drawLine(this, prevLine.x, prevLine.y, width * remappedSample, left * height / 2 + height / 2);
|
||||
prevLine.x = (balanced * swagheight / 2 + swagheight / 2) + x;
|
||||
prevLine.x = (curAud.balanced * swagheight / 2 + swagheight / 2) + x;
|
||||
prevLine.y = (Std.int(remappedSample) / lengthOfShit * daHeight) + y;
|
||||
|
||||
var line = FlxVector.get(prevLine.x - group.members[Std.int(remappedSample)].x, prevLine.y - group.members[Std.int(remappedSample)].y);
|
||||
|
|
|
@ -105,6 +105,17 @@ class VisShit
|
|||
return freqOutput;
|
||||
}
|
||||
|
||||
public static function getCurAud(aud:Int16Array, index:Int):CurAudioInfo
|
||||
{
|
||||
var left = aud[index] / 32767;
|
||||
var right = aud[index + 2] / 32767;
|
||||
var balanced = (left + right) / 2;
|
||||
|
||||
var funny:CurAudioInfo = {left: left, right: right, balanced: balanced};
|
||||
|
||||
return funny;
|
||||
}
|
||||
|
||||
public function checkAndSetBuffer()
|
||||
{
|
||||
if (snd != null && snd.playing)
|
||||
|
@ -129,3 +140,10 @@ class VisShit
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef CurAudioInfo =
|
||||
{
|
||||
var left:Float;
|
||||
var right:Float;
|
||||
var balanced:Float;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import Note.NoteData;
|
|||
import Section.SwagSection;
|
||||
import SongLoad.SwagSong;
|
||||
import audiovis.ABotVis;
|
||||
import audiovis.PolygonSpectogram;
|
||||
import audiovis.SpectogramSprite;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.addons.display.FlxGridOverlay;
|
||||
|
@ -86,7 +87,7 @@ class ChartingState extends MusicBeatState
|
|||
|
||||
var playheadTest:FlxSprite;
|
||||
|
||||
var staticSpecGrp:FlxTypedGroup<SpectogramSprite>;
|
||||
var staticSpecGrp:FlxTypedGroup<PolygonSpectogram>;
|
||||
|
||||
override function create()
|
||||
{
|
||||
|
@ -442,7 +443,7 @@ class ChartingState extends MusicBeatState
|
|||
// vocals = new FlxSound().loadEmbedded(Paths.voices(daSong));
|
||||
// FlxG.sound.list.add(vocals);
|
||||
|
||||
staticSpecGrp = new FlxTypedGroup<SpectogramSprite>();
|
||||
staticSpecGrp = new FlxTypedGroup<PolygonSpectogram>();
|
||||
add(staticSpecGrp);
|
||||
|
||||
var aBoy:ABotVis = new ABotVis(FlxG.sound.music);
|
||||
|
@ -459,14 +460,14 @@ class ChartingState extends MusicBeatState
|
|||
vocalSpec.scrollFactor.set();
|
||||
add(vocalSpec);
|
||||
|
||||
var staticVocal:SpectogramSprite = new SpectogramSprite(voc, FlxG.random.color(0xFFAAAAAA, FlxColor.WHITE, 100), GRID_SIZE * 16, GRID_SIZE * 8);
|
||||
var staticVocal:PolygonSpectogram = new PolygonSpectogram(voc, FlxG.random.color(0xFFAAAAAA, FlxColor.WHITE, 100), GRID_SIZE * 16, 0.5);
|
||||
if (index == 0)
|
||||
staticVocal.x -= 150;
|
||||
|
||||
if (index == 1)
|
||||
staticVocal.x = gridBG.width;
|
||||
|
||||
staticVocal.visType = STATIC;
|
||||
// staticVocal.visType = STATIC;
|
||||
staticSpecGrp.add(staticVocal);
|
||||
}
|
||||
|
||||
|
@ -788,6 +789,7 @@ class ChartingState extends MusicBeatState
|
|||
{
|
||||
var minusStuff:Float = FlxG.mouse.y - getYfromStrum(curSelectedNote.strumTime);
|
||||
minusStuff -= GRID_SIZE;
|
||||
minusStuff += GRID_SIZE / 2;
|
||||
minusStuff = Math.floor(minusStuff / GRID_SIZE) * GRID_SIZE;
|
||||
minusStuff = FlxMath.remapToRange(minusStuff, 0, 40, 0, Conductor.stepCrochet);
|
||||
|
||||
|
@ -1189,19 +1191,7 @@ class ChartingState extends MusicBeatState
|
|||
{
|
||||
for (notes in sideSection.sectionNotes)
|
||||
{
|
||||
var col:Int = switch (notes.noteData % 4)
|
||||
{
|
||||
case 0:
|
||||
0xFFFF22AA;
|
||||
case 1:
|
||||
0xFF00EEFF;
|
||||
case 2:
|
||||
0xFF00CC00;
|
||||
case 3:
|
||||
0xFFCC1111;
|
||||
default:
|
||||
0xFFFF0000;
|
||||
}
|
||||
var col:Int = Note.codeColors[notes.noteData % 4];
|
||||
|
||||
var noteFlip:Int = (sideSection.mustHitSection ? 1 : -1);
|
||||
var noteX:Float = 5 * (((notes.noteData - 4) * noteFlip) + 4);
|
||||
|
@ -1261,6 +1251,8 @@ class ChartingState extends MusicBeatState
|
|||
{
|
||||
var sustainVis:FlxSprite = new FlxSprite(note.x + (GRID_SIZE / 2),
|
||||
note.y + GRID_SIZE).makeGraphic(8, Math.floor(FlxMath.remapToRange(daSus, 0, Conductor.stepCrochet * 16, 0, gridBG.height)));
|
||||
sustainVis.x -= sustainVis.width / 2;
|
||||
sustainVis.color = Note.codeColors[note.data.noteData % 4];
|
||||
curRenderedSustains.add(sustainVis);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue