-
Notifications
You must be signed in to change notification settings - Fork 0
/
waveshaper.h
90 lines (78 loc) · 2.41 KB
/
waveshaper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* Copyright (C) 2017 taylor.fish <[email protected]>
*
* This file is part of Fish Waveshaper.
*
* Fish Waveshaper is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fish Waveshaper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Fish Waveshaper. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WAVESHAPER_H
#define WAVESHAPER_H
#include "cspline.h"
#include "ports.h"
#include "utils.h"
#include <lv2/lv2plug.in/ns/lv2core/lv2.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
// Constants
enum {
NUM_POINTS = NUM_USER_POINTS + 3,
NUM_SPLINES = NUM_POINTS - 1,
PORTS_PER_POINT = 6,
};
typedef struct {
const float *xs[NUM_POINTS];
const float *ys[NUM_POINTS];
const float *types[NUM_SPLINES];
const float *tensions[NUM_SPLINES];
const float *tangent1_vals[NUM_SPLINES];
const float *tangent2_vals[NUM_SPLINES];
const float *display_plot;
const float *oversample;
const float *input_gain;
const float *output_gain;
const float *monitor_levels;
float *input_level;
float *input_clip;
float *output_level;
float *output_0db;
const float *asymmetric;
float old_xs[NUM_POINTS];
float old_ys[NUM_POINTS];
float old_types[NUM_SPLINES];
float old_tensions[NUM_SPLINES];
float old_tangent1_vals[NUM_SPLINES];
float old_tangent2_vals[NUM_SPLINES];
bool old_display_plot;
uint_fast8_t old_oversample_multiplier;
bool old_monitor_levels;
bool old_asymmetric;
uint32_t sample_rate;
const float *inputs[2];
float *outputs[2];
SplineParams splines[NUM_POINTS + 1];
size_t num_splines;
FILE *gnuplot;
LowpassParams lp1[2];
LowpassParams lp2[2];
float *oversample_buf;
size_t oversample_buf_size;
uint32_t reset_input_clip_after;
uint32_t reset_output_0db_after;
uint32_t samples_since_update_check;
} Waveshaper;
LV2_SYMBOL_EXPORT
const LV2_Descriptor *lv2_descriptor(uint32_t index);
#endif