Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2023 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #ifndef MUSE_AUDIO_ALLPASSDISPERSION_H
24 : #define MUSE_AUDIO_ALLPASSDISPERSION_H
25 :
26 : #include "iirbiquadfilter.h"
27 :
28 : namespace muse::audio::fx {
29 : class AllPassDispersion
30 : {
31 : public:
32 0 : AllPassDispersion()
33 0 : {
34 : // these values have been manually tuned to produce a 50-sample IR that has a (low) peak of 0.453731
35 0 : m_processor[0].setTargetCoefficients(IirBiquadFilter::createAllpass2P(0.2492, 2.168, 1.0));
36 0 : m_processor[1].setTargetCoefficients(IirBiquadFilter::createAllpass2P(0.1119, 2.033, 1.0));
37 0 : reset();
38 0 : }
39 :
40 0 : void reset()
41 : {
42 0 : for (auto& p : m_processor) {
43 0 : p.reset();
44 : }
45 0 : }
46 :
47 0 : void process(float** signalPtr, int numCh, int n)
48 : {
49 0 : for (auto& p : m_processor) {
50 0 : p.process(signalPtr, numCh, n);
51 : }
52 0 : }
53 :
54 : void processMonoSample(float& s)
55 : {
56 : for (auto& p : m_processor) {
57 : p.processMonoSample(s);
58 : }
59 : }
60 :
61 : void processStereoSample(float& l, float& r)
62 : {
63 : for (auto& p : m_processor) {
64 : p.processStereoSample(l, r);
65 : }
66 : }
67 :
68 : private:
69 : std::array<IirBiquadFilter::DF1Processor<double>, 2> m_processor;
70 : };
71 : } // namespace muse::audio::fx
72 :
73 : #endif // MUSE_AUDIO_ALLPASSDISPERSION_H
|