1 /* simple spectrum analyzer
2  *
3  * Copyright (C) 2013 Robin Gareus <robin@gareus.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef FIL4_URIS_H
20 #define FIL4_URIS_H
21 
22 #include "lv2/lv2plug.in/ns/ext/atom/atom.h"
23 #include "lv2/lv2plug.in/ns/ext/atom/forge.h"
24 #include "lv2/lv2plug.in/ns/ext/urid/urid.h"
25 
26 #define FIL4_URI "http://gareus.org/oss/lv2/fil4#"
27 
28 #ifdef HAVE_LV2_1_8
29 #define x_forge_object lv2_atom_forge_object
30 #else
31 #define x_forge_object lv2_atom_forge_blank
32 #endif
33 
34 typedef struct {
35 	LV2_URID atom_Blank;
36 	LV2_URID atom_Object;
37 	LV2_URID atom_Vector;
38 	LV2_URID atom_Float;
39 	LV2_URID atom_Int;
40 	LV2_URID atom_eventTransfer;
41 	LV2_URID rawaudio;
42 	LV2_URID channelid;
43 	LV2_URID audiodata;
44 	LV2_URID samplerate;
45 	LV2_URID ui_on;
46 	LV2_URID ui_off;
47 	LV2_URID state;
48 	LV2_URID s_dbscale;
49 	LV2_URID s_fftmode;
50 	LV2_URID s_fftgain;
51 	LV2_URID s_fftchan;
52 	LV2_URID s_uiscale;
53 	LV2_URID s_kbtuning;
54 } Fil4LV2URIs;
55 
56 static inline void
map_fil4_uris(LV2_URID_Map * map,Fil4LV2URIs * uris)57 map_fil4_uris(LV2_URID_Map* map, Fil4LV2URIs* uris) {
58 	uris->atom_Blank         = map->map(map->handle, LV2_ATOM__Blank);
59 	uris->atom_Object        = map->map(map->handle, LV2_ATOM__Object);
60 	uris->atom_Vector        = map->map(map->handle, LV2_ATOM__Vector);
61 	uris->atom_Float         = map->map(map->handle, LV2_ATOM__Float);
62 	uris->atom_Int           = map->map(map->handle, LV2_ATOM__Int);
63 	uris->atom_eventTransfer = map->map(map->handle, LV2_ATOM__eventTransfer);
64 	uris->rawaudio           = map->map(map->handle, FIL4_URI "rawaudio");
65 	uris->audiodata          = map->map(map->handle, FIL4_URI "audiodata");
66 	uris->samplerate         = map->map(map->handle, FIL4_URI "samplerate");
67 	uris->channelid          = map->map(map->handle, FIL4_URI "channelid");
68 	uris->ui_on              = map->map(map->handle, FIL4_URI "ui_on");
69 	uris->ui_off             = map->map(map->handle, FIL4_URI "ui_off");
70 	uris->state              = map->map(map->handle, FIL4_URI "state");
71 	uris->s_dbscale          = map->map(map->handle, FIL4_URI "dbscale");
72 	uris->s_fftgain          = map->map(map->handle, FIL4_URI "fftgain");
73 	uris->s_fftmode          = map->map(map->handle, FIL4_URI "fftmode");
74 	uris->s_fftchan          = map->map(map->handle, FIL4_URI "fftchannel");
75 	uris->s_uiscale          = map->map(map->handle, FIL4_URI "uiscale");
76 	uris->s_kbtuning         = map->map(map->handle, FIL4_URI "kbtuning");
77 }
78 
79 /* common definitions UI and DSP */
80 
81 typedef enum {
82 	FIL_ATOM_CONTROL = 0, FIL_ATOM_NOTIFY,
83 	FIL_ENABLE,
84 	FIL_GAIN,
85 	FIL_PEAK_DB, FIL_PEAK_RESET,
86 	FIL_HIPASS, FIL_HIFREQ, FIL_HIQ,
87 	FIL_LOPASS, FIL_LOFREQ, FIL_LOQ,
88 
89 	IIR_LS_EN, IIR_LS_FREQ, IIR_LS_Q, IIR_LS_GAIN,
90 
91 	FIL_SEC1, FIL_FREQ1, FIL_Q1, FIL_GAIN1,
92 	FIL_SEC2, FIL_FREQ2, FIL_Q2, FIL_GAIN2,
93 	FIL_SEC3, FIL_FREQ3, FIL_Q3, FIL_GAIN3,
94 	FIL_SEC4, FIL_FREQ4, FIL_Q4, FIL_GAIN4,
95 
96 	IIR_HS_EN, IIR_HS_FREQ, IIR_HS_Q, IIR_HS_GAIN,
97 
98 	FIL_INPUT0, FIL_OUTPUT0,
99 	FIL_INPUT1, FIL_OUTPUT1,
100 	FIL_LAST
101 } PortIndex;
102 
103 #define DEFAULT_YZOOM (30) // [dB] -30..+30, 60dB total range per default
104 
105 #define NSECT (4)
106 
107 /* Low Pass Resonance Map
108  * user    internal    desc
109  * 0.0       0.0         -6dB at freq
110  * 0.71      1.0         -3dB at freq
111  * 1.0       3.0          0dB at freq
112  * 1.4       8.8
113  */
114 #define RESLP(X) (3.f * powf((X), 3.20772f))
115 
116 /* High Pass Resonance Map
117  * user    internal    desc
118  * 0.0       0.0         -6dB at freq
119  * 0.71      0.57        -3dB at freq
120  * 1.00      0.97         0dB at freq
121  * 1.4       1.3
122  */
123 #define RESHP(X) (0.7 + 0.78 * tanh(1.82 * ((X) -.8)))
124 
125 #endif
126