Terraria ModLoader  0.11.8
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)
 

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 ()
 

Private Attributes

float[] floatBuf
 
int loopEnd
 
int loopStart
 
VorbisReader reader
 

Additional Inherited Members

- Public Attributes inherited from Terraria.ModLoader.Audio.MusicStreaming
override bool IsPaused => instance != null && instance.State == SoundState.Paused
 
override bool IsPlaying => instance != null && instance.State != SoundState.Stopped
 
- Protected Attributes inherited from Terraria.ModLoader.Audio.MusicStreaming
AudioChannels channels
 
int sampleRate
 
Stream stream
 
- 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

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

Definition at line 218 of file MusicWrappers.cs.

Member Function Documentation

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

Definition at line 260 of file MusicWrappers.cs.

Referenced by Terraria.ModLoader.Mod.LoadSound().

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  }

+ Here is the caller graph for this function:

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)
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  }
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  }
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  }

Member Data Documentation

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

Definition at line 214 of file MusicWrappers.cs.

int Terraria.ModLoader.Audio.MusicStreamingOGG.loopEnd
private

Definition at line 216 of file MusicWrappers.cs.

int Terraria.ModLoader.Audio.MusicStreamingOGG.loopStart
private

Definition at line 215 of file MusicWrappers.cs.

VorbisReader Terraria.ModLoader.Audio.MusicStreamingOGG.reader
private

Definition at line 213 of file MusicWrappers.cs.