From a721e495076043a06180c04ec20c55d680f214b2 Mon Sep 17 00:00:00 2001 From: "born a rick, raised a morty, died a jerry" Date: Sat, 24 Nov 2018 18:20:10 -0500 Subject: [PATCH] scale cd graph functions to rate --- src/Steps.cpp | 13 +++++++------ src/Steps.h | 6 ++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Steps.cpp b/src/Steps.cpp index 7cad3e6fe5..07583e6223 100644 --- a/src/Steps.cpp +++ b/src/Steps.cpp @@ -688,7 +688,7 @@ Steps::SetCachedRadarValues(const RadarValues& rv) } vector -Steps::GetNPSVector(NoteData& nd, vector nerv, vector etaner) +Steps::GetNPSVector(NoteData& nd, vector nerv, vector etaner, float rate) { vector doot(static_cast(etaner.back())); int notecounter = 0; @@ -696,7 +696,7 @@ Steps::GetNPSVector(NoteData& nd, vector nerv, vector etaner) int curinterval = 0; for (size_t i = 0; i < nerv.size(); ++i) { - curinterval = static_cast(etaner[i]); + curinterval = static_cast(etaner[i] / rate); if (curinterval > lastinterval) { doot[lastinterval] = notecounter; notecounter = 0; @@ -714,7 +714,7 @@ Steps::GetNPSVector(NoteData& nd, vector nerv, vector etaner) } vector -Steps::GetCNPSVector(NoteData& nd, vector nerv, vector etaner, int chordsize) +Steps::GetCNPSVector(NoteData& nd, vector nerv, vector etaner, int chordsize, float rate) { vector doot(static_cast(etaner.back())); int chordnotecounter = 0; // number of NOTES inside chords of this size, so 5 jumps = 10 notes, 3 hands = 9 notes, etc @@ -902,21 +902,22 @@ class LunaSteps : public Luna } static int GetCDGraphVectors(T* p, lua_State* L) { + float rate = FArg(1); auto nd = p->GetNoteData(); if (nd.IsEmpty()) return 0; const vector& nerv = nd.BuildAndGetNerv(); const vector& etaner = - p->GetTimingData()->BuildAndGetEtaner(nerv); + p->GetTimingData()->BuildAndGetEtaner(nerv); // directly using CreateTableFromArray(p->GetNPSVector(nd, nerv, etaner), L) produced tables full of 0 values for ???? reason -mina - vector scroot = p->GetNPSVector(nd, nerv, etaner); + vector scroot = p->GetNPSVector(nd, nerv, etaner, rate); lua_newtable(L); LuaHelpers::CreateTableFromArray(scroot, L); lua_rawseti(L, -2, 1); for (int i = 1; i < nd.GetNumTracks(); ++i) { - scroot = p->GetCNPSVector(nd, nerv, etaner, i + 1); // sort of confusing: the luatable pos/chordsize are i + 1 + scroot = p->GetCNPSVector(nd, nerv, etaner, i + 1, rate);// sort of confusing: the luatable pos/chordsize are i + 1 LuaHelpers::CreateTableFromArray(scroot, L); // but we're iterating over tracks which are 0 indexed lua_rawseti(L, -2, i + 1); // so jumps are position 2 and 2 notes each when i = 1 -mina } diff --git a/src/Steps.h b/src/Steps.h index 2a4d39aa0d..e4af8febfa 100644 --- a/src/Steps.h +++ b/src/Steps.h @@ -142,7 +142,8 @@ class Steps // self exaplanatory -mina vector GetNPSVector(NoteData& nd, vector nerv, - vector etaner); + vector etaner, + float rate); // takes size of chord and counts how many -NOTES- are in // chords of that exact size (this functionally means // multiplying chord counter by chord size) in a row -mina @@ -150,7 +151,8 @@ class Steps vector GetCNPSVector(NoteData& nd, vector nerv, vector etaner, - int chordsize); + int chordsize, + float rate); float PredictMeter() const { return 1.f; } unsigned GetHash() const;