Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Xna.Framework;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace OMG
- {
- public static class StepData
- {
- //LOS DATOS
- public static string dType;
- public static int dTracks;
- public static int dMetaData;
- public static List<int> dData;
- //EL SPLIT
- public static List<int> sBlocks;
- public static List<float> sStepTime;
- public static List<float> sBpm;
- public static List<float> sMystery; //ni idea porque está en float
- public static List<float> sDelay;
- public static List<bool> sFreeze;
- public static List<float> sSpeed;
- public static List<float> sBeatSplit;
- public static List<int> sMeasure;
- public static List<int> sSmooth;
- public static List<float> sRows;
- //LAS NOTAS
- public static List<float[]> sNotes;
- public static void _CLEAN()
- {
- dType = "";
- dTracks = 5;
- dMetaData = 2;
- dData = new List<int>();
- sBlocks = new List<int>();
- sStepTime = new List<float>();
- sBpm = new List<float>();
- sMystery = new List<float>();
- sDelay = new List<float>();
- sFreeze = new List<bool>();
- sSpeed = new List<float>();
- sBeatSplit = new List<float>();
- sMeasure = new List<int>();
- sSmooth = new List<int>();
- sRows = new List<float>();
- sNotes = new List<float[]>();
- }
- public static void _PARSE()
- {
- int total = 0;//en que espacio voy
- dTracks = Convert.ToInt32(Reader.FILEDATA[2].Substring(0, 2), 16);
- dMetaData = Convert.ToInt32(Reader.FILEDATA[4].Substring(0, 2), 16);
- total = 6; //independiente del step, siempre el metadata empieza en 6
- for (int i = 0; i < dMetaData; i++)
- dData.Add(Convert.ToInt32(Reader.FILEDATA[total + i * 2].Substring(0, 2), 16));
- total += (dMetaData * 2); //cada metadata va acompañado de 1 bloque
- total += 2; //espaciado entre splits
- _MAKEDEC(); //PENDIENTE
- bool DATA = true;
- float temp = 0;
- float space = 60f;
- for (int i = total; i < Reader.FILEDATA.Count; i++)
- {
- if (DATA)
- {
- sBlocks.Add(Convert.ToInt32(Reader.FILEDATA[i].Substring(0, 2), 16));
- sStepTime.Add(_GETFLOAT(Reader.FILEDATA[i + 1]));
- sBpm.Add(_GETFLOAT(Reader.FILEDATA[i + 2]));
- sMystery.Add(_GETFLOAT(Reader.FILEDATA[i + 3]));
- if (sMystery[sMystery.Count - 1].ToString() == "NaN")
- sMystery[sMystery.Count - 1] = 0;
- sDelay.Add(_GETFLOAT(Reader.FILEDATA[i + 4]));
- if (sDelay[sDelay.Count - 1].ToString() == "NaN" || sDelay[sDelay.Count - 1].ToString() == "NeuN")
- sDelay[sDelay.Count - 1] = 0;
- sFreeze.Add(_GETFLOAT(Reader.FILEDATA[i + 5]) < 0 ? true : false);
- sSpeed.Add(_GETFLOAT(Reader.FILEDATA[i + 5]));
- sBeatSplit.Add(Convert.ToInt32(Reader.FILEDATA[i + 6].Substring(0, 2), 16));
- sMeasure.Add(Convert.ToInt32(Reader.FILEDATA[i + 6].Substring(2, 2), 16));
- sSmooth.Add(Convert.ToInt32(Reader.FILEDATA[i + 6].Substring(4, 2), 16));
- sRows.Add(_ROWS(Reader.FILEDATA[i + 8]));
- i += 8;
- DATA = false;
- }
- else
- {
- for (int r = 0; r < sRows[sRows.Count-1]; r++)
- {
- temp = ((space / (sBpm[sBpm.Count - 1] / space) / sBeatSplit[sBeatSplit.Count - 1]) * (float)r) + (sStepTime[sStepTime.Count - 1] / 16.66666667f);
- if (Reader.FILEDATA[i + r].Substring(0, 2) != "80")
- {
- for (int t = 0; t < dTracks; t++)
- {
- if (Convert.ToInt32(Reader.FILEDATA[i + r + t].Substring(0, 2), 16) == 0)
- continue; //empty
- //COMO ES LA WEÁ
- //TAPNOTE, MÁSCARA, PLAYER, UNKNOW, SPLIT, TRACK, Y, asd
- sNotes.Add(new float[] { Convert.ToInt32(Reader.FILEDATA[i + r + t].Substring(0, 2), 16)
- , Convert.ToInt32(Reader.FILEDATA[i + r + t].Substring(2, 2), 16)
- , Convert.ToInt32(Reader.FILEDATA[i + r + t].Substring(4, 2), 16)
- , Convert.ToInt32(Reader.FILEDATA[i + r + t].Substring(6, 2), 16)
- , sBlocks.Count - 1
- , t
- , temp
- , 0
- });
- }
- i += dTracks - 1;
- }
- }
- i += (int)sRows[sRows.Count - 1] + 1; //1 de espaciado
- DATA = true;
- }
- }
- for (int i = 0; i < sNotes.Count; i++)
- {
- switch (sNotes[i][0].ToString())
- {
- case "35": //fake tap
- case "55": //fake head
- case "59": //fake body
- case "63": //fake tail
- sNotes.RemoveAt(i);
- i--;
- break;
- }
- //if (sNotes[i][1] != 3)
- //{
- // sNotes.RemoveAt(i);
- // i--;
- //}
- }
- }
- static int _ROWS(string hex)
- {
- int num1,num2, rows=0;
- num1 = Convert.ToInt32(hex.Substring(0, 2), 16);
- num2 = Convert.ToInt32(hex.Substring(2, 2), 16);
- rows = num1 + num2 * 256;
- return rows;
- }
- static int[] decim = new int[20];
- static float[] bases = new float[20];
- static float[] mult0 = new float[20];
- static float[] mult1 = new float[20];
- static float[] mult2 =
- new float[20];
- static void _MAKEDEC()
- {
- decim[0] = 58;
- bases[0] = 0.00048828125f;
- mult0[0] = 16777216;
- mult1[0] = 65536;
- mult2[0] = 262144f;
- for (int i = 1; i < decim.Length; i++)
- {
- decim[i] = decim[i - 1] + 1;
- bases[i] = bases[i - 1] * 4;
- mult0[i] = mult0[i - 1] / 4;
- mult1[i] = mult1[i - 1] / 4;
- mult2[i] = mult2[i - 1] / 4;
- }
- }
- static float _GETFLOAT(String hex)
- {
- float convert = 0;
- float based = 0;
- float[] mult = new float[3];
- List<int> dec = new List<int>();
- for (int i = 0; i < hex.Length; i += 2)
- dec.Add(Convert.ToInt32(hex.Substring(i, 2), 16));
- int fix = 1;
- for (int i = 0; i < decim.Length; i++)
- if ((dec[3] == decim[i]) || (dec[3] == (decim[i] + 128)))
- {
- based = bases[i];
- mult[0] = mult0[i];
- mult[1] = mult1[i];
- mult[2] = mult2[i];
- }
- int divisor0 = 1024;
- int divisor1 = 1024;
- int divisor2 = 1;
- if (dec[2] >= 128)
- {
- based = 0;
- divisor0 = 512;
- divisor1 = 512;
- divisor2 = 2;
- }
- if (dec[3] >= 186)
- fix = -1;
- convert =
- based +
- (dec[0] / (mult[0] * divisor0)) +
- (dec[1] / (mult[1] * divisor1)) +
- (dec[2] / (mult[2] / divisor2));
- convert = (float)(Math.Round((convert * fix), 3));
- return convert;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement