Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::signal::FrequencyShifterT< SampleType > Class Template Reference

Shifts every frequency in a signal by the same number of Hz. More...

#include <frequency_shifter.hpp>

Public Member Functions

void set_sample_rate (double sr)
void set_shift_hz (double hz)
 Amount to add to every frequency, in Hz. Negative shifts downward.
double shift_hz () const
void reset ()
SampleType process (SampleType input)

Detailed Description

template<typename SampleType = float>
class pulp::signal::FrequencyShifterT< SampleType >

Shifts every frequency in a signal by the same number of Hz.

This is not a pitch shift and the difference is the entire point. A pitch shift multiplies every partial by a ratio, so a harmonic series stays harmonic and the sound keeps its identity at a new pitch. A frequency shift adds a constant, so a series at 100, 200, 300 Hz becomes 130, 230, 330 Hz — no longer integer multiples of anything. The result has no fundamental and no pitch, which is exactly what is wanted when a bank of resonators is ringing on a chord and the chord is the problem: a shift of a few tens of hertz turns tuned metal into a cymbal.

Implemented by single-sideband modulation: split the input into a quadrature pair, modulate each by a sine and cosine at the shift frequency, and subtract. Adding instead of subtracting selects the other sideband, which is why the shift can go down as well as up — here that is reached by the sign of set_shift_hz, which runs the carrier's phase accumulator backwards.

Member Function Documentation

◆ process()

template<typename SampleType = float>
SampleType pulp::signal::FrequencyShifterT< SampleType >::process ( SampleType input)
inline

◆ reset()

template<typename SampleType = float>
void pulp::signal::FrequencyShifterT< SampleType >::reset ( )
inline

◆ set_sample_rate()

template<typename SampleType = float>
void pulp::signal::FrequencyShifterT< SampleType >::set_sample_rate ( double sr)
inline

◆ set_shift_hz()

template<typename SampleType = float>
void pulp::signal::FrequencyShifterT< SampleType >::set_shift_hz ( double hz)
inline

Amount to add to every frequency, in Hz. Negative shifts downward.

◆ shift_hz()

template<typename SampleType = float>
double pulp::signal::FrequencyShifterT< SampleType >::shift_hz ( ) const
inline

The documentation for this class was generated from the following file: