tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.Audio.MusicStreamingOGG Class Reference
+ Inheritance diagram for Terraria.ModLoader.Audio.MusicStreamingOGG:
+ Collaboration diagram for Terraria.ModLoader.Audio.MusicStreamingOGG:

Public Member Functions

 MusicStreamingOGG (string path)
 
override void Reset ()
 
override void Stop (AudioStopOptions options)
 
- Public Member Functions inherited from Terraria.ModLoader.Audio.MusicStreaming
 MusicStreaming (string path)
 
override void CheckBuffer ()
 
void Dispose ()
 
override void Pause ()
 
override void Play ()
 
override void Resume ()
 
override void SetVariable (string name, float value)
 
override void Stop (AudioStopOptions options)
 
virtual void CheckBuffer ()
 
abstract void Pause ()
 
abstract void Play ()
 
abstract void Reset ()
 
abstract void Resume ()
 
abstract void SetVariable (string name, float value)
 
abstract void Stop (AudioStopOptions options)
 

Static Public Member Functions

static void Convert (float[] floatBuf, byte[] buffer)
 
- Static Public Member Functions inherited from Terraria.ModLoader.Audio.Music
static implicit operator Music (Cue cue)
 

Protected Member Functions

override void FillBuffer (byte[] buffer)
 
override void PrepareStream ()
 
virtual void FillBuffer (byte[] buffer)
 
abstract void PrepareStream ()
 

Private Attributes

float[] floatBuf
 
int loopEnd
 
int loopStart
 
VorbisReader reader
 

Additional Inherited Members

- Protected Attributes inherited from Terraria.ModLoader.Audio.MusicStreaming
AudioChannels channels
 
int sampleRate
 
Stream stream
 
- Properties inherited from Terraria.ModLoader.Audio.MusicStreaming
override bool IsPaused [get]
 
override bool IsPlaying [get]
 
- Properties inherited from Terraria.ModLoader.Audio.Music
abstract bool IsPaused [get]
 
abstract bool IsPlaying [get]
 

Detailed Description

Definition at line 211 of file MusicWrappers.cs.

Constructor & Destructor Documentation

◆ MusicStreamingOGG()

Terraria.ModLoader.Audio.MusicStreamingOGG.MusicStreamingOGG ( string  path)

Definition at line 218 of file MusicWrappers.cs.

Member Function Documentation

◆ Convert()

static void Terraria.ModLoader.Audio.MusicStreamingOGG.Convert ( float[]  floatBuf,
byte[]  buffer 
)
static

Definition at line 260 of file MusicWrappers.cs.

260 {
261 for (int i = 0; i < floatBuf.Length; i++) {
262 short val = (short)(floatBuf[i] * short.MaxValue);
263 buffer[i * 2] = (byte)val;
264 buffer[i * 2 + 1] = (byte)(val >> 8);
265 }
266 }

References Terraria.ModLoader.Audio.MusicStreaming.buffer, and Terraria.ModLoader.Audio.MusicStreamingOGG.floatBuf.

Referenced by Terraria.ModLoader.Audio.MusicStreamingOGG.FillBuffer(), and Terraria.ModLoader.Mod.LoadSound().

+ Here is the caller graph for this function:

◆ FillBuffer()

override void Terraria.ModLoader.Audio.MusicStreamingOGG.FillBuffer ( byte[]  buffer)
protectedvirtual

Reimplemented from Terraria.ModLoader.Audio.MusicStreaming.

Definition at line 234 of file MusicWrappers.cs.

234 {
235 if (floatBuf == null)
236 floatBuf = new float[buffer.Length/2];
237
238 int read = reader.ReadSamples(floatBuf, 0, floatBuf.Length);
239 if ((loopEnd > 0 && reader.DecodedPosition >= loopEnd) || read < floatBuf.Length) {
240 reader.DecodedPosition = loopStart;
241 reader.ReadSamples(floatBuf, read, floatBuf.Length - read);
242 }
243
245 }
static void Convert(float[] floatBuf, byte[] buffer)

References Terraria.ModLoader.Audio.MusicStreaming.buffer, Terraria.ModLoader.Audio.MusicStreamingOGG.Convert(), Terraria.ModLoader.Audio.MusicStreamingOGG.floatBuf, Terraria.ModLoader.Audio.MusicStreamingOGG.loopEnd, Terraria.ModLoader.Audio.MusicStreamingOGG.loopStart, and Terraria.ModLoader.Audio.MusicStreamingOGG.reader.

+ Here is the call graph for this function:

◆ PrepareStream()

override void Terraria.ModLoader.Audio.MusicStreamingOGG.PrepareStream ( )
protectedvirtual

Implements Terraria.ModLoader.Audio.MusicStreaming.

Definition at line 220 of file MusicWrappers.cs.

220 {
221 reader = new VorbisReader(stream, true);
222 sampleRate = reader.SampleRate;
223 channels = (AudioChannels)reader.Channels;
224
225 string[] comments = reader.Comments;
226 for (int i = 0; i < comments.Length; i++) {
227 if (comments[i].StartsWith("LOOPSTART"))
228 int.TryParse(comments[i].Split('=')[1], out loopStart);
229 else if (comments[i].StartsWith("LOOPEND"))
230 int.TryParse(comments[i].Split('=')[1], out loopEnd);
231 }
232 }

References Terraria.ModLoader.Audio.MusicStreaming.channels, Terraria.ModLoader.Audio.MusicStreamingOGG.loopEnd, Terraria.ModLoader.Audio.MusicStreamingOGG.loopStart, Terraria.ModLoader.Audio.MusicStreamingOGG.reader, Terraria.ModLoader.Audio.MusicStreaming.sampleRate, and Terraria.ModLoader.Audio.MusicStreaming.stream.

◆ Reset()

override void Terraria.ModLoader.Audio.MusicStreamingOGG.Reset ( )
virtual

Implements Terraria.ModLoader.Audio.Music.

Definition at line 255 of file MusicWrappers.cs.

255 {
256 if (reader != null)
257 reader.DecodedPosition = 0;
258 }

References Terraria.ModLoader.Audio.MusicStreamingOGG.reader.

◆ Stop()

override void Terraria.ModLoader.Audio.MusicStreamingOGG.Stop ( AudioStopOptions  options)
virtual

Reimplemented from Terraria.ModLoader.Audio.MusicStreaming.

Definition at line 247 of file MusicWrappers.cs.

247 {
248 base.Stop(options);
249
250 reader.Dispose();
251 reader = null;
252 floatBuf = null;
253 }

References Terraria.ModLoader.Audio.MusicStreamingOGG.floatBuf, and Terraria.ModLoader.Audio.MusicStreamingOGG.reader.

Member Data Documentation

◆ floatBuf

float [] Terraria.ModLoader.Audio.MusicStreamingOGG.floatBuf
private

◆ loopEnd

int Terraria.ModLoader.Audio.MusicStreamingOGG.loopEnd
private

◆ loopStart

int Terraria.ModLoader.Audio.MusicStreamingOGG.loopStart
private

◆ reader