Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix interpolating rate values, set ReTrigger reset range toggle #512

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Audio/src/DSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void GateDSP::SetLength(double length)
void GateDSP::SetGating(float gating)
{
gating = Math::Clamp(gating, 0.f, 1.f);
float flength = (float)m_length;
auto flength = (float)m_length;
m_gating = gating;
m_halfway = (uint32)(flength * gating);
const float fadeDuration = Math::Min(0.05f, gating * 0.5f);
Expand Down
2 changes: 1 addition & 1 deletion Beatmap/include/Beatmap/KShootMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ class KShootMap

};

bool ParseKShootCourse(BinaryStream& input, Map<String, String>& settings, Vector<String>& charts);
bool ParseKShootCourse(BinaryStream& input, Map<String, String>& settings, Vector<String>& charts);
10 changes: 8 additions & 2 deletions Beatmap/src/AudioEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ EffectDuration EffectDuration::Lerp(const EffectDuration &lhs, const EffectDurat
{
assert(rhs.type == lhs.type);
if (lhs.type == Type::Rate)
return lhs.rate + (lhs.rate - rhs.rate) * time;
{
// Assumes rate is never above 1
float interp = (1 / rhs.rate) * time;
return interp == 0 ? lhs.rate : fmin(1.f, 1 / interp);
}
else
return (int32)(lhs.duration + (float)(lhs.duration - rhs.duration) * time);
{
return (int32) (lhs.duration + (float) (lhs.duration - rhs.duration) * time);
}
}
uint32 EffectDuration::Absolute(double noteDuration)
{
Expand Down
28 changes: 13 additions & 15 deletions Beatmap/src/BeatmapFromKSH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ AudioEffect ParseCustomEffect(const KShootEffectDefinition &def, Vector<String>
}

return effect;
};
}

bool Beatmap::m_ProcessKShootMap(BinaryStream &input, bool metadataOnly)
{
Expand All @@ -427,19 +427,19 @@ bool Beatmap::m_ProcessKShootMap(BinaryStream &input, bool metadataOnly)
}

// Add all the custom effect types
for (auto it = kshootMap.fxDefines.begin(); it != kshootMap.fxDefines.end(); it++)
for (auto & fxDefine : kshootMap.fxDefines)
{
EffectType type = effectTypeMap.FindOrAddEffectType(it->first);
EffectType type = effectTypeMap.FindOrAddEffectType(fxDefine.first);
if (m_customEffects.Contains(type))
continue;
m_customEffects.Add(type, ParseCustomEffect(it->second, m_switchablePaths));
m_customEffects.Add(type, ParseCustomEffect(fxDefine.second, m_switchablePaths));
}
for (auto it = kshootMap.filterDefines.begin(); it != kshootMap.filterDefines.end(); it++)
for (auto & filterDefine : kshootMap.filterDefines)
{
EffectType type = filterTypeMap.FindOrAddEffectType(it->first);
EffectType type = filterTypeMap.FindOrAddEffectType(filterDefine.first);
if (m_customFilters.Contains(type))
continue;
m_customFilters.Add(type, ParseCustomEffect(it->second, m_switchablePaths));
m_customFilters.Add(type, ParseCustomEffect(filterDefine.second, m_switchablePaths));
}

auto ParseFilterType = [&](const String &str) {
Expand Down Expand Up @@ -965,7 +965,7 @@ bool Beatmap::m_ProcessKShootMap(BinaryStream &input, bool metadataOnly)
}
else
{
Logf("[KSH]Unkown map parameter at %d:%d: %s", Logger::Severity::Warning, it.GetTime().block, it.GetTime().tick, p.first);
Logf("[KSH] Unknown map parameter at %d:%d: %s", Logger::Severity::Warning, it.GetTime().block, it.GetTime().tick, p.first);
}
tickSettingIndex++;
}
Expand Down Expand Up @@ -1139,7 +1139,7 @@ bool Beatmap::m_ProcessKShootMap(BinaryStream &input, bool metadataOnly)
}
else
{
// Hold are always on a high enough snap to make suere they are seperate when needed
// Hold are always on a high enough snap to make sure they are separate when needed
if (c == '2')
{
state->fineSnap = false;
Expand Down Expand Up @@ -1364,13 +1364,11 @@ bool Beatmap::m_ProcessKShootMap(BinaryStream &input, bool metadataOnly)
currentTick += (tickResolution * 4 * lastTimingPoint->numerator / lastTimingPoint->denominator) / block.ticks.size();
}

for (int i = 0; i < sizeof(firstControlPoints) / sizeof(ZoomControlPoint *); i++)
for (auto point : firstControlPoints)
{
ZoomControlPoint *point = firstControlPoints[i];
if (!point)
continue;
if (!point) continue;

ZoomControlPoint *dup = new ZoomControlPoint();
auto *dup = new ZoomControlPoint();
dup->index = point->index;
dup->zoom = point->zoom;
dup->time = INT32_MIN;
Expand All @@ -1379,7 +1377,7 @@ bool Beatmap::m_ProcessKShootMap(BinaryStream &input, bool metadataOnly)
}

//Add chart end event
EventObjectState *evt = new EventObjectState();
auto *evt = new EventObjectState();
evt->time = lastMapTime + 2000;
evt->key = EventKey::ChartEnd;
m_objectStates.Add(*evt);
Expand Down
6 changes: 3 additions & 3 deletions Beatmap/src/KShootMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ bool KShootMap::Init(BinaryStream& input, bool metadataOnly)

// Split up parameters
Vector<String> paramsString = strings[2].Explode(";");
for(auto param : paramsString)
for(const auto& param : paramsString)
{
String k, v;
if(!param.Split("=", &k, &v))
Expand All @@ -295,7 +295,7 @@ bool KShootMap::Init(BinaryStream& input, bool metadataOnly)
}
else
{
Logf("Unkown define statement in ksh @%d: \"%s\"", Logger::Severity::Warning, lineNumber, line);
Logf("Unknown define statement in ksh @%d: \"%s\"", Logger::Severity::Warning, lineNumber, line);
}
}
else if(line.Split("=", &k, &v))
Expand Down Expand Up @@ -406,4 +406,4 @@ float KShootMap::TranslateLaserChar(char c) const
}
return (float)index[0] / (float)(laserCharacters.size()-1);
}
const char* KShootMap::c_sep = "--";
const char* KShootMap::c_sep = "--";
4 changes: 2 additions & 2 deletions Main/include/Audio/AudioPlayback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,5 @@ class AudioPlayback : Unique
HoldObjectState *m_currentHoldEffects[2] = {nullptr};
float m_effectMix[2] = {0.0f};

bool m_SkipEffectIfInputIsZero();
};
bool m_SkipEffectIfInputIsZero(float input);
};
42 changes: 23 additions & 19 deletions Main/src/Audio/AudioPlayback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ bool AudioPlayback::Init(class BeatmapPlayback &playback, const String &mapRootP
return true;
}


auto switchablePaths = m_beatmap->GetSwitchablePaths();

// Load switchable audio tracks
for (auto it = switchablePaths.begin(); it != switchablePaths.end(); ++it)
for (auto & switchablePath : switchablePaths)
{
audioPath = Path::Normalize(m_beatmapRootPath + Path::sep + *it);
audioPath = Path::Normalize(m_beatmapRootPath + Path::sep + switchablePath);
audioPath.TrimBack(' ');

SwitchableAudio switchable;
Expand Down Expand Up @@ -125,9 +124,11 @@ void AudioPlayback::Play()
m_music->Play();
if (m_fxtrack)
m_fxtrack->Play();
for (auto it = m_switchables.begin(); it != m_switchables.end(); ++it)
if (it->m_audio)
it->m_audio->Play();
for (auto & m_switchable : m_switchables)
{
if (m_switchable.m_audio)
m_switchable.m_audio->Play();
}

m_paused = false;
}
Expand Down Expand Up @@ -251,15 +252,15 @@ void AudioPlayback::SetLaserEffect(EffectType type)
m_laserEffect = m_beatmap->GetFilter(type);
}
}
bool AudioPlayback::m_SkipEffectIfInputIsZero()
bool AudioPlayback::m_SkipEffectIfInputIsZero(float input)
{
return m_laserEffect.type == EffectType::PeakingFilter || m_laserEffect.type == EffectType::HighPassFilter
return input == 0 && (m_laserEffect.type == EffectType::PeakingFilter || m_laserEffect.type == EffectType::HighPassFilter
|| m_laserEffect.type == EffectType::LowPassFilter || m_laserEffect.type == EffectType::PitchShift
|| m_laserEffect.type == EffectType::Bitcrush;
|| m_laserEffect.type == EffectType::Bitcrush);
}
void AudioPlayback::SetLaserFilterInput(float input, bool active)
{
if (m_laserEffect.type != EffectType::None && (active && (input != 0.0f || !m_SkipEffectIfInputIsZero())))
if (m_laserEffect.type != EffectType::None && active && !m_SkipEffectIfInputIsZero(input))
{
if (m_laserEffect.type == EffectType::SwitchAudio)
{
Expand All @@ -284,9 +285,8 @@ void AudioPlayback::SetLaserFilterInput(float input, bool active)

Ref<AudioStream> audioTrack = m_GetDSPTrack();

m_laserDSP = m_laserEffect.CreateDSP(m_playback->GetCurrentTimingPoint(),
GetLaserFilterInput(),
audioTrack->GetAudioSampleRate());
m_laserDSP = m_laserEffect.CreateDSP(m_playback->GetCurrentTimingPoint(),GetLaserFilterInput(),
audioTrack->GetAudioSampleRate());
if (!m_laserDSP)
{
Logf("Failed to create laser DSP with type %d", Logger::Severity::Warning, m_laserEffect.type);
Expand Down Expand Up @@ -415,9 +415,11 @@ void AudioPlayback::SetPlaybackSpeed(float speed)
m_music->PlaybackSpeed = speed;
if (m_fxtrack)
m_fxtrack->PlaybackSpeed = speed;
for (auto it = m_switchables.begin(); it != m_switchables.end(); ++it)
if (it->m_audio)
it->m_audio->PlaybackSpeed = speed;
for (auto & m_switchable : m_switchables)
{
if (m_switchable.m_audio)
m_switchable.m_audio->PlaybackSpeed = speed;
}
}
float AudioPlayback::GetPlaybackSpeed() const
{
Expand All @@ -428,9 +430,11 @@ void AudioPlayback::SetVolume(float volume)
m_music->SetVolume(volume);
if (m_fxtrack)
m_fxtrack->SetVolume(volume);
for (auto it = m_switchables.begin(); it != m_switchables.end(); ++it)
if (it->m_audio)
it->m_audio->SetVolume(volume);
for (auto & m_switchable : m_switchables)
{
if (m_switchable.m_audio)
m_switchable.m_audio->SetVolume(volume);
}
}
void AudioPlayback::m_CleanupDSP(DSP *&ptr)
{
Expand Down
5 changes: 2 additions & 3 deletions Main/src/Audio/GameAudioEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ DSP *GameAudioEffect::CreateDSP(const TimingPoint &tp, float filterInput, uint32
case EffectType::LowPassFilter:
case EffectType::HighPassFilter:
{
// Don't set anthing for biquad Filters
// Don't set anything for biquad Filters
BQFDSP *bqfDSP = new BQFDSP(sampleRate);
ret = bqfDSP;
break;
Expand Down Expand Up @@ -88,8 +88,7 @@ DSP *GameAudioEffect::CreateDSP(const TimingPoint &tp, float filterInput, uint32
{
FlangerDSP *fl = new FlangerDSP(sampleRate);
fl->SetLength(actualLength);
fl->SetDelayRange(abs(flanger.offset.Sample(filterInput)),
abs(flanger.depth.Sample(filterInput)));
fl->SetDelayRange(abs(flanger.offset.Sample(filterInput)), abs(flanger.depth.Sample(filterInput)));
fl->SetFeedback(flanger.feedback.Sample(filterInput));
fl->SetStereoWidth(flanger.stereoWidth.Sample(filterInput));
fl->SetVolume(flanger.volume.Sample(filterInput));
Expand Down