A Hopf, Skip and a Jump
Public Types | Public Member Functions | Protected Attributes | List of all members
FrequencyShifter Class Reference

Shift a signal by a given frequency. More...

#include <frequencyshifter.h>

Public Types

enum  HilbertMode { fir, fft }
 

Public Member Functions

 FrequencyShifter (const inputSample_t *inputSignal, const std::size_t inputSignalSize, const double sr, HilbertMode mode=HilbertMode::fir)
 Construct a FrequencyShifter, which uses either an FIR or FFT. More...
 
void shift (const parameter_t fShift, inputSample_t *shiftedSignal, const std::size_t shiftedSignalSize)
 Shift the input signal by the stated amount and fill shiftedSignal. More...
 

Protected Attributes

const inputSample_t * inputSignal
 input signal
 
const std::size_t inputSignalSize
 input signal size
 
std::complex< inputSample_t > * analyticSignal
 Complex array to store results of Hilbert transform.
 
const parameter_t sr
 Sample rate.
 

Detailed Description

Shift a signal by a given frequency.

Use SSB modulation, implemeted via the Hilbert transform (which is itself implemented with FFTs from the FFTW library).

Definition at line 12 of file frequencyshifter.h.

Member Enumeration Documentation

◆ HilbertMode

Enumerator
fir 

FIR.

fft 

FFT.

Definition at line 15 of file frequencyshifter.h.

Constructor & Destructor Documentation

◆ FrequencyShifter()

FrequencyShifter::FrequencyShifter ( const inputSample_t *  inputSignal,
const std::size_t  inputSignalSize,
const double  sr,
HilbertMode  mode = HilbertMode::fir 
)

Construct a FrequencyShifter, which uses either an FIR or FFT.

We rely on the float version (low precision) of FFTW3 for all the transforms, and assume inputSample_t to be float. Make the code work for inputSample_t double or long double (e.g. using templates) is not currently supported. Additionally the double-precision version of the FFTW3 library would have to be linked.

Parameters
inputSignalThe signal to be shifted
inputSignalSizeLength of the signal
srSample rate of the audio
modeFrequencyShifter.fir or FrequencyShifter.fft

Member Function Documentation

◆ shift()

void FrequencyShifter::shift ( const parameter_t  fShift,
inputSample_t *  shiftedSignal,
const std::size_t  shiftedSignalSize 
)

Shift the input signal by the stated amount and fill shiftedSignal.

Parameters
fShiftFrequency by which to shift the signal (Hz)
shiftedSignalOutput buffer
shiftedSignalSizeLength of the output buffer

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