Audio: Uniformize SampleCount/SampleRate type
Former-commit-id: a67b0f10a4aeb1399834221d32859ab0e376813e
This commit is contained in:
parent
2fd3872099
commit
ce3bbf6c78
|
|
@ -45,8 +45,8 @@ class NAZARA_AUDIO_API NzMusic : public NzResource, public NzSoundEmitter
|
||||||
nzUInt32 GetDuration() const;
|
nzUInt32 GetDuration() const;
|
||||||
nzAudioFormat GetFormat() const;
|
nzAudioFormat GetFormat() const;
|
||||||
nzUInt32 GetPlayingOffset() const;
|
nzUInt32 GetPlayingOffset() const;
|
||||||
unsigned int GetSampleCount() const;
|
nzUInt32 GetSampleCount() const;
|
||||||
unsigned int GetSampleRate() const;
|
nzUInt32 GetSampleRate() const;
|
||||||
nzSoundStatus GetStatus() const;
|
nzSoundStatus GetStatus() const;
|
||||||
|
|
||||||
bool IsLooping() const;
|
bool IsLooping() const;
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,8 @@ class NAZARA_AUDIO_API NzSoundBuffer : public NzRefCounted, public NzResource
|
||||||
nzUInt32 GetDuration() const;
|
nzUInt32 GetDuration() const;
|
||||||
nzAudioFormat GetFormat() const;
|
nzAudioFormat GetFormat() const;
|
||||||
const nzInt16* GetSamples() const;
|
const nzInt16* GetSamples() const;
|
||||||
unsigned int GetSampleCount() const;
|
nzUInt32 GetSampleCount() const;
|
||||||
unsigned int GetSampleRate() const;
|
nzUInt32 GetSampleRate() const;
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class NAZARA_AUDIO_API NzSoundStream
|
||||||
|
|
||||||
virtual nzUInt32 GetDuration() const = 0;
|
virtual nzUInt32 GetDuration() const = 0;
|
||||||
virtual nzAudioFormat GetFormat() const = 0;
|
virtual nzAudioFormat GetFormat() const = 0;
|
||||||
virtual nzUInt64 GetSampleCount() const = 0;
|
virtual nzUInt32 GetSampleCount() const = 0;
|
||||||
virtual nzUInt32 GetSampleRate() const = 0;
|
virtual nzUInt32 GetSampleRate() const = 0;
|
||||||
|
|
||||||
virtual unsigned int Read(void* buffer, unsigned int sampleCount) = 0;
|
virtual unsigned int Read(void* buffer, unsigned int sampleCount) = 0;
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ namespace
|
||||||
return m_format;
|
return m_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
nzUInt64 GetSampleCount() const override
|
nzUInt32 GetSampleCount() const override
|
||||||
{
|
{
|
||||||
return m_sampleCount;
|
return m_sampleCount;
|
||||||
}
|
}
|
||||||
|
|
@ -152,11 +152,11 @@ namespace
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sampleCount = infos.channels*infos.frames;
|
m_sampleCount = static_cast<nzUInt32>(infos.channels*infos.frames);
|
||||||
m_sampleRate = infos.samplerate;
|
m_sampleRate = infos.samplerate;
|
||||||
|
|
||||||
// Durée de la musique (s) = samples / channels*rate
|
// Durée de la musique (s) = samples / channels*rate
|
||||||
m_duration = static_cast<nzUInt32>(1000*m_sampleCount / (m_format*m_sampleRate));
|
m_duration = static_cast<nzUInt32>(1000ULL*m_sampleCount / (m_format*m_sampleRate));
|
||||||
|
|
||||||
// https://github.com/LaurentGomila/SFML/issues/271
|
// https://github.com/LaurentGomila/SFML/issues/271
|
||||||
// http://www.mega-nerd.com/libsndfile/command.html#SFC_SET_SCALE_FLOAT_INT_READ
|
// http://www.mega-nerd.com/libsndfile/command.html#SFC_SET_SCALE_FLOAT_INT_READ
|
||||||
|
|
@ -168,7 +168,7 @@ namespace
|
||||||
if (forceMono && m_format != nzAudioFormat_Mono)
|
if (forceMono && m_format != nzAudioFormat_Mono)
|
||||||
{
|
{
|
||||||
m_mixToMono = true;
|
m_mixToMono = true;
|
||||||
m_sampleCount = infos.frames;
|
m_sampleCount = static_cast<nzUInt32>(infos.frames);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_mixToMono = false;
|
m_mixToMono = false;
|
||||||
|
|
@ -206,8 +206,8 @@ namespace
|
||||||
SNDFILE* m_handle;
|
SNDFILE* m_handle;
|
||||||
bool m_mixToMono;
|
bool m_mixToMono;
|
||||||
nzUInt32 m_duration;
|
nzUInt32 m_duration;
|
||||||
nzUInt64 m_sampleCount;
|
unsigned int m_sampleCount;
|
||||||
nzUInt32 m_sampleRate;
|
unsigned int m_sampleRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool IsSupported(const NzString& extension)
|
bool IsSupported(const NzString& extension)
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,32 @@ nzUInt32 NzMusic::GetPlayingOffset() const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nzUInt32 NzMusic::GetSampleCount() const
|
||||||
|
{
|
||||||
|
#if NAZARA_AUDIO_SAFE
|
||||||
|
if (!m_impl)
|
||||||
|
{
|
||||||
|
NazaraError("Music not created");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return m_impl->stream->GetSampleCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
nzUInt32 NzMusic::GetSampleRate() const
|
||||||
|
{
|
||||||
|
#if NAZARA_AUDIO_SAFE
|
||||||
|
if (!m_impl)
|
||||||
|
{
|
||||||
|
NazaraError("Music not created");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return m_impl->stream->GetSampleRate();
|
||||||
|
}
|
||||||
|
|
||||||
nzSoundStatus NzMusic::GetStatus() const
|
nzSoundStatus NzMusic::GetStatus() const
|
||||||
{
|
{
|
||||||
#if NAZARA_AUDIO_SAFE
|
#if NAZARA_AUDIO_SAFE
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ struct NzSoundBufferImpl
|
||||||
nzAudioFormat format;
|
nzAudioFormat format;
|
||||||
nzUInt32 duration;
|
nzUInt32 duration;
|
||||||
std::unique_ptr<nzInt16[]> samples;
|
std::unique_ptr<nzInt16[]> samples;
|
||||||
unsigned int sampleCount;
|
nzUInt32 sampleCount;
|
||||||
unsigned int sampleRate;
|
nzUInt32 sampleRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
NzSoundBuffer::NzSoundBuffer(nzAudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const nzInt16* samples)
|
NzSoundBuffer::NzSoundBuffer(nzAudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const nzInt16* samples)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue