[go: up one dir, main page]

File: ToneControls.cc

package info (click to toggle)
caps 0.3.0-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 888 kB
  • ctags: 1,273
  • sloc: cpp: 9,837; ansic: 584; makefile: 62
file content (73 lines) | stat: -rw-r--r-- 1,681 bytes parent folder | download | duplicates (2)
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
/*
	ToneControls.cc
	
	Copyright 2004-5 Tim Goetze <tim@quitte.de>
	
	http://quitte.de/dsp/

	4-way Eq for amplifier emulation plugins
*/
/*
	This program 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 2
	of the License, or (at your option) any later version.

	This program 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 this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
	02111-1307, USA or point your web browser to http://www.gnu.org.
*/

#include "basics.h"
#include <stdio.h>

#include "Amp.h"

PreampBand 
ToneControls::bands[] = 
{
	/*  f,    Q,    g */
	{  80, 1.20, 1.61},
	{ 300, 1.10, 1.10},
	{1200, 1.14, 1.07},
	{4800,  .80, 1.06}
};

void
ToneControls::init (double fs)
{
	for (int i = 0; i < 4; ++i)
		eq.init_band (i, 2 * bands[i].center * M_PI / fs, bands[i].Q);
}

double 
ToneControls::get_band_gain (int i, double g)
{
	return bands[i].adjust * DSP::db2lin (g);
}

void
ToneControls::set_band_gain (int i, float g)
{
	/* sorry, _ != . but hardly readable -- the difference is between local
	 * buffered value and actual Eq band gain */
	eq_gain[i] = g;
	eq.gain[i] = get_band_gain (i, g);
}

void
ToneControls::activate (d_sample ** ports)
{
	for (int i = 0; i < 4; ++i)
		set_band_gain (i, *ports[i]);

	eq.reset();
}