SoLoud class interface
The main class to call all the audio methods that play sounds.
This class has a singleton instance which represents the (also singleton) instance of the SoLoud (C++) engine.
Properties
-
activeSounds
→ Iterable<
AudioSource> -
The sounds that are currently being loaded.
no setter
- filters → FiltersGlobal
-
This can be used to access all the available filter functionalities
for the player output (formerly called global filters).
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
- isInitialized → bool
-
The current status of the engine. This is
true
when the engine has been initialized and is immediately ready.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addAudioDataStream(
AudioSource source, Uint8List audioChunk) → void - Add PCM audio data to the stream.
-
addGlobalFilter(
FilterType filterType) → void -
Adds a
filterType
to all sounds. -
addVoicesToGroup(
SoundHandle voiceGroupHandle, List< SoundHandle> voiceHandles) → void -
Adds voice handle to the voice group. The voice handles can still be
used separate from the group.
voiceGroupHandle
the group handle to add the newvoiceHandles
.voiceHandles
voice handle to add to thevoiceGroupHandle
. -
changeDevice(
{PlaybackDevice? newDevice}) → void -
Changes the output audio device to the one specified in the
newDevice
. IfnewDevice
is not provided, the default OS device will be used. -
countAudioSource(
AudioSource audioSource) → int - Returns the number of concurrent sounds that are playing a specific audio source.
-
createVoiceGroup(
) → SoundHandle - Used to create a new voice group. Returns 0 if not successful.
-
deinit(
) → void - Stops the engine and disposes of all resources, including sounds.
-
destroyVoiceGroup(
SoundHandle handle) → void - Deallocates the voice group. Does not stop the voices attached to the voice group.
-
disposeAllSources(
) → Future< void> - Disposes all audio sources that are currently loaded. Also stops all sound instances if anything is playing.
-
disposeSource(
AudioSource source) → Future< void> -
Stops all handles of the already loaded
source
, and reclaims memory. -
fadeGlobalFilterParameter(
FilterType filterType, int attributeId, double to, Duration time) → void - Fade a parameter of a filter.
-
fadeGlobalVolume(
double to, Duration time) → void -
Smoothly changes the global volume to the value of
to
over specifiedtime
. -
fadePan(
SoundHandle handle, double to, Duration time) → void -
Smoothly changes a currently playing sound's pan setting
to the value of
to
over specifiedtime
. -
fadeRelativePlaySpeed(
SoundHandle handle, double to, Duration time) → void -
Smoothly changes a currently playing sound's relative play speed
to the value of
to
over specifiedtime
. -
fadeVolume(
SoundHandle handle, double to, Duration time) → void -
Smoothly changes a single sound instance's volume
to the value of
to
over the specifiedtime
. -
get3dSoundSpeed(
) → double - Gets the speed of sound.
-
getActiveVoiceCount(
) → int - Returns the number of concurrent sounds that are playing at the moment.
-
getBufferSize(
AudioSource sound) → int - Get the current buffer size in bytes of this sound with hash hash. hash the hash of the stream sound.
-
getFilterParameter(
FilterType filterType, int attributeId, {SoundHandle handle = const SoundHandle.error()}) → double -
Get the effect parameter value with id
attributeId
offilterType
. -
getFilterParamNames(
FilterType filterType) → List< String> -
Gets parameters of the given
filterType
. -
getGlobalFilterParameter(
FilterType filterType, int attributeId) → double -
Get the effect parameter value with id
attributeId
offilterType
. -
getGlobalVolume(
) → double - Gets the current global volume.
-
getIsValidVoiceHandle(
SoundHandle handle) → bool -
Check if the
handle
is still valid. -
getLength(
AudioSource source) → Duration -
Get the length of a loaded audio
source
. -
getLooping(
SoundHandle handle) → bool -
Query whether a sound (supplied via
handle
) is set to loop. -
getLoopPoint(
SoundHandle handle) → Duration -
Get the loop point value of a currently playing sound, provided via
its
handle
. -
getMaxActiveVoiceCount(
) → int - Gets the current maximum active voice count.
-
getPan(
SoundHandle handle) → double - Get a sound's current pan setting.
-
getPause(
SoundHandle handle) → bool -
Gets the pause state of a currently playing sound identified by
handle
. -
getPosition(
SoundHandle handle) → Duration -
Get the current sound position of a sound instance (provided via its
handle
). NOTE: if this handle belongs to a buffer stream of BufferingType.released type, please use getStreamTimeConsumed instead. -
getProtectVoice(
SoundHandle handle) → bool - Get a sound's protection state.
-
getRelativePlaySpeed(
SoundHandle handle) → double -
Get a sound's relative play speed. Provide the sound instance via
its
handle
. -
getStreamTimeConsumed(
AudioSource sound) → Duration -
Get the current stream time consumed in seconds of this
sound
of type BufferingType.released. Since the position of this kind of stream is always 0, this method is useful to know the time already played. -
getVisualizationEnabled(
) → bool - Get visualization state.
-
getVoiceCount(
) → int - Returns the number of voices the application has told SoLoud to play.
-
getVolume(
SoundHandle handle) → double -
Get the volume of the currently playing sound instance, provided
via its
handle
. -
init(
{PlaybackDevice? device, bool automaticCleanup = false, int sampleRate = 44100, int bufferSize = 2048, Channels channels = Channels.stereo}) → Future< void> - Initializes the audio engine.
-
isFilterActive(
FilterType filterType) → int -
Checks whether the given
filterType
is active. -
isVoiceGroup(
SoundHandle handle) → bool - Checks if the handle is a valid voice group. Does not care if the voice group is empty.
-
isVoiceGroupEmpty(
SoundHandle handle) → bool - Checks whether a voice group is empty. SoLoud automatically trims the voice groups of voices that have ended, so the group may be empty even though you've added valid voice handles to it.
-
listPlaybackDevices(
) → List< PlaybackDevice> - Lists all OS available playback devices. Could be called safely even if the engin has not been initialized yet.
-
loadAsset(
String key, {LoadMode mode = LoadMode.memory, AssetBundle? assetBundle}) → Future< AudioSource> - Load a new sound to be played once or multiple times later, from an asset.
-
loadFile(
String path, {LoadMode mode = LoadMode.memory}) → Future< AudioSource> - Load a new sound to be played once or multiple times later, from the file system. NOTE: this is not available on Web. Use loadMem instead.
-
loadMem(
String path, Uint8List buffer, {LoadMode mode = LoadMode.memory}) → Future< AudioSource> - Load a new sound to be played once or multiple times later, from a buffer. While loadFile decompresses the audio file and loads it into memory, loadMem loads the audio data directly from the compressed file. The compressed data could be read from memory LoadMode.memory or from disk LoadMode.disk.
-
loadUrl(
String url, {LoadMode mode = LoadMode.memory, Client? httpClient}) → Future< AudioSource> - Load a new sound to be played once or multiple times later, from a network URL.
-
loadWaveform(
WaveForm waveform, bool superWave, double scale, double detune) → Future< AudioSource> - Load a new waveform to be played once or multiple times later.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
oscillateGlobalFilterParameter(
FilterType filterType, int attributeId, double from, double to, Duration time) → void - Oscillate a parameter of a filter.
-
oscillateGlobalVolume(
double from, double to, Duration time) → void - Set fader to oscillate the global volume at specified frequency.
-
oscillatePan(
SoundHandle handle, double from, double to, Duration time) → void - Sets oscillation of the pan at specified frequency.
-
oscillateRelativePlaySpeed(
SoundHandle handle, double from, double to, Duration time) → void - Sets oscillation of the play speed at specified frequency.
-
oscillateVolume(
SoundHandle handle, double from, double to, Duration time) → void - Sets fader to oscillate the volume at specified frequency.
-
pauseSwitch(
SoundHandle handle) → void -
Pause or unpause a currently playing sound identified by
handle
. -
play(
AudioSource sound, {double volume = 1, double pan = 0, bool paused = false, bool looping = false, Duration loopingStartAt = Duration.zero}) → Future< SoundHandle> -
Play an already-loaded sound identified by
sound
. Creates a new playing instance of the sound, and returns its SoundHandle. -
play3d(
AudioSource sound, double posX, double posY, double posZ, {double velX = 0, double velY = 0, double velZ = 0, double volume = 1, bool paused = false, bool looping = false, Duration loopingStartAt = Duration.zero}) → Future< SoundHandle> - This function is the 3D version of the play call.
-
readSamplesFromFile(
String completeFileName, int numSamplesNeeded, {double startTime = 0, double endTime = -1, bool average = false}) → Future< Float32List> -
Read
numSamplesNeeded
audio data from a file equally spaced in time. The returned Float32List is not guaranteed to benumSamplesNeeded
long. Each value in the returned Float32List is in the range -1.0 to 1.0 (but not guaranteed). Their values are the average of audio data from the previous index sample ifaverage
is true. NOTE: this is not available on Web. Use readSamplesFromMem instead. -
readSamplesFromMem(
Uint8List buffer, int numSamplesNeeded, {double startTime = 0, double endTime = -1, bool average = false}) → Future< Float32List> -
Read
numSamplesNeeded
audio data from a audio buffer equally spaced in time. The returned Float32List is not guaranteed to benumSamplesNeeded
long. Each value in the returned Float32List is in the range -1.0 to 1.0 (but not guaranteed). Their values are the average of audio data from the previous index sample ifaverage
is true. NOTE: on Web this is synchronous and could freeze the UI. -
removeGlobalFilter(
FilterType filterType) → void -
Removes
filterType
from all sounds. -
resetBufferStream(
AudioSource sound) → void - Resets the buffer of the data stream.
-
schedulePause(
SoundHandle handle, Duration time) → void -
Waits the specified
time
, then pauses the currently playing sound. -
scheduleStop(
SoundHandle handle, Duration time) → void -
Waits the specified
time
, then stops the currently playing sound. -
seek(
SoundHandle handle, Duration time) → void -
Seek a currently playing sound instance, provided via its
handle
. Specify thetime
(as a Duration) to which you want to move the play head. -
set3dListenerAt(
double atX, double atY, double atZ) → void - Sets the at-vector (i.e. position) parameter of the 3D audio listener.
-
set3dListenerParameters(
double posX, double posY, double posZ, double atX, double atY, double atZ, double upX, double upY, double upZ, double velocityX, double velocityY, double velocityZ) → void - Sets the position, at-vector, up-vector and velocity parameters of the 3D audio listener with one call.
-
set3dListenerPosition(
double posX, double posY, double posZ) → void - Sets the position parameter of the 3D audio listener.
-
set3dListenerUp(
double upX, double upY, double upZ) → void - Sets the up-vector parameter of the 3D audio listener.
-
set3dListenerVelocity(
double velocityX, double velocityY, double velocityZ) → void - Sets the 3D listener's velocity vector.
-
set3dSoundSpeed(
double speed) → void - Since SoLoud has no knowledge of the scale of your coordinates, you may need to adjust the speed of sound for these effects to work correctly. The default value is 343, which assumes that your world coordinates are in meters (where 1 unit is 1 meter), and that the environment is dry air at around 20 degrees Celsius.
-
set3dSourceAttenuation(
SoundHandle handle, int attenuationModel, double attenuationRolloffFactor) → void - You can change the attenuation model and rolloff factor parameters of a live 3D audio source.
-
set3dSourceDopplerFactor(
SoundHandle handle, double dopplerFactor) → void - Sets the doppler factor of a live 3D audio source. 0 = disable, 1 = normal, >1 = exaggerated
-
set3dSourceMinMaxDistance(
SoundHandle handle, double minDistance, double maxDistance) → void - Sets the minimum and maximum distance parameters of a live 3D audio source. Default values are 1 and 1000000.
-
set3dSourceParameters(
SoundHandle handle, double posX, double posY, double posZ, double velocityX, double velocityY, double velocityZ) → void - Sets the position and velocity parameters of a live 3D audio source with one call.
-
set3dSourcePosition(
SoundHandle handle, double posX, double posY, double posZ) → void - Sets the position of a live 3D audio source.
-
set3dSourceVelocity(
SoundHandle handle, double velocityX, double velocityY, double velocityZ) → void - Set the velocity parameter of a live 3D audio source.
-
setBufferStream(
{int? maxBufferSizeBytes, Duration? maxBufferSizeDuration, BufferingType bufferingType = BufferingType.preserved, double bufferingTimeNeeds = 2, int sampleRate = 24000, Channels channels = Channels.mono, BufferType format = BufferType.s16le, void onBuffering(bool isBuffering, int handle, double time)?}) → AudioSource - Set up an audio stream.
-
setDataIsEnded(
AudioSource sound) → void - Set the end of the data stream.
-
setFftSmoothing(
double smooth) → void - Smooth FFT data. When new data is read and the values are decreasing, the new value will be decreased with an amplitude between the old and the new value. This will resul on a less shaky visualization.
-
setFilterParameter(
FilterType filterType, int attributeId, double value) → void -
Set the effect parameter with id
attributeId
offilterType
withvalue
value. -
setGlobalFilterParameter(
FilterType filterType, int attributeId, double value) → void -
Set the effect parameter with id
attributeId
offilterType
withvalue
value. -
setGlobalVolume(
double volume) → void - Sets the global volume which affects all sounds.
-
setInaudibleBehavior(
SoundHandle handle, bool mustTick, bool kill) → void - Set the inaudible behavior of a live 3D sound. By default, if a sound is inaudible, it's paused, and will resume when it becomes audible again. With this function you can tell SoLoud to either kill the sound if it becomes inaudible, or to keep ticking the sound even if it's inaudible.
-
setLooping(
SoundHandle handle, bool enable) → void -
Set the looping flag of a currently playing sound, provided via
its
handle
. -
setLoopPoint(
SoundHandle handle, Duration time) → void -
Set the loop point of a currently playing sound, provided via
its
handle
. -
setMaxActiveVoiceCount(
int maxVoiceCount) → void - Sets the current maximum active voice count.
-
setPan(
SoundHandle handle, double pan) → void - Set a sound's current pan setting.
-
setPanAbsolute(
SoundHandle handle, double panLeft, double panRight) → void - Set the left/right volumes directly. Note that this does not affect the value returned by getPan.
-
setPause(
SoundHandle handle, bool pause) → void -
Pause or unpause a currently playing sound identified by
handle
. -
setProtectVoice(
SoundHandle handle, bool protect) → void - Sets a sound instance's protection state.
-
setRelativePlaySpeed(
SoundHandle handle, double speed) → void - Set a sound's relative play speed.
-
setVisualizationEnabled(
bool enabled) → void - Enable or disable visualization.
-
setVolume(
SoundHandle handle, double volume) → void -
Set the volume for a currently playing sound instance, provided
via its
handle
. -
setWaveform(
AudioSource sound, WaveForm newWaveform) → void - Set a waveform type to the given sound: see WaveForm enum.
-
setWaveformDetune(
AudioSource sound, double newDetune) → void -
If this sound is a
superWave
you can change the detune at runtime. -
setWaveformFreq(
AudioSource sound, double newFrequency) → void - Set the frequency of the given waveform sound.
-
setWaveformScale(
AudioSource sound, double newScale) → void -
If this sound is a
superWave
you can change the scale at runtime. -
setWaveformSuperWave(
AudioSource sound, bool superwave) → void - Set the given waveform sound's super wave flag.
-
speechText(
String textToSpeech) → Future< AudioSource> -
Create a new audio source from the given
textToSpeech
. -
stop(
SoundHandle handle) → Future< void> -
Stop a currently playing sound identified by
handle
and clear it from the sound handle list. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited