Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/servers/audio/effects/audio_effect_eq.h
10278 views
1
/**************************************************************************/
2
/* audio_effect_eq.h */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#pragma once
32
33
#include "servers/audio/audio_effect.h"
34
#include "servers/audio/effects/eq_filter.h"
35
36
class AudioEffectEQ;
37
38
class AudioEffectEQInstance : public AudioEffectInstance {
39
GDCLASS(AudioEffectEQInstance, AudioEffectInstance);
40
friend class AudioEffectEQ;
41
Ref<AudioEffectEQ> base;
42
43
Vector<EQ::BandProcess> bands[2];
44
Vector<float> gains;
45
46
public:
47
virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) override;
48
};
49
50
class AudioEffectEQ : public AudioEffect {
51
GDCLASS(AudioEffectEQ, AudioEffect);
52
53
friend class AudioEffectEQInstance;
54
55
EQ eq;
56
Vector<float> gain;
57
HashMap<StringName, int> prop_band_map;
58
Vector<String> band_names;
59
60
protected:
61
bool _set(const StringName &p_name, const Variant &p_value);
62
bool _get(const StringName &p_name, Variant &r_ret) const;
63
void _get_property_list(List<PropertyInfo> *p_list) const;
64
65
static void _bind_methods();
66
67
public:
68
Ref<AudioEffectInstance> instantiate() override;
69
void set_band_gain_db(int p_band, float p_volume);
70
float get_band_gain_db(int p_band) const;
71
int get_band_count() const;
72
73
AudioEffectEQ(EQ::Preset p_preset = EQ::PRESET_6_BANDS);
74
};
75
76
class AudioEffectEQ6 : public AudioEffectEQ {
77
GDCLASS(AudioEffectEQ6, AudioEffectEQ);
78
79
public:
80
AudioEffectEQ6() :
81
AudioEffectEQ(EQ::PRESET_6_BANDS) {}
82
};
83
84
class AudioEffectEQ10 : public AudioEffectEQ {
85
GDCLASS(AudioEffectEQ10, AudioEffectEQ);
86
87
public:
88
AudioEffectEQ10() :
89
AudioEffectEQ(EQ::PRESET_10_BANDS) {}
90
};
91
92
class AudioEffectEQ21 : public AudioEffectEQ {
93
GDCLASS(AudioEffectEQ21, AudioEffectEQ);
94
95
public:
96
AudioEffectEQ21() :
97
AudioEffectEQ(EQ::PRESET_21_BANDS) {}
98
};
99
100