Terraria ModLoader  0.11.7.7
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 210 of file MusicWrappers.cs.

Constructor & Destructor Documentation

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

Definition at line 217 of file MusicWrappers.cs.

Member Function Documentation

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

Definition at line 259 of file MusicWrappers.cs.

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

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

+ 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 233 of file MusicWrappers.cs.

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

Implements Terraria.ModLoader.Audio.MusicStreaming.

Definition at line 219 of file MusicWrappers.cs.

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

Implements Terraria.ModLoader.Audio.Music.

Definition at line 254 of file MusicWrappers.cs.

254  {
255  if (reader != null)
256  reader.DecodedPosition = 0;
257  }
override void Terraria.ModLoader.Audio.MusicStreamingOGG.Stop ( AudioStopOptions  options)
virtual

Reimplemented from Terraria.ModLoader.Audio.MusicStreaming.

Definition at line 246 of file MusicWrappers.cs.

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

Member Data Documentation

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

Definition at line 213 of file MusicWrappers.cs.

int Terraria.ModLoader.Audio.MusicStreamingOGG.loopEnd
private

Definition at line 215 of file MusicWrappers.cs.

int Terraria.ModLoader.Audio.MusicStreamingOGG.loopStart
private

Definition at line 214 of file MusicWrappers.cs.

VorbisReader Terraria.ModLoader.Audio.MusicStreamingOGG.reader
private

Definition at line 212 of file MusicWrappers.cs.