bw_ring_mod

Ring modulator with variable modulation amount.

API

Module type: DSP

bw_ring_mod_coeffs

typedef struct bw_ring_mod_coeffs bw_ring_mod_coeffs;

Coefficients and related.

bw_ring_mod_init()

static inline void bw_ring_mod_init(
	bw_ring_mod_coeffs * BW_RESTRICT coeffs);

Initializes input parameter values in coeffs.

bw_ring_mod_set_sample_rate()

static inline void bw_ring_mod_set_sample_rate(
	bw_ring_mod_coeffs * BW_RESTRICT coeffs,
	float                            sample_rate);

Sets the sample_rate (Hz) value in coeffs.

bw_ring_mod_reset_coeffs()

static inline void bw_ring_mod_reset_coeffs(
	bw_ring_mod_coeffs * BW_RESTRICT coeffs);

Resets coefficients in coeffs to assume their target values.

bw_ring_mod_update_coeffs_ctrl()

static inline void bw_ring_mod_update_coeffs_ctrl(
	bw_ring_mod_coeffs * BW_RESTRICT coeffs);

Triggers control-rate update of coefficients in coeffs.

bw_ring_mod_update_coeffs_audio()

static inline void bw_ring_mod_update_coeffs_audio(
	bw_ring_mod_coeffs * BW_RESTRICT coeffs);

Triggers audio-rate update of coefficients in coeffs.

bw_ring_mod_process1()

static inline float bw_ring_mod_process1(
	const bw_ring_mod_coeffs * BW_RESTRICT coeffs,
	float                                  x_mod,
	float                                  x_car);

Processes one modulation input sample x_mod and one carrier input sample x_car using coeffs and returns the corresponding output sample.

bw_ring_mod_process()

static inline void bw_ring_mod_process(
	bw_ring_mod_coeffs * BW_RESTRICT coeffs,
	const float *                    x_mod,
	const float *                    x_car,
	float *                          y,
	size_t                           n_samples);

Processes the first n_samples of the modulation input buffer x_mod and of the carrier input buffer x_car and fills the first n_samples of the output buffer y, while using and updating coeffs (control and audio rate).

bw_ring_mod_process_multi()

static inline void bw_ring_mod_process_multi(
	bw_ring_mod_coeffs * BW_RESTRICT coeffs,
	const float * const *            x_mod,
	const float * const *            x_car,
	float * const *                  y,
	size_t                           n_channels,
	size_t                           n_samples);

Processes the first n_samples of the n_channels modulation input buffers x_mod and of the n_channels carrier input buffers x_car, and fills the first n_samples of the n_channels output buffers y, while using and updating the common coeffs (control and audio rate).

bw_ring_mod_set_amount()

static inline void bw_ring_mod_set_amount(
	bw_ring_mod_coeffs * BW_RESTRICT coeffs,
	float                            value);

Sets the modulation amount parameter to the given value (0.f = no modulation, 1.f = full modulation, -1.f = full modulation with inverted polarity) in coeffs.

Valid range: [-1.f (full modulation with inverted polarity), 1.f (full modulation)].

Default value: 1.f.

bw_ring_mod_coeffs_is_valid()

static inline char bw_ring_mod_coeffs_is_valid(
	const bw_ring_mod_coeffs * BW_RESTRICT coeffs);

Tries to determine whether coeffs is valid and returns non-0 if it seems to be the case and 0 if it is certainly not. False positives are possible, false negatives are not.

coeffs must at least point to a readable memory block of size greater than or equal to that of bw_ring_mod_coeffs.

C++ wrapper

Brickworks::RingMod
template<size_t N_CHANNELS>
class RingMod {
public:
	RingMod();

	void setSampleRate(
		float sampleRate);

	void reset();

	void process(
		const float * const * xMod,
		const float * const * xCar,
		float * const *       y,
		size_t                nSamples);

# ifndef BW_CXX_NO_ARRAY
	void process(
		std::array<const float *, N_CHANNELS> xMod,
		std::array<const float *, N_CHANNELS> xCar,
		std::array<float *, N_CHANNELS>       y,
		size_t                                nSamples);
# endif

	void setAmount(float value);
...
}

Changelog

  • Version 1.2.0:
    • Added support for BW_INCLUDE_WITH_QUOTES, BW_NO_CXX, and BW_CXX_NO_EXTERN_C.
    • Added debugging checks from bw_ring_mod_process() to bw_ring_mod_process_multi().
    • Added debugging checks in bw_ring_mod_process_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:
    • Module renamed as bw_ring_mod.
    • bw_ring_mod_process() and bw_ring_mod_process_multi() now use size_t to count samples and channels.
    • Added more const specifiers to input arguments.
    • Moved C++ code to C header.
    • Added overloaded C++ process() function taking C-style arrays as arguments.
    • Removed usage of reserved identifiers.
    • Fixed inverted-polarity modulation (for real this time).
    • Clearly specified parameter validity ranges.
    • Added debugging code.
  • Version 0.6.0:
    • Removed dependency on bw_config.
  • Version 0.5.0:
    • Added bw_ringmod_process_multi().
    • Fixed inverted-polarity modulation.
    • "modulator signal" -> "modulation signal" in documentation.
    • Added C++ wrapper.
  • Version 0.4.0:
    • First release.