bw_buf

Common operations on buffers.

Examples

Here you can download one or more example VST3 plugins for Windows, macOS and Linux. Source code of the audio engine(s) is included in the archive(s).

DescriptionLink
Monophonic subtractive synth Download
Polyphonic subtractive synth Download
Simple monophonic subtractive synth Download
VST® is a trademark of Steinberg Media Technologies GmbH, registered in Europe and other countries.

API

Module type: Utility

bw_buf_fill()

static inline void bw_buf_fill(
	float               k,
	float * BW_RESTRICT dest,
	size_t              n_elems);

Sets the first n_elems in dest to k.

bw_buf_copy()

static inline void bw_buf_copy(
	const float * src,
	float *       dest,
	size_t        n_elems);

Copies the first n_elems in src into the first n_elems of dest.

bw_buf_neg()

static inline void bw_buf_neg(
	const float * src,
	float *       dest,
	size_t        n_elems);

Inverts the sign of the first n_elems in src and stores the results in the first n_elems of dest.

bw_buf_add()

static inline void bw_buf_add(
	const float * src,
	float         k,
	float *       dest,
	size_t        n_elems);

Adds k to the first n_elems in src and stores the results in the first n_elems of dest.

bw_buf_scale()

static inline void bw_buf_scale(
	const float * src,
	float         k,
	float *       dest,
	size_t        n_elems);

Multiplies the first n_elems in src by k and stores the results in the first n_elems of dest.

bw_buf_mix()

static inline void bw_buf_mix(
	const float * src1,
	const float * src2,
	float *       dest,
	size_t        n_elems);

Adds the first n_elems of src1 and src2 and stores the results in the first n_elems of dest.

bw_buf_mul()

static inline void bw_buf_mul(
	const float * src1,
	const float * src2,
	float *       dest,
	size_t        n_elems);

Multiplies the first n_elems of src1 and src2 and stores the results in the first n_elems of dest.

bw_buf_fill_multi()

static inline void bw_buf_fill_multi(
	float                                   k,
	float * BW_RESTRICT const * BW_RESTRICT dest,
	size_t                                  n_channels,
	size_t                                  n_elems);

Sets the first n_elems in each of the n_channels buffers dest to k.

bw_buf_copy_multi()

static inline void bw_buf_copy_multi(
	const float * const * src,
	float * const *       dest,
	size_t                n_channels,
	size_t                n_elems);

Copies the first n_elems in each of the n_channels buffers src into the first n_elems in each of the n_channels buffers dest.

bw_buf_neg_multi()

static inline void bw_buf_neg_multi(
	const float * const * src,
	float * const *       dest,
	size_t                n_channels,
	size_t                n_elems);

Inverts the sign of the first n_elems in each of the n_channels buffers src and stores the results in the first n_elems in each of the n_channels buffers dest.

bw_buf_add_multi()

static inline void bw_buf_add_multi(
	const float * const * src,
	float                 k,
	float * const *       dest,
	size_t                n_channels,
	size_t                n_elems);

Adds k to the first n_elems in each of the n_channels buffers src and stores the results in the first n_elems in each of the n_channels buffers dest.

bw_buf_scale_multi()

static inline void bw_buf_scale_multi(
	const float * const * src,
	float                 k,
	float * const *       dest,
	size_t                n_channels,
	size_t                n_elems);

Multiplies the first n_elems in each of the n_channels buffers src by k and stores the results in the first n_elems in each of the n_channels buffers dest.

bw_buf_mix_multi()

static inline void bw_buf_mix_multi(
	const float * const * src1,
	const float * const * src2,
	float * const *       dest,
	size_t                n_channels,
	size_t                n_elems);

Adds the first n_elems in each of the n_channels buffers src1 and src2 and stores the results in the first n_elems in each of the n_channels buffers dest.

bw_buf_mul_multi()

static inline void bw_buf_mul_multi(
	const float * const * src1,
	const float * const * src2,
	float * const *       dest,
	size_t                n_channels,
	size_t                n_elems);

Multiplies the first n_elems in each of the n_channels buffers src1 and src2 and stores the results in the first n_elems in each of the n_channels buffers dest.

C++ wrapper

Brickworks::bufFill()
template<size_t N_CHANNELS>
inline void bufFill(
	float                                   k,
	float * BW_RESTRICT const * BW_RESTRICT dest,
	size_t                                  nSamples);

# ifndef BW_CXX_NO_ARRAY
template<size_t N_CHANNELS>
inline void bufFill(
	float                                       k,
	std::array<float * BW_RESTRICT, N_CHANNELS> dest,
	size_t                                      nSamples);
# endif
Brickworks::bufCopy()
template<size_t N_CHANNELS>
inline void bufCopy(
	const float * const * src,
	float * const *       dest,
	size_t                nSamples);

# ifndef BW_CXX_NO_ARRAY
template<size_t N_CHANNELS>
inline void bufCopy(
	const std::array<const float *, N_CHANNELS> src,
	const std::array<float *, N_CHANNELS>       dest,
	size_t                                      nSamples);
# endif
Brickworks::bufNeg()
template<size_t N_CHANNELS>
inline void bufNeg(
	const float * const * src,
	float * const *       dest,
	size_t                nSamples);

# ifndef BW_CXX_NO_ARRAY
template<size_t N_CHANNELS>
inline void bufNeg(
	const std::array<const float *, N_CHANNELS> src,
	const std::array<float *, N_CHANNELS>       dest,
	size_t                                      nSamples);
# endif
Brickworks::bufAdd()
template<size_t N_CHANNELS>
inline void bufAdd(
	const float * const * src,
	float                 k,
	float * const *       dest,
	size_t                nSamples);

# ifndef BW_CXX_NO_ARRAY
template<size_t N_CHANNELS>
inline void bufAdd(
	const std::array<const float *, N_CHANNELS> src,
	float                                       k,
	const std::array<float *, N_CHANNELS>       dest,
	size_t                                      nSamples);
# endif
Brickworks::bufScale()
template<size_t N_CHANNELS>
inline void bufScale(
	const float * const * src,
	float                 k,
	float * const *       dest,
	size_t                nSamples);

# ifndef BW_CXX_NO_ARRAY
template<size_t N_CHANNELS>
inline void bufScale(
	const std::array<const float *, N_CHANNELS> src,
	float                                       k,
	const std::array<float *, N_CHANNELS>       dest,
	size_t                                      nSamples);
# endif
Brickworks::bufMix()
template<size_t N_CHANNELS>
inline void bufMix(
	const float * const * src1,
	const float * const * src2,
	float * const *       dest,
	size_t                nSamples);

# ifndef BW_CXX_NO_ARRAY
template<size_t N_CHANNELS>
inline void bufMix(
	const std::array<const float *, N_CHANNELS> src1,
	const std::array<const float *, N_CHANNELS> src2,
	const std::array<float *, N_CHANNELS>       dest,
	size_t                                      nSamples);
# endif
Brickworks::bufMul()
template<size_t N_CHANNELS>
inline void bufMul(
	const float * const * src1,
	const float * const * src2,
	float * const *       dest,
	size_t                nSamples);

# ifndef BW_CXX_NO_ARRAY
template<size_t N_CHANNELS>
inline void bufMul(
	const std::array<const float *, N_CHANNELS> src1,
	const std::array<const float *, N_CHANNELS> src2,
	const std::array<float *, N_CHANNELS>       dest,
	size_t                                      nSamples);
# endif

Changelog

  • Version 1.2.0:
    • Added bw_buf_copy() and bw_buf_copy_multi().
    • Added support for BW_INCLUDE_WITH_QUOTES, BW_NO_CXX, and BW_CXX_NO_EXTERN_C.
    • Added debugging check in bw_buf_{neg,add,scale,mix,mul}_multi() to ensure that buffers used for both input and output appear at the same channel indices.
  • Version 1.1.0:
    • Now using BW_NULL and BW_CXX_NO_ARRAY.
  • Version 1.0.0:
    • Now using size_t instead of BW_SIZE_T.
    • C++ API now uses size_t to count samples.
    • Changed order of arguments to improve consistency.
    • Added more const and BW_RESTRICT specifiers to input arguments.
    • Moved C++ code to C header.
    • Added overloaded C++ functions taking C-style arrays as arguments.
    • Removed usage of reserved identifiers.
    • Now checking that buffers are never NULL and that output buffers are different in debugging code.
  • Version 0.6.0:
    • Added debugging code.
    • Removed dependency on bw_config.
  • Version 0.5.0:
    • Added bw_buf_*_multi().
    • Added bw_buf_neg().
    • Added C++ wrapper.
  • Version 0.4.0:
    • Added bw_buf_fill() and bw_buf_add().
  • Version 0.3.0:
    • First release.