Exemplo n.º 1
0
 protected override void FillBuffer(float[] buffer, int offset, int count)
 {
     if (DoRead)
     {
         InputSignal.Read(buffer, offset, count);
         if (WritePosition >= FBufferSize)
         {
             WritePosition %= FBufferSize;
         }
         var copyCount = Math.Min(FBufferSize - WritePosition, count);
         Array.Copy(buffer, 0, FBuffer, WritePosition, copyCount);
         if (copyCount < count)                //copy rest to front
         {
             Array.Copy(buffer, 0, FBuffer, 0, count - copyCount);
         }
         WritePosition += count;
     }
     //do preview
     if (PreviewSize > 0)
     {
         if (Preview.Length != PreviewSize)
         {
             Preview = new float[PreviewSize];
         }
         var stepsize = (FBufferSize / PreviewSize) + 1;
         var index    = 0;
         for (int i = stepsize / 2; i < FBufferSize; i += stepsize)
         {
             Preview[index] = FBuffer[i];
             index++;
         }
     }
 }
Exemplo n.º 2
0
        protected override void FillBuffer(float[] buffer, int offset, int count)
        {
            if (InputSignal.Value != null)
            {
                InputSignal.Read(buffer, offset, count);

                //just output the latest value
                Value = buffer[count - 1];
            }
        }
Exemplo n.º 3
0
 protected override void FillBuffer(float[] buffer, int offset, int count)
 {
     if (InputSignal.Value != null)
     {
         InputSignal.Read(buffer, offset, count);
         FDecoder.Write(buffer, count, 0);
         if (FDecoder.GetQueueLength() > 0)
         {
             Timecode = FDecoder.Read().getTimecode();
         }
     }
 }
Exemplo n.º 4
0
 protected override void FillBuffer(float[] buffer, int offset, int count)
 {
     if (InputSignal.Value != null)
     {
         InputSignal.Read(buffer, offset, count);
         var max = 0.0;
         for (int i = offset; i < count; i++)
         {
             max = Math.Max(max, Math.Abs(buffer[i]));
         }
         Max = max;
     }
 }
Exemplo n.º 5
0
        protected override void FillBuffer(float[] buffer, int offset, int count)
        {
            if (FBTrack != null && isValid)
            {
                InputSignal.Read(buffer, offset, count);
                //base.FillBuffer(buffer, offset, count);
                FBTrack.ProcessFrame(buffer, count);

                if (FBTrack.Beat)
                {
                    beatReadFlag = false;
                }
                Beat.Value = beatReadFlag ? false : true;   // return true as long as beat was not yet registered by node
                Bpm.Value  = FBTrack.Bpm;
            }
        }
Exemplo n.º 6
0
        protected override void FillBuffer(float[] buffer, int offset, int count)
        {
            if (FGist != null)
            {
                InputSignal.Read(buffer, offset, count);
                //base.FillBuffer(buffer, offset, count);
                FGist.ProcessFrame(buffer, count);
                FFT.Value = FGist.SpectrumData;

                //get flags
                AudioFeaturesFlags flags = (AudioFeaturesFlags)2047;

                var features = FGist.GetFeatures(flags);
                var vals     = new float[11];
                features.Values.CopyTo(vals, 0);
                Features.Value = vals;
            }
        }
Exemplo n.º 7
0
        protected override void FillBuffer(float[] buffer, int offset, int count)
        {
            if (BufferOut.Length != Buffer.Size)
            {
                BufferOut = new float[Buffer.Size];
            }

            if (InputSignal.Value != null)
            {
                InputSignal.Read(buffer, offset, count);
                Buffer.Write(buffer, offset, count);
            }
            else
            {
                buffer.ReadSilence(offset, count);
                Buffer.Write(buffer, offset, count);
            }
        }
Exemplo n.º 8
0
        protected override void FillBuffer(float[] buffer, int offset, int count)
        {
            if (InputSignal.Value != null)
            {
                InputSignal.Read(buffer, offset, count);

                //write to buffer
                FRingBuffer.Write(buffer, offset, count);

                //calc fft
                var fftSize = FRingBuffer.Size;

                if (FFFTBuffer.Length != fftSize)
                {
                    FFFTBuffer = new double[fftSize];
                    FFTOut     = new double[fftSize];
                    FWindow    = AudioUtils.CreateWindowDouble(fftSize, WindowFunc);
                }

                FRingBuffer.ReadDoubleWindowed(FFFTBuffer, FWindow, 0, fftSize);
                FFFT.RealFFT(FFFTBuffer, true);
                Array.Copy(FFFTBuffer, FFTOut, fftSize);
            }
        }