This acts as a stream for producing audio data.
Inheritance: Stream
Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
 public MixAudioStream(AudioStream source, bool closeSourceOnClose = false, MixAudioStreamChannels channels = MixAudioStreamChannels.Mix)
     : base(source, closeSourceOnClose)
 {
     Channels = channels;
 }
Esempio n. 3
0
 public FilterAudioStream(AudioStream source, bool closeSourceOnClose = false)
 {
     this.source = source;
     this.closeSourceOnClose = closeSourceOnClose;
 }
Esempio n. 4
0
 public MixAudioStream(AudioStream source, bool closeSourceOnClose = false, MixAudioStreamChannels channels = MixAudioStreamChannels.Mix)
     : base(source, closeSourceOnClose)
 {
     Channels = channels;
 }
Esempio n. 5
0
 public FilterAudioStream(AudioStream source, bool closeSourceOnClose = false)
 {
     this.source             = source;
     this.closeSourceOnClose = closeSourceOnClose;
 }
Esempio n. 6
0
 public AudioStreamer(AudioSource source, AudioStream stream) : this(source, stream, TimeSpan.FromSeconds(1.2))
 {
 }
Esempio n. 7
0
 public AudioStreamer(AudioSource source, AudioStream stream, TimeSpan bufferTime) : this(source, stream, BufferTimeToSamples(stream, bufferTime))
 {
 }
Esempio n. 8
0
 public AudioStreamer(AudioSource source, AudioStream stream)
     : this(source, stream, TimeSpan.FromSeconds(1.2))
 {
 }
Esempio n. 9
0
 public AudioStreamer(AudioSource source, AudioStream stream, TimeSpan bufferTime)
     : this(source, stream, BufferTimeToSamples(stream, bufferTime))
 {
 }
Esempio n. 10
0
 static int BufferTimeToSamples(AudioStream stream, TimeSpan time)
 {
     if (stream == null)
         throw new ArgumentNullException("stream");
     return (int)(stream.Frequency.InHertz * time.TotalSeconds);
 }