BSE Interface Reference

/opt/src/beast/bse/bseresamplerimpl.hh

SYNOPSIS

DESCRIPTION

Bse::Resampler::AlignedArray

/opt/src/beast/bse/bseresamplerimpl.hh:154
class Bse::Resampler::AlignedArray
{
  unsigned char *unaligned_mem;
  T             *data;
  unsigned int   n_elements;
  void  allocate_aligned_data  ();
    BIRNET_PRIVATE_CLASS_COPY  ();
    AlignedArray  (elements);
    AlignedArray  (n_elements);
    ~AlignedArray  ();
  T &  operator[]  (pos);
  const T &  operator[]  (pos);
  unsigned int  size  ();
};

   


  AlignedArray 
(const vector< T >  &elements);

  AlignedArray 
(unsigned int n_elements);

  ~AlignedArray 
();

T &  operator[] 
(unsigned int pos);

const T &  operator[] 
(unsigned int pos);

unsigned int  size 
();

Bse::Resampler::Downsampler2

/opt/src/beast/bse/bseresamplerimpl.hh:413
Factor 2 downsampling of a data stream

Template arguments: ORDER number of resampling filter coefficients USE_SSE whether to use SSE (vectorized) instructions or not
   
void  process_4samples_aligned 
(const float *input_even,
 const float *input_odd,
 float       *output);

float  process_sample_unaligned 
(const float *input_even,
 const float *input_odd);

void  process_block_aligned 
(const float *input_even,
 const float *input_odd,
 float       *output,
 guint        n_output_samples);

void  process_block_unaligned 
(const float *input_even,
 const float *input_odd,
 float       *output,
 guint        n_output_samples);

void  deinterleave2 
(const float *data,
 guint        n_data_values,
 float       *output);

  Downsampler2 
(float *init_taps);
Constructs a Downsampler2 class using a given set of filter coefficients.

init_taps: coefficients for the downsampling FIR halfband filter

void  process_block 
(const float *input,
 guint        n_input_samples,
 float       *output);
The function process_block() takes a block of input samples and produces a block with half the length, containing downsampled output samples.

guint  order 
();
Returns the filter order.

double  delay 
();

Bse::Resampler::Upsampler2

/opt/src/beast/bse/bseresamplerimpl.hh:286
Factor 2 upsampling of a data stream

Template arguments: ORDER number of resampling filter coefficients USE_SSE whether to use SSE (vectorized) instructions or not
   
void  process_4samples_aligned 
(const float *input,
 float       *output);

void  process_sample_unaligned 
(const float *input,
 float       *output);

void  process_block_aligned 
(const float *input,
 guint        n_input_samples,
 float       *output);

void  process_block_unaligned 
(const float *input,
 guint        n_input_samples,
 float       *output);

  Upsampler2 
(float *init_taps);
Constructs an Upsampler2 object with a given set of filter coefficients.

init_taps: coefficients for the upsampling FIR halfband filter

void  process_block 
(const float *input,
 guint        n_input_samples,
 float       *output);
The function process_block() takes a block of input samples and produces a block with twice the length, containing interpolated output samples.

guint  order 
();
Returns the FIR filter order.

double  delay 
();

Resampler2

/opt/src/beast/bse/bseresamplerimpl.hh:413

fir_compute_sse_taps

/opt/src/beast/bse/bseresamplerimpl.hh:138
vector< float >  fir_compute_sse_taps 
(const vector< float >  &taps);
fir_compute_sse_taps takes a normal vector of FIR taps as argument and computes a specially scrambled version of these taps, ready to be used for SSE operations (by fir_process_4samples_sse).

we require a special ordering of the FIR taps, to get maximum benefit of the SSE operations

example: suppose the FIR taps are [ x1 x2 x3 x4 x5 x6 x7 x8 x9 ], then the SSE taps become

[ x1 x2 x3 x4 0 x1 x2 x3 0 0 x1 x2 0 0 0 x1 <- for input[0] x5 x6 x7 x8 x4 x5 x6 x7 x3 x4 x5 x6 x2 x3 x4 x5 <- for input[1] x9 0 0 0 x8 x9 0 0 x7 x8 x9 0 x6 x7 x8 x9 ] <- for input[2] \------------/\-----------/\-----------/\-----------/ for out0 for out1 for out2 for out3

so that we can compute out0, out1, out2 and out3 simultaneously from input[0]..input[2]

fir_process_4samples_sse

/opt/src/beast/bse/bseresamplerimpl.hh:88
void  fir_process_4samples_sse 
(const float *input,
 const float *sse_taps,
 const guint  order,
 float       *out0,
 float       *out1,
 float       *out2,
 float       *out3);
FIR filter routine for 4 samples simultaneously

This routine produces (approximately) the same result as fir_process_one_sample but computes four consecutive output values at once using vectorized SSE instructions. Note that input and sse_taps need to be 16-byte aligned here.

Also note that sse_taps is not a plain impulse response here, but a special version that needs to be computed with fir_compute_sse_taps.

fir_process_one_sample

/opt/src/beast/bse/bseresamplerimpl.hh:63
Accumulator  fir_process_one_sample 
(const float *input,
 const float *taps,
 const guint  order);
FIR filter routine

A FIR filter has the characteristic that it has a finite impulse response, and can be computed by convolution of the input signal with that finite impulse response.

Thus, we use this for computing the output of the FIR filter

output = input[0] * taps[0] + input[1] * taps[1] + ... + input[N-1] * taps[N-1]

where input is the input signal, taps are the filter coefficients, in other texts sometimes called h[0]..h[N-1] (impulse response) or a[0]..a[N-1] (non recursive part of a digital filter), and N is the filter order.

fir_test_filter_sse

/opt/src/beast/bse/bseresamplerimpl.hh:221
bool  fir_test_filter_sse 
(bool        verbose,
 const guint max_order);
This function tests the SSEified FIR filter code (that is, the reordering done by fir_compute_sse_taps and the actual computation implemented in fir_process_4samples_sse).

It prints diagnostic information, and returns true if the filter implementation works correctly, and false otherwise. The maximum filter order to be tested can be optionally specified as argument.