Guitarix
valve.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3
* Copyright (C) 2011 Pete Shorthose
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 of the License, or
8
* (at your option) 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, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
* --------------------------------------------------------------------------
19
*
20
*
21
* This file is part of the Guitarix Audio Engine
22
*
23
*
24
* --------------------------------------------------------------------------
25
*/
26
27
#pragma once
28
29
#ifndef SRC_HEADERS_VALVE_H_
30
#define SRC_HEADERS_VALVE_H_
31
32
/****************************************************************
33
* 1-dimensional function tables for linear interpolation
34
*
35
* table1d and table1d_imp<size> must only differ in the last
36
* element, so that the typecast for tubetab below will work.
37
* Can't use inheritance because then C initializers will not
38
* work and initialization will be more awkward or less efficient.
39
*/
40
41
struct
table1d
{
// 1-dimensional function table
42
float
low
;
43
float
high
;
44
float
istep
;
45
int
size
;
46
float
data
[];
47
};
48
49
template
<
int
tab_size>
50
struct
table1d_imp
{
51
float
low
;
52
float
high
;
53
float
istep
;
54
int
size
;
55
float
data
[tab_size];
56
operator
table1d
&()
const
{
return
*(
table1d
*)
this
; }
57
};
58
59
/*
60
* data tables generated by tools/tube_transfer.py
61
*/
62
#include "
12ax7.cc
"
63
#include "
12AU7.cc
"
64
#include "
12AT7.cc
"
65
#include "
6V6.cc
"
66
#include "
6DJ8.cc
"
67
#include "
6C16.cc
"
68
69
enum
{
70
TUBE_TABLE_12AX7_68k
,
71
TUBE_TABLE_12AX7_250k
,
72
TUBE_TABLE_6V6_68k
,
73
TUBE_TABLE_6V6_250k
,
74
TUBE_TABLE_12AU7_68k
,
75
TUBE_TABLE_12AU7_250k
,
76
TUBE_TABLE_6DJ8_68k
,
77
TUBE_TABLE_6DJ8_250k
,
78
TUBE_TABLE_12AT7_68k
,
79
TUBE_TABLE_12AT7_250k
,
80
TUBE_TABLE_6C16_68k
,
81
TUBE_TABLE_6C16_250k
,
82
TUBE_TABLE_SIZE
83
};
84
85
table1d
*
tubetab
[
TUBE_TABLE_SIZE
] = {
86
&
static_cast<
table1d
&
>
(tubetable_12AX7[0]),
87
&
static_cast<
table1d
&
>
(tubetable_12AX7[1]),
88
&
static_cast<
table1d
&
>
(tubetable_6V6[0]),
89
&
static_cast<
table1d
&
>
(tubetable_6V6[1]),
90
&
static_cast<
table1d
&
>
(tubetable_12AU7[0]),
91
&
static_cast<
table1d
&
>
(tubetable_12AU7[1]),
92
&
static_cast<
table1d
&
>
(tubetable_6DJ8[0]),
93
&
static_cast<
table1d
&
>
(tubetable_6DJ8[1]),
94
&
static_cast<
table1d
&
>
(tubetable_12AT7[0]),
95
&
static_cast<
table1d
&
>
(tubetable_12AT7[1]),
96
&
static_cast<
table1d
&
>
(tubetable_6C16[0]),
97
&
static_cast<
table1d
&
>
(tubetable_6C16[1]),
98
};
99
100
/*
101
* definitions for ffunction(float Ftube(int,float), "valve.h", "");
102
* in gx_amp.dsp - gx_ampmodul.dsp
103
*/
104
105
static
inline
double
Ftube(
int
table,
double
Vgk) {
106
const
table1d
& tab = *
tubetab
[table];
107
double
f = (Vgk - tab.
low
) * tab.
istep
;
108
int
i =
static_cast<
int
>
(f);
109
if
(i < 0)
110
return
tab.
data
[0];
111
if
(i >= tab.
size
-1)
112
return
tab.
data
[tab.
size
-1];
113
f -= i;
114
return
tab.
data
[i]*(1-f) + tab.
data
[i+1]*f;
115
}
116
117
#endif // SRC_HEADERS_VALVE_H_
12ax7.cc
TUBE_TABLE_12AX7_250k
@ TUBE_TABLE_12AX7_250k
Definition:
valve.h:71
TUBE_TABLE_12AX7_68k
@ TUBE_TABLE_12AX7_68k
Definition:
valve.h:70
tubetab
table1d * tubetab[TUBE_TABLE_SIZE]
Definition:
valve.h:85
12AU7.cc
table1d_imp::high
float high
Definition:
valve.h:52
table1d_imp::low
float low
Definition:
valve.h:51
table1d::high
float high
Definition:
valve.h:50
table1d
Definition:
valve.h:41
TUBE_TABLE_6C16_250k
@ TUBE_TABLE_6C16_250k
Definition:
valve.h:81
6DJ8.cc
TUBE_TABLE_SIZE
@ TUBE_TABLE_SIZE
Definition:
valve.h:82
table1d_imp::istep
float istep
Definition:
valve.h:53
12AT7.cc
table1d::low
float low
Definition:
valve.h:49
TUBE_TABLE_12AU7_68k
@ TUBE_TABLE_12AU7_68k
Definition:
valve.h:74
TUBE_TABLE_6DJ8_68k
@ TUBE_TABLE_6DJ8_68k
Definition:
valve.h:76
table1d::istep
float istep
Definition:
valve.h:51
TUBE_TABLE_6DJ8_250k
@ TUBE_TABLE_6DJ8_250k
Definition:
valve.h:77
table1d_imp
Definition:
valve.h:50
6C16.cc
TUBE_TABLE_12AT7_250k
@ TUBE_TABLE_12AT7_250k
Definition:
valve.h:79
table1d_imp::data
float data[tab_size]
Definition:
valve.h:55
6V6.cc
TUBE_TABLE_12AU7_250k
@ TUBE_TABLE_12AU7_250k
Definition:
valve.h:75
TUBE_TABLE_12AT7_68k
@ TUBE_TABLE_12AT7_68k
Definition:
valve.h:78
table1d::size
int size
Definition:
valve.h:52
table1d_imp::size
int size
Definition:
valve.h:54
table1d::data
float data[]
Definition:
valve.h:53
TUBE_TABLE_6C16_68k
@ TUBE_TABLE_6C16_68k
Definition:
valve.h:80
TUBE_TABLE_6V6_250k
@ TUBE_TABLE_6V6_250k
Definition:
valve.h:73
TUBE_TABLE_6V6_68k
@ TUBE_TABLE_6V6_68k
Definition:
valve.h:72
src
gx_head
engine
valve.h
Generated on Tue Apr 28 2020 22:17:06 for Guitarix by
1.8.17