3 using Microsoft.Xna.Framework;
9 abstract class Sound : IDisposable
27 public bool Loading {
get;
protected set; }
34 return sourcePoolIndex;
68 Filename = getFullPath ? Path.GetFullPath(filename.CleanUpPath()).CleanUpPath() : filename;
81 return GetType().ToString() +
" (" +
Filename +
")";
95 DebugConsole.AddWarning($
"Attempted to play the sound {this} while it was still loading.");
102 public virtual SoundChannel Play(
float gain,
float range, Vector2 position,
bool muffle =
false)
105 return new SoundChannel(
this, gain,
new Vector3(position.X, position.Y, 0.0f), 1.0f, range * 0.4f, range,
"default", muffle);
108 public virtual SoundChannel Play(
float gain,
float range,
float freqMult, Vector2 position,
bool muffle =
false)
111 return new SoundChannel(
this, gain,
new Vector3(position.X, position.Y, 0.0f), freqMult, range * 0.4f, range,
"default", muffle);
114 public virtual SoundChannel Play(Vector3? position,
float gain,
float freqMult = 1.0f,
bool muffle =
false)
122 return Play(
null, gain);
136 static protected void CastBuffer(
float[] inBuffer,
short[] outBuffer,
int length)
138 for (
int i = 0; i < length; i++)
140 outBuffer[i] = ToolBox.FloatToShortAudioSample(inBuffer[i]);
static void CastBuffer(float[] inBuffer, short[] outBuffer, int length)
virtual SoundManager.SourcePoolIndex SourcePoolIndex
int MaxSimultaneousInstances
How many instances of the same sound clip can be playing at the same time
override string ToString()
virtual SoundChannel Play()
virtual void FillAlBuffers()
Sound(SoundManager owner, string filename, bool stream, bool streamsReliably, ContentXElement xElement=null, bool getFullPath=true)
readonly ContentXElement XElement
virtual SoundChannel Play(float gain)
bool LogWarningIfStillLoading()
abstract int FillStreamBuffer(int samplePos, short[] buffer)
virtual void InitializeAlBuffers()
readonly bool StreamsReliably
virtual void DeleteAlBuffers()
abstract float GetAmplitudeAtPlaybackPos(int playbackPos)
readonly SoundManager Owner
virtual SoundChannel Play(float gain, float range, float freqMult, Vector2 position, bool muffle=false)
virtual SoundChannel Play(float gain, float range, Vector2 position, bool muffle=false)
virtual SoundChannel Play(float? gain, string category)
virtual SoundChannel Play(Vector3? position, float gain, float freqMult=1.0f, bool muffle=false)
int CountPlayingInstances(Sound sound)
void RemoveSound(Sound sound)
bool IsPlaying(Sound sound)
void KillChannels(Sound sound)