buffer_new

From an input data stream, formatted in arbitrary packet sizes, produce a data stream with a fixed packet length.

Namespace: dsp

Prototype

sptr<Sink<T, int>> buffer_new(int N, fonction<void(const Vector<T> &)> callback)

Parameters

NOutput packets length
callbackUser function which will be called for each output packet of size \(N\)

Returns

A data sink accepting vectors of type T and of arbitrary length.

Description

From an input data stream, formatted in arbitrary packet sizes, produce a data stream with a fixed packet length.

Example: preparation of packets for a FFT


  soit t = tampon_création<float>(512,
      // Définition de la callback
      [](const Vecf &x)
      {
        // Ici, on est certain d'avoir 512 échantillons
        assertion(x.rows() == 512);
        soit X = fft(x);
      });

  // 10000 échantillons à traiter
  Vecf x(10000);

  // x = ...

  // Traite les échantillons, par paquets de 512
  t->step(x);


Note that 10000 not being a multiple of 512, the last samples are not processed (they would be if the method t->step()) is called with more samples).