diff options
author | Jörg Müller <nexyon@gmail.com> | 2020-12-24 12:39:28 +0300 |
---|---|---|
committer | Jörg Müller <nexyon@gmail.com> | 2020-12-24 12:42:16 +0300 |
commit | 83ad35cb9c41c7e7df5ff239e5c2232742f4d5b6 (patch) | |
tree | 52848e205ace38234c09d55df6bfaa93fca3f0a2 /extern/audaspace/src | |
parent | c9efb5424079189951a0eebc968a33787878b039 (diff) |
Fix T83997: Duplicated audio does not sound the same
The issue was that sounds were always faded from 0 volume when they
started and depending on the currently used buffer size, the fading took
longer or shorter.
The solution stores whether the sound has ever been played back and
consequently does not fade when starting to play back.
Diffstat (limited to 'extern/audaspace/src')
-rw-r--r-- | extern/audaspace/src/devices/SoftwareDevice.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/extern/audaspace/src/devices/SoftwareDevice.cpp b/extern/audaspace/src/devices/SoftwareDevice.cpp index 7186f8b9442..c8c1c6081c2 100644 --- a/extern/audaspace/src/devices/SoftwareDevice.cpp +++ b/extern/audaspace/src/devices/SoftwareDevice.cpp @@ -78,7 +78,7 @@ bool SoftwareDevice::SoftwareHandle::pause(bool keep) } SoftwareDevice::SoftwareHandle::SoftwareHandle(SoftwareDevice* device, std::shared_ptr<IReader> reader, std::shared_ptr<PitchReader> pitch, std::shared_ptr<ResampleReader> resampler, std::shared_ptr<ChannelMapperReader> mapper, bool keep) : - m_reader(reader), m_pitch(pitch), m_resampler(resampler), m_mapper(mapper), m_keep(keep), m_user_pitch(1.0f), m_user_volume(1.0f), m_user_pan(0.0f), m_volume(0.0f), m_old_volume(0.0f), m_loopcount(0), + m_reader(reader), m_pitch(pitch), m_resampler(resampler), m_mapper(mapper), m_first_reading(true), m_keep(keep), m_user_pitch(1.0f), m_user_volume(1.0f), m_user_pan(0.0f), m_volume(0.0f), m_old_volume(0.0f), m_loopcount(0), m_relative(true), m_volume_max(1.0f), m_volume_min(0), m_distance_max(std::numeric_limits<float>::max()), m_distance_reference(1.0f), m_attenuation(1.0f), m_cone_angle_outer(M_PI), m_cone_angle_inner(M_PI), m_cone_volume_outer(0), m_flags(RENDER_CONE), m_stop(nullptr), m_stop_data(nullptr), m_status(STATUS_PLAYING), m_device(device) @@ -106,6 +106,14 @@ void SoftwareDevice::SoftwareHandle::update() if(m_pitch->getSpecs().channels != CHANNELS_MONO) { m_volume = m_user_volume; + + // we don't know a previous volume if this source has never been read before + if(m_first_reading) + { + m_old_volume = m_volume; + m_first_reading = false; + } + m_pitch->setPitch(m_user_pitch); return; } @@ -214,6 +222,13 @@ void SoftwareDevice::SoftwareHandle::update() m_volume *= m_user_volume; } + // we don't know a previous volume if this source has never been read before + if(m_first_reading) + { + m_old_volume = m_volume; + m_first_reading = false; + } + // 3D Cue Quaternion orientation; @@ -754,6 +769,8 @@ void SoftwareDevice::mix(data_t* buffer, int length) { m_mixer->mix(buf, pos, len, sound->m_volume, sound->m_old_volume); + sound->m_old_volume = sound->m_volume; + pos += len; if(sound->m_loopcount > 0) |