Class MusicTrack
Represents a music track with associated metadata and audio properties. Inherits from AudioPlayerClip to utilize audio playback features.
Namespace: Serenity.MusicPlayer.Domain.Entities
Assembly: Serenity.MusicPlayer.Domain.dll
Syntax
public class MusicTrack : AudioPlayerClip
Constructors
MusicTrack(string, string, string, string, AudioPlayerType, bool, float, float, float, float, float, int, float, float, float, float, bool, float, MusicFadeCurve, float[])
Default audio player type for music tracks.
Declaration
public MusicTrack(string id, string title, string artist, string filePath, AudioPlayerType clipType = 0, bool loop = false, float volume = 1, float pitch = 1, float panStereo = 0, float spatialBlend = 0, float reverbZoneMix = 1, int rolloffMode = 0, float minDistance = 1, float maxDistance = 500, float startTime = 0, float endTime = 0, bool tailPreservingLoop = false, float tailFadeOutDuration = 0, MusicFadeCurve tailFadeOutCurve = MusicFadeCurve.Linear, float[] tailFadeOutCurveSamples = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | id | The unique identifier for the music track. |
| string | title | The title of the music track. |
| string | artist | The artist of the music track. |
| string | filePath | The file path to the audio clip. |
| AudioPlayerType | clipType | The type of audio player clip. Default is BackgroundMusic. |
| bool | loop | Whether the audio should loop. Default is true. |
| float | volume | The volume level of the audio. Default is 1.0f. |
| float | pitch | The pitch level of the audio. Default is 1.0f. |
| float | panStereo | The stereo pan level of the audio. Default is 0.0f. |
| float | spatialBlend | The spatial blend level of the audio. Default is 0.0f. |
| float | reverbZoneMix | The reverb zone mix level of the audio. Default is 1.0f. |
| int | rolloffMode | The rolloff mode of the audio. Default is 1 (Logarithmic). |
| float | minDistance | The minimum distance for 3D audio. Default is 1.0f. |
| float | maxDistance | The maximum distance for 3D audio. Default is 500.0f. |
| float | startTime | The loop-return point in seconds. Default is 0.0f. |
| float | endTime | The loop-out point in seconds. Default is 0.0f. |
| bool | tailPreservingLoop | Whether the track uses tail-preserving looping. Default is false. |
| float | tailFadeOutDuration | Duration in seconds over which the tail fades out; 0 cuts at the loop point. Default is 0.0f. |
| MusicFadeCurve | tailFadeOutCurve | Shape of the tail fade-out curve. Default is Linear. |
| float[] | tailFadeOutCurveSamples | Custom fade-out gain table over [0, 1], or null for presets. Default is null. |
Remarks
Set to BackgroundMusic by default.
Fields
DEFAULT_END_TIME
Declaration
protected const float DEFAULT_END_TIME = 0
Field Value
| Type | Description |
|---|---|
| float | Default loop-out point in seconds for music tracks. |
DEFAULT_START_TIME
Declaration
protected const float DEFAULT_START_TIME = 0
Field Value
| Type | Description |
|---|---|
| float | Default loop-return point in seconds for music tracks. |
DEFAULT_TAIL_FADE_OUT_CURVE
Declaration
protected const MusicFadeCurve DEFAULT_TAIL_FADE_OUT_CURVE = Linear
Field Value
| Type | Description |
|---|---|
| MusicFadeCurve | Default tail fade-out curve for music tracks. |
DEFAULT_TAIL_FADE_OUT_DURATION
Declaration
protected const float DEFAULT_TAIL_FADE_OUT_DURATION = 0
Field Value
| Type | Description |
|---|---|
| float | Default tail fade-out duration in seconds for music tracks (0 = cut at the loop point). |
DEFAULT_TAIL_PRESERVING_LOOP
Declaration
protected const bool DEFAULT_TAIL_PRESERVING_LOOP = false
Field Value
| Type | Description |
|---|---|
| bool | Default tail-preserving loop setting for music tracks. |
_artist
Declaration
protected string _artist
Field Value
| Type | Description |
|---|---|
| string | Music track artist. |
_endTime
Declaration
protected float _endTime
Field Value
| Type | Description |
|---|---|
| float | Loop-out point in seconds; the position where the next loop voice is scheduled. |
_startTime
Declaration
protected float _startTime
Field Value
| Type | Description |
|---|---|
| float | Loop-return point in seconds; each tail-preserving loop restarts playback from here. |
_tailFadeOutCurve
Declaration
protected MusicFadeCurve _tailFadeOutCurve
Field Value
| Type | Description |
|---|---|
| MusicFadeCurve | Shape of the tail fade-out curve. |
_tailFadeOutCurveSamples
Declaration
protected float[] _tailFadeOutCurveSamples
Field Value
| Type | Description |
|---|---|
| float[] | Custom tail fade-out gain table sampled over [0, 1], or null for preset curves. |
_tailFadeOutDuration
Declaration
protected float _tailFadeOutDuration
Field Value
| Type | Description |
|---|---|
| float | Duration in seconds over which the outgoing tail voice fades to silence. |
_tailPreservingLoop
Declaration
protected bool _tailPreservingLoop
Field Value
| Type | Description |
|---|---|
| bool | Whether the track loops with a tail-preserving (dual-source) seam. |
_title
Declaration
protected string _title
Field Value
| Type | Description |
|---|---|
| string | Music track title. |
Methods
GetArtist()
Gets the artist of the music track.
Declaration
public string GetArtist()
Returns
| Type | Description |
|---|---|
| string | The artist of the music track. |
GetEndTime()
Gets the loop-out point in seconds.
Declaration
public float GetEndTime()
Returns
| Type | Description |
|---|---|
| float | The end time, in seconds, where the next loop voice is scheduled. |
GetStartTime()
Gets the loop-return point in seconds.
Declaration
public float GetStartTime()
Returns
| Type | Description |
|---|---|
| float | The start time, in seconds, the tail-preserving loop returns to. |
GetTailFadeOutCurve()
Gets the shape of the tail fade-out curve.
Declaration
public MusicFadeCurve GetTailFadeOutCurve()
Returns
| Type | Description |
|---|---|
| MusicFadeCurve | The selected MusicFadeCurve. |
GetTailFadeOutCurveSamples()
Gets the custom tail fade-out gain table, or null when a preset curve is used.
Declaration
public float[] GetTailFadeOutCurveSamples()
Returns
| Type | Description |
|---|---|
| float[] | The sampled gain table over [0, 1], or null. |
GetTailFadeOutDuration()
Gets the tail fade-out duration in seconds.
Declaration
public float GetTailFadeOutDuration()
Returns
| Type | Description |
|---|---|
| float | The duration over which the outgoing tail fades to silence; 0 cuts at the loop point. |
GetTailPreservingLoop()
Gets whether the track uses tail-preserving looping.
Declaration
public bool GetTailPreservingLoop()
Returns
| Type | Description |
|---|---|
| bool | True when tail-preserving looping is enabled. |
GetTitle()
Gets the title of the music track.
Declaration
public string GetTitle()
Returns
| Type | Description |
|---|---|
| string | The title of the music track. |