Bauer stereophonic-to-binaural DSP: library description.

The bs2b library is simple to use. See tables 1 and 2 for example. It is a reductive code of 'bs2bstream.c'. The 'bs2b.h' and 'bs2bclass.h' files of the source code package can help also.
You can use a 'bs2bstream' with 'lame' by a command line like this:
  lame -t --decode test.wav - | bs2bstream | lame -r -x -m j -s 44.1 --bitwidth 16 --preset extreme - test.mp3
or without of '-x' swap bytes of input file, like this:
  lame -t --decode test.wav - | bs2bstream | lame -r -m j -s 44.1 --bitwidth 16 --preset extreme - test.mp3

Table 1. Example of using of bs2b library (C).
#include <stdio.h>
#include "bs2b.h"

int main()
{
  t_bs2bdp bs2bdp;
  short sample[ 2 ];

  bs2bdp = bs2b_open();

  /* Default init value
  bs2b_set_srate( bs2bdp, 44100 );
  bs2b_set_level( bs2bdp, BS2B_DEFAULT_CLEVEL ); // 700 Hz, 4.5 dB
  // or another way
  bs2b_set_srate( bs2bdp, 44100 );
  bs2b_set_level_fcut( bs2bdp, 700 ); // 700 Hz
  bs2b_set_level_feed( bs2bdp, 45 );  // 4.5 dB
  */

  /* raw LPCM, signed 16 bit, native to CPU byte order, stereo interleaved */
  while( 2 == fread( sample, sizeof( short ), 2, stdin ) )
  {
    bs2b_cross_feed_s16( bs2bdp, sample );
    fwrite( sample, sizeof( short ), 2, stdout );
  }

  bs2b_close( bs2bdp );
  bs2bdp = 0;

  return 0 ;
}


Sample rate default value is 44100 Hz. Crossfeed level default value is 700 Hz, 4.5 dB. If a sample rate of audio data is different or if you want to change crossfeed level then you must call 'bs2b_set_srate' and 'bs2b_set_level' functions (or 'bs2b_set_srate', 'bs2b_set_level_fcut', 'bs2b_set_level_feed') accordingly.

Table 2. Example of using of bs2b library (C++).
#include <stdio.h>
#include "bs2bclass.h"

int main()
{
  bs2b_base bs2b;

  // Default init value
  //bs2b.set_srate( 44100 );
  //bs2b.set_level( BS2B_DEFAULT_CLEVEL ); // 700 Hz, 4.5 dB
  // or another way
  //bs2b.set_srate( 44100 );
  //bs2b.set_level_fcut( 700 ); // 700 Hz
  //bs2b.set_level_feed( 45 );  // 4.5 dB

  // raw LPCM, signed 16 bit, native to CPU byte order, stereo interleaved
  short sample[ 2 ];
  while( 2 == fread( sample, sizeof( short ), 2, stdin ) )
  {
    bs2b.cross_feed( sample );
    fwrite( sample, sizeof( short ), 2, stdout );
  }

  return 0 ;
}



Copyright (c) 2005-2010  Boris Mikhaylov < http://www.tmn.ru/~bor>