Guitarix
trany.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_TRANY_H_
30
#define SRC_HEADERS_TRANY_H_
31
32
/****************************************************************
33
* 1-dimensional function tables for linear interpolation
34
*
35
* table1dt and table1dt_imp<size> must only differ in the last
36
* element, so that the typecast for tranytab 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
table1dt
{
// 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
table1dt_imp
{
51
float
low
;
52
float
high
;
53
float
istep
;
54
int
size
;
55
float
data
[tab_size];
56
operator
table1dt
&()
const
{
return
*(
table1dt
*)
this
; }
57
};
58
59
/*
60
* data tables generated by tools/trany_transfer.py
61
*/
62
#include "
KT88.cc
"
63
#include "
7199P.cc
"
64
65
enum
{
66
TRANY_TABLE_KT88_68k
,
67
TRANY_TABLE_KT88_250k
,
68
TRANY_TABLE_7199P_68k
,
69
TRANY_TABLE_7199P_250k
,
70
TRANY_TABLE_SIZE
71
};
72
73
table1dt
*
tranytab
[
TRANY_TABLE_SIZE
] = {
74
&
static_cast<
table1dt
&
>
(tranytable_KT88[0]),
75
&static_cast<table1dt&>(tranytable_KT88[1]),
76
&
static_cast<
table1dt
&
>
(tranytable_7199P[0]),
77
&static_cast<table1dt&>(tranytable_7199P[1]),
78
};
79
80
/*
81
* definitions for ffunction(float Ftrany(int,float), "valve.h", "");
82
* in gx_amp.dsp - gx_ampmodul.dsp
83
*/
84
85
static
inline
double
Ftrany(
int
table,
double
Vgk) {
86
const
table1dt
& tab = *tranytab[table];
87
double
f = (Vgk - tab.
low
) * tab.
istep
;
88
int
i = static_cast<int>(f);
89
if
(i < 0)
90
return
tab.
data
[0];
91
if
(i >= tab.
size
-1)
92
return
tab.
data
[tab.
size
-1];
93
f -= i;
94
return
tab.
data
[i]*(1-f) + tab.
data
[i+1]*f;
95
}
96
97
#endif // SRC_HEADERS_TRANY_H_
7199P.cc
table1dt::high
float high
Definition:
trany.h:43
TRANY_TABLE_KT88_250k
Definition:
trany.h:67
table1dt::istep
float istep
Definition:
trany.h:44
table1dt_imp
Definition:
trany.h:50
TRANY_TABLE_SIZE
Definition:
trany.h:70
table1dt::low
float low
Definition:
trany.h:42
table1dt
Definition:
trany.h:41
KT88.cc
table1dt_imp::istep
float istep
Definition:
trany.h:53
tranytab
table1dt * tranytab[TRANY_TABLE_SIZE]
Definition:
trany.h:73
table1dt_imp::high
float high
Definition:
trany.h:52
TRANY_TABLE_7199P_68k
Definition:
trany.h:68
table1dt_imp::size
int size
Definition:
trany.h:54
table1dt::data
float data[]
Definition:
trany.h:46
table1dt::size
int size
Definition:
trany.h:45
TRANY_TABLE_KT88_68k
Definition:
trany.h:66
table1dt_imp::low
float low
Definition:
trany.h:51
TRANY_TABLE_7199P_250k
Definition:
trany.h:69
src
gx_head
engine
trany.h
Generated on Tue Oct 25 2016 19:17:41 for Guitarix by
1.8.12