0
1
mirror of https://github.com/radio95-rnt/fm95.git synced 2026-02-26 19:23:51 +01:00
Files
fm95/lib/filters.h
2025-03-23 18:09:18 +01:00

30 lines
710 B
C

#pragma once
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "constants.h"
#include "oscillator.h"
typedef struct
{
float alpha;
float prev_sample;
} ResistorCapacitor;
void init_preemphasis(ResistorCapacitor *filter, float tau, float sample_rate);
float apply_preemphasis(ResistorCapacitor *filter, float sample);
float hard_clip(float sample, float threshold);
typedef struct {
float phase;
float freq;
float loop_filter_state;
float kp;
float ki;
float last_output;
int sample_rate;
int quadrature_mode;
} PLL;
void init_pll(PLL *pll, float freq, float loop_filter_bandwidth, float damping, int quadrature_mode, int sample_rate);
float apply_pll(PLL *pll, float ref_sample);