public void Break() { if(channel == null) return; lock (AudioManager.Instance.workWithListMutex) { channel.Stop(); channel = null; } }
/// <summary> /// Reads an audio clip from the given stream. /// </summary> /// <param name="inputStream">The stream to read from.</param> public AudioClip(Stream inputStream) { underlyingStream = inputStream; StaticChanel = new AudioChannel(AudioManager.Instance.BuffersPerChannel, AudioManager.Instance.BytesPerBuffer); StaticChanel.Init(this); //StaticChanel.Prepare(); AudioManager.Instance.StaticClips.Add(this); //rawClip = new VorbisFile(inputStream); //Cache(64 * 1024); }
/// <summary> /// Constructs an audio clip from the given file. /// </summary> /// <param name="fileName">The file which to read from.</param> public AudioClip(string fileName) { underlyingStream = File.OpenRead(fileName); StaticChanel = new AudioChannel(AudioManager.Instance.BuffersPerChannel, AudioManager.Instance.BytesPerBuffer); StaticChanel.Init(this); //StaticChanel.Prepare(); AudioManager.Instance.StaticClips.Add(this); //rawClip = new VorbisFile(fileName); //Cache(64 * 1024); }
/// <summary> /// Initializes the audio manager. /// </summary> /// <param name="channels">The number of channels to use.</param> /// <param name="buffersPerChannel">The number of buffers each channel will contain.</param> /// <param name="bytesPerBuffer">The number of bytes in each buffer.</param> private void Init(int channels, int buffersPerChannel, int bytesPerBuffer, bool launchThread) { BytesPerBuffer = bytesPerBuffer; BuffersPerChannel = buffersPerChannel; ChannelCount = channels; RunUpdates = launchThread; ChannelCount = channels; Channels = new AudioChannel[channels]; StaticClips = new List<AudioClip>(); for (int i = 0; i < channels; i++) Channels[i] = new AudioChannel(buffersPerChannel, bytesPerBuffer); Instance = this; if(launchThread) { UpdateThread = new Thread(RunUpdateLoop); UpdateThread.IsBackground = true; UpdateThread.Start(); } else { UpdateThread = null; } }
internal void SoftBreak() { channel = null; }
internal AudioRemoteControll(AudioChannel chanell) { this.channel = chanell; }
private void Init(Stream stream, AudioFormat format) { if(format == AudioFormat.Unknown) throw new Exception("Audio format unknown"); Format = format; underlyingStream = stream; StaticChanel = new AudioChannel(AudioManager.Instance.BuffersPerChannel, AudioManager.Instance.BytesPerBuffer); StaticChanel.Init(this); AudioManager.Instance.AddClip(this); if(Format == AudioFormat.OGG) Cache(AudioManager.Instance.BytesPerBuffer * AudioManager.Instance.BuffersPerChannel); }