Exemple #1
0
 public WavPlayer(IBufferAllocator <byte> bufferAllocator)
 {
     this.bufferAllocator = bufferAllocator;
     WaveOut        = new WaveOut();
     CurrentSegment = null;
     Position       = 0;
 }
Exemple #2
0
 private void RemoveCurrentSegment()
 {
     if (CurrentSegment == null)
     {
         return;
     }
     bufferAllocator.ReturnBuffer(CurrentSegment.Data);
     CurrentSegment = CurrentSegment.NextSegment;
 }
Exemple #3
0
        public void AddAudioData(long startByte, byte[] data)
        {
            AudioSegment segment = new AudioSegment()
            {
                StartIndex = startByte,
                Data       = data
            };

            if (CurrentSegment == null)
            {
                if (startByte + data.Length > Position)
                {
                    CurrentSegment = segment;
                }
            }
            else
            {
                CurrentSegment.Insert(segment);
            }
        }
Exemple #4
0
 public void Insert(AudioSegment newSegment)
 {
     if (NextSegment == null)
     {
         if (newSegment.StartIndex + newSegment.Data.Length > StartIndex + Data.Length)
         {
             NextSegment = newSegment;
         }
     }
     else
     {
         if (newSegment.StartIndex < NextSegment.StartIndex)
         {
             newSegment.NextSegment = NextSegment;
             NextSegment            = newSegment;
         }
         else
         {
             NextSegment.Insert(newSegment);
         }
     }
 }