예제 #1
0
 /// <inheritdoc/>
 void IDisposable.Dispose()
 {
     lock (syncLock)
     {
         stream.Dispose();
         frame.Dispose();
     }
 }
예제 #2
0
        /// <inheritdoc/>
        public void Dispose()
        {
            if (isDisposed)
            {
                return;
            }

            stream.Dispose();
            frame.Dispose();

            fixed(SwrContext **ptr = &swrContext)
            {
                ffmpeg.swr_free(ptr);
            }

            isDisposed = true;
        }
예제 #3
0
        private void DrawVisualization(AudioFrame dataFrame, CanvasDrawingSession ds, bool bDrawVU, bool bDrawLeftChannel, bool bDrawRightChannel, Vector2 barSize, Vector2 offset)
        {
            if (dataFrame != null)
            {
                using (var data = dataFrame.AsVisualizationData())
                {
                    if (bDrawVU)
                    {
                        DrawVU(ds, data.GetRMS(0), data.GetRMS(1));
                    }
                    DrawSpectrogram(data, ds, bDrawLeftChannel, bDrawRightChannel, barSize, offset);
                }
                dataFrame.Dispose();
            }
            else
            {
                if (bDrawVU)
                {
                    DrawVU(ds, -100.0f, -100.0f);
                }

                DrawSpectrogram(null, ds, bDrawLeftChannel, bDrawRightChannel, barSize, offset);
            }
        }
예제 #4
0
 public void Dispose()
 {
     media.Dispose();
     frame.Dispose();
 }
예제 #5
0
        unsafe private void Timer_Tick(object sender, object e)
        {
            try
            {
                AudioFrame audioFrame = frameOutputNode.GetFrame();
                using (AudioBuffer buffer = audioFrame.LockBuffer(AudioBufferAccessMode.Read))
                    using (IMemoryBufferReference memoryBufferReference = buffer.CreateReference())
                    {
                        byte * dataInBytes;
                        uint   capacityInBytes;
                        float *dataInFloat;

                        ((IMemoryBufferByteAccess)memoryBufferReference).GetBuffer(out dataInBytes, out capacityInBytes);
                        dataInFloat = (float *)dataInBytes;

                        Int32   pulseOn             = 0;
                        Int32   pulseOff            = 0;
                        Boolean transitionUpFound   = false;
                        Boolean transitionDownFound = false;
                        Int32   transitionCount     = 0;
                        periodLength = 0;
                        Boolean high = dataInFloat[0] > 0;
                        for (Int32 i = 0; i < capacityInBytes / 8; i++)
                        {
                            if (dataInFloat[i] != 0)
                            {
                                if (dataInFloat[i] < -0.05) // If low
                                {
                                    if (high)               // If was high
                                    {
                                        transitionDownFound = true;
                                        transitionCount++;
                                    }
                                    high = false;
                                }
                                else if (dataInFloat[i] > 0.05) // Is high
                                {
                                    if (!high)                  // If was low
                                    {
                                        transitionUpFound = true;
                                        transitionCount++;
                                    }
                                    high = true;
                                }

                                if (transitionCount > 2)
                                {
                                    periodLength = (int)((pulseOn + pulseOff) / 9.27);
                                    break;
                                }

                                if (high && transitionUpFound)
                                {
                                    pulseOn++;
                                }
                                else if (!high && transitionDownFound)
                                {
                                    pulseOff++;
                                }
                            }
                        }
                        dataInFloat = null;
                        dataInBytes = null;
                        memoryBufferReference.Dispose();
                        buffer.Dispose();
                        audioFrame.Dispose();
                        periodLengthUK101 = periodLength;
                    }
            } catch { }
            //audioFrame = frameOutputNode.GetFrame();
            audioGraph.Stop();
            audioGraph.ResetAllNodes();
            audioGraph.Start();
        }
예제 #6
0
 /// <summary>
 /// Releases all unmanaged resources associated with this instance.
 /// </summary>
 public void Dispose()
 {
     frame.Dispose();
 }