reckfellENGINE

AudioStreamMP3

MP3 audio stream driver.

On this page
class AudioStreamMP3ReckfellSharpInherits AudioStream

MP3 audio stream driver.

MP3 audio stream driver. See AudioStreamMP3.Data if you want to load an MP3 file at run-time. More info can be found in ResourceImporterMP3. Note: This class can optionally support legacy MP1 and MP2 formats, provided that the engine is compiled with the minimp3_extra_formats=yes SCons option. These extra formats are not enabled by default.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

AudioStreamMP3Constructor
# AudioStreamMP3
C#
public AudioStreamMP3();

Properties6

BarBeatsProperty
# BarBeats
C#
public int BarBeats { get; set; }

Number of musical beats per bar, for example 4 for a four-beat bar. This is composition metadata, not bars within one beat or an automatically analyzed audio value.

BeatCountProperty
# BeatCount
C#
public int BeatCount { get; set; }

The length of the audio track, in beats. The actual duration of the audio file might be longer than what is indicated by this property. It defines the end of the audio for looping, AudioStreamPlaylist, and AudioStreamInteractive.

BpmProperty
# Bpm
C#
public double Bpm { get; set; }

The tempo of the audio track, measured in beats per minute.

DataProperty
# Data
C#
public byte[] Data { get; set; }

Contains the audio data in bytes. You can load a file without having to import it beforehand using the code snippet below. Keep in mind that this snippet loads the whole file into memory and may not be ideal for huge files (hundreds of megabytes or more).

C#
public AudioStreamMP3 LoadMP3(string path)
{
    using var file = FileAccess.Open(path, FileAccess.ModeFlags.Read);
    var sound = new AudioStreamMP3();
    sound.Data = file.GetBuffer(file.GetLength());
    return sound;
}
LoopProperty
# Loop
C#
public bool Loop { get; set; }

If true, the stream will play again from the specified AudioStreamMP3.LoopOffset once it reaches the end of the audio track, or once it reaches the end of the last beat according to the amount specified in AudioStreamMP3.BeatCount. Useful for ambient sounds and background music.

LoopOffsetProperty
# LoopOffset
C#
public double LoopOffset { get; set; }

Loop restart position in seconds when Loop is enabled. It is not a WAV frame index and does not specify an independent loop end. Check it against the actual recording.

Methods16

GetBarBeatsint
# GetBarBeats
C#
public int GetBarBeats();
Returns int
GetBeatCountint
# GetBeatCount
C#
public int GetBeatCount();
Returns int
GetBpmdouble
# GetBpm
C#
public double GetBpm();
Returns double
GetDatabyte[]
# GetData
C#
public byte[] GetData();
Returns byte[]
GetLoopOffsetdouble
# GetLoopOffset
C#
public double GetLoopOffset();
Returns double
HasLoopbool
# HasLoop
C#
public bool HasLoop();
Returns bool
LoadFromBuffer2 overloads
# LoadFromBuffer · 1/2
C#
public static AudioStreamMP3 LoadFromBuffer(byte[] streamData);

Creates a new AudioStreamMP3 instance from the given buffer. The buffer must contain MP3 data.

Parameters
NameTypeDefault
streamDatabyte[]—
Returns AudioStreamMP3
# LoadFromBuffer · 2/2
C#
public static AudioStreamMP3 LoadFromBuffer(ReadOnlySpan<byte> streamData);

Creates a new AudioStreamMP3 instance from the given buffer. The buffer must contain MP3 data.

Parameters
NameTypeDefault
streamDataReadOnlySpan<byte>—
Returns AudioStreamMP3
LoadFromFileAudioStreamMP3
# LoadFromFile
C#
public static AudioStreamMP3 LoadFromFile(string path);

Reads a raw audio file directly without applying editor .import settings. Use ResourceLoader.Load for a project asset with its imported settings. Set loop and music metadata on the result explicitly.

Parameters
NameTypeDefault
pathstring—
path

Path to the actual source file. Ensure it is available in the chosen build; an imported resource path does not guarantee the original bytes are shipped.

Returns AudioStreamMP3

Loaded audio resource, or null on a reading/format error. Check the result before playback.

SetBarBeatsvoid
# SetBarBeats
C#
public void SetBarBeats(int count);
Parameters
NameTypeDefault
countint—
SetBeatCountvoid
# SetBeatCount
C#
public void SetBeatCount(int count);
Parameters
NameTypeDefault
countint—
SetBpmvoid
# SetBpm
C#
public void SetBpm(double bpm);
Parameters
NameTypeDefault
bpmdouble—
SetData2 overloads
# SetData · 1/2
C#
public void SetData(byte[] data);
Parameters
NameTypeDefault
databyte[]—
# SetData · 2/2
C#
public void SetData(ReadOnlySpan<byte> data);
Parameters
NameTypeDefault
dataReadOnlySpan<byte>—
SetLoopvoid
# SetLoop
C#
public void SetLoop(bool enable);
Parameters
NameTypeDefault
enablebool—
SetLoopOffsetvoid
# SetLoopOffset
C#
public void SetLoopOffset(double seconds);
Parameters
NameTypeDefault
secondsdouble—
Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.