Skip to content

Commit

Permalink
Add support for KSH 'Standard BPM'
Browse files Browse the repository at this point in the history
  • Loading branch information
Drewol committed May 18, 2021
1 parent b75c04d commit df7b3b5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
4 changes: 4 additions & 0 deletions Beatmap/include/Beatmap/Beatmap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ struct BeatmapSettings
float slamVolume = 1.0f;
float laserEffectMix = 1.0f;
float musicVolume = 1.0f;

// BPM Override for mmod calculation
float speedBpm = -1.0f;

EffectType laserEffectType = EffectType::PeakingFilter;
};

Expand Down
4 changes: 4 additions & 0 deletions Beatmap/src/BeatmapFromKSH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,10 @@ bool Beatmap::m_ProcessKShootMap(BinaryStream &input, bool metadataOnly)
{
m_settings.musicVolume = (float)atoi(*s.second) / 100.0f;
}
else if (s.first == "to")
{
m_settings.speedBpm = atof(*s.second);
}
}

// Temporary map for timing points
Expand Down
38 changes: 23 additions & 15 deletions Main/src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,28 +316,36 @@ class Game_Impl : public Game
MapTime largestMT = -1;
double useBPM = -1;
double lastBPM = -1;
for (TimingPoint* tp : timingPoints)

if (mapSettings.speedBpm > 0.0f)
{
useBPM = mapSettings.speedBpm;
}
else
{
double thisBPM = tp->GetBPM();
if (!bpmDurations.count(lastBPM))
for (TimingPoint* tp : timingPoints)
{
bpmDurations[lastBPM] = 0;
double thisBPM = tp->GetBPM();
if (!bpmDurations.count(lastBPM))
{
bpmDurations[lastBPM] = 0;
}
MapTime timeSinceLastTP = tp->time - lastMT;
bpmDurations[lastBPM] += timeSinceLastTP;
if (bpmDurations[lastBPM] > largestMT)
{
useBPM = lastBPM;
largestMT = bpmDurations[lastBPM];
}
lastMT = tp->time;
lastBPM = thisBPM;
}
MapTime timeSinceLastTP = tp->time - lastMT;
bpmDurations[lastBPM] += timeSinceLastTP;
bpmDurations[lastBPM] += m_endTime - lastMT;

if (bpmDurations[lastBPM] > largestMT)
{
useBPM = lastBPM;
largestMT = bpmDurations[lastBPM];
}
lastMT = tp->time;
lastBPM = thisBPM;
}
bpmDurations[lastBPM] += m_endTime - lastMT;

if (bpmDurations[lastBPM] > largestMT)
{
useBPM = lastBPM;
}

m_hispeed = m_modSpeed / useBPM;
Expand Down

0 comments on commit df7b3b5

Please sign in to comment.