Skip to content

Commit eafd047

Browse files
committed
Use constant for sample rate and add comment
1 parent 4895af2 commit eafd047

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

include/Config/SettingsManager.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ namespace MetaAudio
3636

3737
XFiWorkaround XfiWorkaround();
3838
};
39+
40+
const int SOXR_SAMPLE_RATE = 48000;
3941
}
4042

4143
#ifndef _METAAUDIO_SETTINGS_MANAGER_

include/Loaders/SoxrDecoder.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "alure2.h"
44
#include "Structures/AudioBuffer.hpp"
55
#include "Utilities/SoxrResamplerHelper.hpp"
6+
#include "Config/SettingsManager.hpp"
67

78
namespace MetaAudio
89
{
@@ -14,8 +15,8 @@ namespace MetaAudio
1415
SoxrResamplerHelper m_helper;
1516

1617
public:
17-
SoxrDecoder(alure::String file_path, alure::Context context, size_t frequency = 48000);
18-
SoxrDecoder(alure::SharedPtr<alure::Decoder> dec, size_t frequency = 48000);
18+
SoxrDecoder(alure::String file_path, alure::Context context, size_t frequency = SOXR_SAMPLE_RATE);
19+
SoxrDecoder(alure::SharedPtr<alure::Decoder> dec, size_t frequency = SOXR_SAMPLE_RATE);
1920

2021
ALuint getFrequency() const noexcept override;
2122
alure::ChannelConfig getChannelConfig() const noexcept override;

src/Loaders/LocalAudioDecoder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ namespace MetaAudio
2929
info.loopstart = loop_points.first;
3030
info.loopend = loop_points.second;
3131

32+
// The decoder `dec` was not created with the resampled audio data, so we need to workaround this
3233
if (settings.ResampleAll() && info.looping)
3334
{
34-
auto ratio = 48000 / dec->getFrequency();
35+
auto ratio = SOXR_SAMPLE_RATE / dec->getFrequency();
3536
info.loopstart *= ratio;
3637
info.loopend *= ratio;
3738
}

0 commit comments

Comments
 (0)