LibAudio: Make AudioLoaders return float instead of double
AudioBuffers already use floats internally so there is no need for loaders to produces doubles
This commit is contained in:
@@ -105,17 +105,17 @@ namespace LibAudio
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static double read_sample(BAN::ConstByteSpan data)
|
||||
static float read_sample(BAN::ConstByteSpan data)
|
||||
{
|
||||
if constexpr(BAN::is_same_v<float, T> || BAN::is_same_v<double, T>)
|
||||
return data.as<const T>();
|
||||
else if constexpr(BAN::is_signed_v<T>)
|
||||
return data.as<const T>() / static_cast<double>(BAN::numeric_limits<T>::max());
|
||||
return data.as<const T>() / static_cast<float>(BAN::numeric_limits<T>::max());
|
||||
else
|
||||
return data.as<const T>() / (BAN::numeric_limits<T>::max() / 2.0) - 1.0;
|
||||
return data.as<const T>() / (BAN::numeric_limits<T>::max() / 2.0f) - 1.0f;
|
||||
}
|
||||
|
||||
double WAVAudioLoader::get_sample()
|
||||
float WAVAudioLoader::get_sample()
|
||||
{
|
||||
ASSERT(samples_remaining() > 0);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace LibAudio
|
||||
virtual uint32_t sample_rate() const = 0;
|
||||
virtual uint32_t samples_remaining() const = 0;
|
||||
|
||||
virtual double get_sample() = 0;
|
||||
virtual float get_sample() = 0;
|
||||
|
||||
protected:
|
||||
AudioLoader() = default;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace LibAudio
|
||||
uint32_t sample_rate() const override { return m_sample_rate; }
|
||||
uint32_t samples_remaining() const override { return m_total_samples - m_current_sample; }
|
||||
|
||||
double get_sample() override;
|
||||
float get_sample() override;
|
||||
|
||||
private:
|
||||
uint32_t m_channels { 0 };
|
||||
|
||||
Reference in New Issue
Block a user