Skip to content

Commit

Permalink
fixup! Restored legacy offset of CAudioStream::streamInternal
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDMC committed Oct 12, 2024
1 parent b083a18 commit f015afb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
12 changes: 6 additions & 6 deletions cleo_plugins/Audio/CAudioStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void CAudioStream::SetVolume(float value, float transitionTime)
if (transitionTime <= 0.0)
volume = value; // instant
else
volumeTransitionStep = (volumeTarget - volume) / (1000.0 * transitionTime);
volumeTransitionStep = (volumeTarget - volume) / (1000.0f * transitionTime);
}

float CAudioStream::GetVolume() const
Expand All @@ -132,7 +132,7 @@ void CAudioStream::SetSpeed(float value, float transitionTime)
if (transitionTime <= 0.0)
speed = value; // instant
else
speedTransitionStep = (speedTarget - speed) / (1000.0 * transitionTime);
speedTransitionStep = (speedTarget - speed) / (1000.0f * transitionTime);
}

float CAudioStream::GetSpeed() const
Expand Down Expand Up @@ -164,11 +164,11 @@ void CAudioStream::UpdateVolume()
if (volume != volumeTarget)
{
auto timeDelta = CTimer::m_snTimeInMillisecondsNonClipped - CTimer::m_snPreviousTimeInMillisecondsNonClipped;
volume += volumeTransitionStep * (double)timeDelta; // animate the transition
volume += volumeTransitionStep * (float)timeDelta; // animate the transition

// check progress
auto remaining = volumeTarget - volume;
remaining *= (volumeTransitionStep > 0.0) ? 1.0 : -1.0;
remaining *= (volumeTransitionStep > 0.0f) ? 1.0f : -1.0f;
if (remaining < 0.0) // overshoot
{
volume = volumeTarget;
Expand All @@ -191,11 +191,11 @@ void CAudioStream::UpdateSpeed()
if (speed != speedTarget)
{
auto timeDelta = CTimer::m_snTimeInMillisecondsNonClipped - CTimer::m_snPreviousTimeInMillisecondsNonClipped;
speed += speedTransitionStep * (double)timeDelta; // animate the transition
speed += speedTransitionStep * (float)timeDelta; // animate the transition

// check progress
auto remaining = speedTarget - speed;
remaining *= (speedTransitionStep > 0.0) ? 1.0 : -1.0;
remaining *= (speedTransitionStep > 0.0f) ? 1.0f : -1.0f;
if (remaining < 0.0) // overshoot
{
speed = speedTarget; // done
Expand Down
21 changes: 7 additions & 14 deletions cleo_plugins/Audio/CAudioStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@

namespace CLEO
{
// in CLEO4 CAudioStream was extending VInjectible
// this dummy parent keeps offset of CAudioStream::streamInternal unchanged
class Dummy
{
virtual void dummy() {};
};

class CAudioStream : Dummy
class CAudioStream
{
public:
enum eStreamState
Expand Down Expand Up @@ -65,14 +58,14 @@ namespace CLEO
eStreamType type = eStreamType::SoundEffect;
bool ok = false;
float rate = 44100.0f; // file's sampling rate
double speed = 1.0f;
double volume = 1.0f;
float speed = 1.0f;
float volume = 1.0f;

// transitions
double volumeTarget = 1.0f;
double volumeTransitionStep = 1.0f;
double speedTarget = 1.0f;
double speedTransitionStep = 1.0f;
float volumeTarget = 1.0f;
float volumeTransitionStep = 1.0f;
float speedTarget = 1.0f;
float speedTransitionStep = 1.0f;

CAudioStream() = default;
CAudioStream(const CAudioStream&) = delete; // no copying!
Expand Down

0 comments on commit f015afb

Please sign in to comment.