Skip to content

Commit

Permalink
scale cd graph functions to rate
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Nov 24, 2018
1 parent 7aaf002 commit a721e49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/Steps.cpp
Expand Up @@ -688,15 +688,15 @@ Steps::SetCachedRadarValues(const RadarValues& rv)
}

vector<int>
Steps::GetNPSVector(NoteData& nd, vector<int> nerv, vector<float> etaner)
Steps::GetNPSVector(NoteData& nd, vector<int> nerv, vector<float> etaner, float rate)
{
vector<int> doot(static_cast<int>(etaner.back()));
int notecounter = 0;
int lastinterval = 0;
int curinterval = 0;

for (size_t i = 0; i < nerv.size(); ++i) {
curinterval = static_cast<int>(etaner[i]);
curinterval = static_cast<int>(etaner[i] / rate);
if (curinterval > lastinterval) {
doot[lastinterval] = notecounter;
notecounter = 0;
Expand All @@ -714,7 +714,7 @@ Steps::GetNPSVector(NoteData& nd, vector<int> nerv, vector<float> etaner)
}

vector<int>
Steps::GetCNPSVector(NoteData& nd, vector<int> nerv, vector<float> etaner, int chordsize)
Steps::GetCNPSVector(NoteData& nd, vector<int> nerv, vector<float> etaner, int chordsize, float rate)
{
vector<int> doot(static_cast<int>(etaner.back()));
int chordnotecounter = 0; // number of NOTES inside chords of this size, so 5 jumps = 10 notes, 3 hands = 9 notes, etc
Expand Down Expand Up @@ -902,21 +902,22 @@ class LunaSteps : public Luna<Steps>
}
static int GetCDGraphVectors(T* p, lua_State* L)
{
float rate = FArg(1);
auto nd = p->GetNoteData();
if (nd.IsEmpty())
return 0;
const vector<int>& nerv = nd.BuildAndGetNerv();
const vector<float>& 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<int> scroot = p->GetNPSVector(nd, nerv, etaner);
vector<int> 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
}
Expand Down
6 changes: 4 additions & 2 deletions src/Steps.h
Expand Up @@ -142,15 +142,17 @@ class Steps
// self exaplanatory -mina
vector<int> GetNPSVector(NoteData& nd,
vector<int> nerv,
vector<float> etaner);
vector<float> 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
// (jumps won't count as hands, etc)
vector<int> GetCNPSVector(NoteData& nd,
vector<int> nerv,
vector<float> etaner,
int chordsize);
int chordsize,
float rate);
float PredictMeter() const { return 1.f; }

unsigned GetHash() const;
Expand Down

0 comments on commit a721e49

Please sign in to comment.