Skip to content

IAudioPlayer.PlaySound(ISoundEffect, float, int, float, float, int, string) Method

Definition

Namespace: Brine2D.Audio

Plays a sound effect and returns the track handle for lifecycle tracking.

C#
nint PlaySound(Brine2D.Audio.ISoundEffect sound, float volume=1f, int loops=0, float pan=0f, float pitch=1f, int priority=0, string? bus=null);

Parameters

sound ISoundEffect

The sound effect to play.

volume System.Single

Per-sound volume multiplier \(0\.0 to 1\.0, default 1\.0\). The final gain applied to the track is volume × SoundVolume.

loops System.Int32

Number of times to loop \(0 = play once, \-1 = infinite\).

pan System.Single

Stereo pan \(\-1\.0 left to 1\.0 right\).

pitch System.Single

Playback speed multiplier \(0\.25 to 4\.0, default 1\.0\).

priority System.Int32

Track priority for eviction. When all tracks are in use the lowest-priority track is evicted if the new sound's priority is equal or higher.

bus System.String

Optional bus name to tag the track with atomically at creation time. When non-null, the track is tagged before playback begins, eliminating the window between PlaySound\(ISoundEffect, float, int, float, float, int, string\) and Brine2D.Audio.IAudioPlayer.TagTrack\(System\.IntPtr,System\.String\) where a PauseBus\(string\) or StopBus\(string, float\) call could miss the track.

Returns

nint
A track handle for use with Brine2D.Audio.IAudioPlayer.StopTrack\(System\.IntPtr\), Brine2D.Audio.IAudioPlayer.PauseTrack\(System\.IntPtr\), Brine2D.Audio.IAudioPlayer.ResumeTrack\(System\.IntPtr\), Brine2D.Audio.IAudioPlayer.IsTrackAlive\(System\.IntPtr\), Brine2D.Audio.IAudioPlayer.TagTrack\(System\.IntPtr,System\.String\), Brine2D.Audio.IAudioPlayer.SetTrackVolume\(System\.IntPtr,System\.Single\), Brine2D.Audio.IAudioPlayer.SetTrackVolumeAndPan\(System\.IntPtr,System\.Single,System\.Single\), Brine2D.Audio.IAudioPlayer.SetTrackPan\(System\.IntPtr,System\.Single\) and Brine2D.Audio.IAudioPlayer.SetTrackPitch\(System\.IntPtr,System\.Single\), or System.IntPtr.Zero if the sound could not be played.