37#include <unordered_set>
137 std::uint64_t sampleCount,
138 unsigned int channelCount,
139 unsigned int sampleRate,
140 const std::vector<SoundChannel>& channelMap);
161 [[nodiscard]]
bool loadFromFile(
const std::filesystem::path& filename);
211 std::uint64_t sampleCount,
212 unsigned int channelCount,
213 unsigned int sampleRate,
214 const std::vector<SoundChannel>& channelMap);
227 [[nodiscard]]
bool saveToFile(
const std::filesystem::path& filename)
const;
339 [[nodiscard]]
bool update(
unsigned int channelCount,
unsigned int sampleRate,
const std::vector<SoundChannel>& channelMap);
347 void attachSound(
Sound* sound)
const;
355 void detachSound(
Sound* sound)
const;
360 using SoundList = std::unordered_set<Sound*>;
365 std::vector<std::int16_t> m_samples;
366 unsigned int m_sampleRate{44100};
369 mutable SoundList m_sounds;
unsigned int getChannelCount() const
Get the number of channels used by the sound.
SoundBuffer(const std::filesystem::path &filename)
Construct the sound buffer from a file.
Time getDuration() const
Get the total duration of the sound.
unsigned int getSampleRate() const
Get the sample rate of the sound.
SoundBuffer(const std::int16_t *samples, std::uint64_t sampleCount, unsigned int channelCount, unsigned int sampleRate, const std::vector< SoundChannel > &channelMap)
Construct the sound buffer from an array of audio samples.
bool loadFromFile(const std::filesystem::path &filename)
Load the sound buffer from a file.
const std::int16_t * getSamples() const
Get the array of audio samples stored in the buffer.
std::vector< SoundChannel > getChannelMap() const
Get the map of position in sample frame to sound channel.
std::uint64_t getSampleCount() const
Get the number of samples stored in the buffer.
SoundBuffer()=default
Default constructor.
bool loadFromSamples(const std::int16_t *samples, std::uint64_t sampleCount, unsigned int channelCount, unsigned int sampleRate, const std::vector< SoundChannel > &channelMap)
Load the sound buffer from an array of audio samples.
SoundBuffer(const SoundBuffer ©)
Copy constructor.
bool saveToFile(const std::filesystem::path &filename) const
Save the sound buffer to an audio file.
SoundBuffer & operator=(const SoundBuffer &right)
Overload of assignment operator.
bool loadFromStream(InputStream &stream)
Load the sound buffer from a custom stream.
~SoundBuffer()
Destructor.
SoundBuffer(InputStream &stream)
Construct the sound buffer from a custom stream.
SoundBuffer(const void *data, std::size_t sizeInBytes)
Construct the sound buffer from a file in memory.
bool loadFromMemory(const void *data, std::size_t sizeInBytes)
Load the sound buffer from a file in memory.
Regular sound that can be played in the audio environment.