|
GREM 3.12.0
Game/Rendering Engine Modules for C++
|
Container for a mix of sound waves that can be played in a SoundStage. More...
#include <GREM/audio/SoundMix.hpp>

Public Member Functions | |
| SoundMix () | |
| Construct a stereo sound mix with the default options. | |
| SoundMix (const SoundMixOptions &options, const SoundOptions &soundOptions={}) | |
| Construct a sound mix. | |
| SoundInstanceID | playSound (const Sound &sound, float volume=-1.0f) |
| Create a new relative sound instance and start playing it. | |
| SoundInstanceID | play3DSound (const Sound &sound, vec3 position, vec3 velocity, float volume=-1.0f) |
| Create a new 3D sound instance and start playing it. | |
| SoundInstanceID | createPausedSound (const Sound &sound, float volume=-1.0f) |
| Create a new relative sound instance, but don't start playing it yet. | |
| SoundInstanceID | createPaused3DSound (const Sound &sound, vec3 position, vec3 velocity, float volume=-1.0f) |
| Create a new 3D sound instance, but don't start playing it yet. | |
| SoundInstanceID | playSoundClocked (Duration time, const Sound &sound, float volume=-1.0f) |
| Create a new 3D sound instance and start playing it at a specific time relative to other sounds that were also played using playSoundClocked(). | |
| SoundInstanceID | play3DSoundClocked (Duration time, const Sound &sound, vec3 position, vec3 velocity, float volume=-1.0f) |
| Create a new 3D sound instance and start playing it at a specific time relative to other sounds that were also played using playSoundClocked(). | |
| void | setVolume (float volume) |
| Set the volume of the sound mix. | |
| void | setStatisticsEnabled (bool newEnableStatistics) |
| Set whether to enable statistics gathering or not. | |
| Array< float, 256 > | calculateOutputFastFourierTransformStatistics () const |
| Calculate the fast Fourier transform of the audio currently playing through the sound mix. | |
| Array< float, 256 > | getOutputWaveStatistics () const |
| Get the sound wave currently playing through the sound mix. | |
| float | getOutputChannelVolumeStatistics (uint32_t channelIndex) const |
| Get an approximation of the volume of the audio currently playing through a specific channel of the sound mix. | |
| Public Member Functions inherited from grem::audio::Sound | |
| Sound () noexcept=default | |
| Construct an invalid sound that must be reassigned before use. | |
| Sound (const Filesystem &filesystem, CStringView filepath, const SoundOptions &options={}) | |
| Load a sound from a virtual file. | |
| Sound (Span< const byte > fileContents, const SoundOptions &options={}) | |
| Load a sound from an in-memory file. | |
| Sound (Span< const uint8_t > samples, float sampleRate, size_t channelCount=1, const SoundOptions &options={}) | |
| Construct a sound wave from a raw array of samples. | |
| Sound (Span< const int16_t > samples, float sampleRate, size_t channelCount=1, const SoundOptions &options={}) | |
| Construct a sound wave from a raw array of samples. | |
| Sound (Span< const float32_t > samples, float sampleRate, size_t channelCount=1, const SoundOptions &options={}) | |
| Construct a sound wave from a raw array of samples. | |
| operator bool () const noexcept | |
| Check if the sound has a value. | |
| template<filter F> | |
| void | setFilter (size_t filterSlotIndex, const F &newFilter) |
| Set the filter at a particular filter slot of the sound. | |
| void | removeFilter (size_t filterSlotIndex) noexcept |
| Remove the filter at a particular filter slot of the sound. | |
| Duration | getDuration () const noexcept |
| Get the duration of the sound. | |
| void * | get () noexcept |
| Get an opaque handle to the internal representation of the sound. | |
| const void * | get () const noexcept |
| Get an opaque handle to the internal representation of the sound. | |
Additional Inherited Members | |
| Static Public Attributes inherited from grem::audio::Sound | |
| static constexpr size_t | MAX_FILTER_COUNT = 8 |
| Maximum number of filters that can be applied simultaneously to a sound. | |
| Protected Member Functions inherited from grem::audio::Sound | |
| Sound (void *handle, const SoundOptions &options) | |
Container for a mix of sound waves that can be played in a SoundStage.
|
inline |
Construct a stereo sound mix with the default options.
| audio::Error | on failure to create the sound mix. |
| std::bad_alloc | on allocation failure. |
|
explicit |
Construct a sound mix.
| options | sound mix options, see SoundMixOptions. |
| soundOptions | sound options, see SoundOptions. |
| audio::Error | on failure to create the sound mix. |
| std::bad_alloc | on allocation failure. |
| SoundInstanceID grem::audio::SoundMix::playSound | ( | const Sound & | sound, |
| float | volume = -1.0f ) |
Create a new relative sound instance and start playing it.
| sound | the sound data to use for this instance. |
| volume | gain to multiply the amplitude of the sound by when playing. If negative, the default volume set in the SoundOptions is used instead. |
| panning | panning to apply to the sound when playing. |
| SoundInstanceID grem::audio::SoundMix::play3DSound | ( | const Sound & | sound, |
| vec3 | position, | ||
| vec3 | velocity, | ||
| float | volume = -1.0f ) |
Create a new 3D sound instance and start playing it.
| sound | the sound data to use for this instance. |
| position | the position to play the sound at, in sound stage coordinates. Used for distance attenuation/falloff according to the SoundAttenuationModel set in the sound's SoundOptions. |
| velocity | initial linear velocity of the sound. Relevant for simulating the doppler effect. |
| volume | gain to multiply the amplitude of the sound by when playing. If negative, the default volume set in the SoundOptions is used instead. |
| SoundInstanceID grem::audio::SoundMix::createPausedSound | ( | const Sound & | sound, |
| float | volume = -1.0f ) |
Create a new relative sound instance, but don't start playing it yet.
| sound | the sound data to use for this instance. |
| volume | gain to multiply the amplitude of the sound by when playing. If negative, the default volume set in the SoundOptions is used instead. |
| panning | panning to apply to the sound when playing. |
| SoundInstanceID grem::audio::SoundMix::createPaused3DSound | ( | const Sound & | sound, |
| vec3 | position, | ||
| vec3 | velocity, | ||
| float | volume = -1.0f ) |
Create a new 3D sound instance, but don't start playing it yet.
| sound | the sound data to use for this instance. |
| position | the position to play the sound at, in sound stage coordinates. Used for distance attenuation/falloff according to the SoundAttenuationModel set in the sound's SoundOptions. |
| velocity | initial linear velocity of the sound. Relevant for simulating the doppler effect. |
| volume | gain to multiply the amplitude of the sound by when playing. If negative, the default volume set in the SoundOptions is used instead. |
| SoundInstanceID grem::audio::SoundMix::playSoundClocked | ( | Duration | time, |
| const Sound & | sound, | ||
| float | volume = -1.0f ) |
Create a new 3D sound instance and start playing it at a specific time relative to other sounds that were also played using playSoundClocked().
| time | time point to play the sound at, relative to other clocked sounds. This is typically the current frame or tick time, plus some offset. |
| sound | the sound data to use for this instance. |
| volume | gain to multiply the amplitude of the sound by when playing. If negative, the default volume set in the SoundOptions is used instead. |
| panning | panning to apply to the sound when playing. |
| SoundInstanceID grem::audio::SoundMix::play3DSoundClocked | ( | Duration | time, |
| const Sound & | sound, | ||
| vec3 | position, | ||
| vec3 | velocity, | ||
| float | volume = -1.0f ) |
Create a new 3D sound instance and start playing it at a specific time relative to other sounds that were also played using playSoundClocked().
| time | time point to play the sound at, relative to other clocked sounds. This is typically the current frame or tick time, plus some offset. |
| sound | the sound data to use for this instance. |
| position | the position to play the sound at, in sound stage coordinates. Used for distance attenuation/falloff according to the SoundAttenuationModel set in the sound's SoundOptions. |
| velocity | initial linear velocity of the sound. Relevant for simulating the doppler effect. |
| volume | gain to multiply the amplitude of the sound by when playing. If negative, the default volume set in the SoundOptions is used instead. |
| void grem::audio::SoundMix::setVolume | ( | float | volume | ) |
Set the volume of the sound mix.
| volume | new volume, see SoundMixOptions::volume. |
| void grem::audio::SoundMix::setStatisticsEnabled | ( | bool | newEnableStatistics | ) |
Set whether to enable statistics gathering or not.
Statistics gathering must be enabled in order for calculateOutputFastFourierTransformStatistics(), getOutputWaveStatistics() and getOutputChannelVolumeStatistics() to work.
| newEnableStatistics | new mode of statistics gathering to set. |
|
nodiscard |
Calculate the fast Fourier transform of the audio currently playing through the sound mix.
|
nodiscard |
Get the sound wave currently playing through the sound mix.
|
nodiscard |
Get an approximation of the volume of the audio currently playing through a specific channel of the sound mix.
| channelIndex | index of the channel to get the volume of. |