25 #ifndef CPP3DS_SOUNDBUFFER_HPP
26 #define CPP3DS_SOUNDBUFFER_HPP
32 #include <cpp3ds/System/LinearAllocator.hpp>
34 #include <cpp3ds/Audio/AlResource.hpp>
35 #include <cpp3ds/System/Time.hpp>
137 bool loadFromSamples(
const Int16* samples, Uint64 sampleCount,
unsigned int channelCount,
unsigned int sampleRate);
152 bool saveToFile(
const std::string& filename)
const;
251 bool update(
unsigned int channelCount,
unsigned int sampleRate);
259 void attachSound(
Sound* sound)
const;
267 void detachSound(
Sound* sound)
const;
272 typedef std::set<Sound*> SoundList;
278 mutable SoundList m_sounds;
280 unsigned int m_sampleRate;
281 unsigned int m_channelCount;
283 unsigned int m_buffer;
284 std::vector<Int16> m_samples;
286 std::vector<Int16, LinearAllocator<Int16>> m_samples;
293 #endif // CPP3DS_SOUNDBUFFER_HPP
unsigned int getSampleRate() const
Get the sample rate of the sound.
SoundBuffer & operator=(const SoundBuffer &right)
Overload of assignment operator.
const Int16 * getSamples() const
Get the array of audio samples stored in the buffer.
bool loadFromMemory(const void *data, std::size_t sizeInBytes)
Load the sound buffer from a file in memory.
bool loadFromFile(const std::string &filename)
Load the sound buffer from a file.
bool loadFromSamples(const Int16 *samples, Uint64 sampleCount, unsigned int channelCount, unsigned int sampleRate)
Load the sound buffer from an array of audio samples.
bool saveToFile(const std::string &filename) const
Save the sound buffer to an audio file.
Storage for audio samples defining a sound.
Regular sound that can be played in the audio environment.
Time getDuration() const
Get the total duration of the sound.
Uint64 getSampleCount() const
Get the number of samples stored in the buffer.
SoundBuffer()
Default constructor.
bool loadFromStream(InputStream &stream)
Load the sound buffer from a custom stream.
unsigned int getChannelCount() const
Get the number of channels used by the sound.
~SoundBuffer()
Destructor.
Base class for classes that require an OpenAL context.