public AudioStreamer(AudioSource source, AudioStream stream, int bufferSampleCount) { if (source == null) throw new ArgumentNullException("source"); if (stream == null) throw new ArgumentNullException("stream"); this.source = source; this.stream = stream; this.bufferSampleCount = bufferSampleCount; this.bufferSamples = new byte[stream.Format.SampleByteSize() * bufferSampleCount]; buffers = new AudioBuffer[4]; for (int index = 0; index < buffers.Length; index++) { buffers[index] = new AudioBuffer(Context); FillBuffer(buffers[index]); } source.Queue(buffers); lock (Context.streamers) { id = nextId++; Context.streamers[id] = this; } }
public MixAudioStream(AudioStream source, bool closeSourceOnClose = false, MixAudioStreamChannels channels = MixAudioStreamChannels.Mix) : base(source, closeSourceOnClose) { Channels = channels; }
public FilterAudioStream(AudioStream source, bool closeSourceOnClose = false) { this.source = source; this.closeSourceOnClose = closeSourceOnClose; }
public AudioStreamer(AudioSource source, AudioStream stream) : this(source, stream, TimeSpan.FromSeconds(1.2)) { }
public AudioStreamer(AudioSource source, AudioStream stream, TimeSpan bufferTime) : this(source, stream, BufferTimeToSamples(stream, bufferTime)) { }
static int BufferTimeToSamples(AudioStream stream, TimeSpan time) { if (stream == null) throw new ArgumentNullException("stream"); return (int)(stream.Frequency.InHertz * time.TotalSeconds); }