add license headers

This commit is contained in:
2025-11-06 11:05:54 +01:00
parent a362ab6c91
commit 12ae07d115
22 changed files with 739 additions and 108 deletions

View File

@@ -1,4 +1,28 @@
/*
* chebyshev.h
* Copyright (c) 2025 Christopher Herb
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#pragma once
#define _USE_MATH_DEFINES
#include <array>
#include <math.h>
@@ -104,4 +128,4 @@ private:
double state3 = 0;
double passband_ripple = 1;
};
} // namespace trnr
} // namespace trnr

View File

@@ -1,6 +1,30 @@
/*
* spliteq.h
* Copyright (c) 2025 Christopher Herb
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#pragma once
#include "audio_math.h"
#include "smoother.h"
#include "../util/audio_math.h"
#include "../util/smoother.h"
#include <cmath>
#include <vector>
@@ -21,7 +45,8 @@ struct cascade_filter {
std::vector<double> state; // State per stage
};
inline void cascade_filter_setup(cascade_filter& f, filter_type _type, int _stages, double _cutoff, double _samplerate)
inline void cascade_filter_setup(cascade_filter& f, filter_type _type, int _stages,
double _cutoff, double _samplerate)
{
f.type = _type;
f.stages = _stages;
@@ -119,7 +144,8 @@ struct aw_filter {
double samplerate;
};
inline void aw_filter_init(aw_filter& f, filter_type type, float amount, double samplerate)
inline void aw_filter_init(aw_filter& f, filter_type type, float amount,
double samplerate)
{
f.type = type;
f.amount = amount;
@@ -269,7 +295,8 @@ struct spliteq {
smoother transition_smoother;
};
inline void spliteq_init(spliteq& eq, double samplerate, double low_mid_crossover, double mid_high_crossover)
inline void spliteq_init(spliteq& eq, double samplerate, double low_mid_crossover,
double mid_high_crossover)
{
low_mid_crossover /= 2.0;
mid_high_crossover /= 2.0;
@@ -495,8 +522,9 @@ inline void spliteq_process_block(spliteq& eq, float** audio, int frames)
aw_filter_process_block(eq.lp_r, audio[1], frames);
}
inline void spliteq_update(spliteq& eq, double hp_freq, double lp_freq, double low_mid_crossover,
double mid_high_crossover, double bass_gain, double mid_gain, double treble_gain)
inline void spliteq_update(spliteq& eq, double hp_freq, double lp_freq,
double low_mid_crossover, double mid_high_crossover,
double bass_gain, double mid_gain, double treble_gain)
{
low_mid_crossover /= 2.0;
mid_high_crossover /= 2.0;
@@ -534,8 +562,10 @@ inline void spliteq_update(spliteq& eq, double hp_freq, double lp_freq, double l
cascade_filter_setup(eq.bass_l, LOWPASS, 2, eq.low_mid_crossover_adj, eq.samplerate);
cascade_filter_setup(eq.bass_r, LOWPASS, 2, eq.low_mid_crossover_adj, eq.samplerate);
cascade_filter_setup(eq.treble_l, HIGHPASS, 2, eq.mid_high_crossover_adj, eq.samplerate);
cascade_filter_setup(eq.treble_r, HIGHPASS, 2, eq.mid_high_crossover_adj, eq.samplerate);
cascade_filter_setup(eq.treble_l, HIGHPASS, 2, eq.mid_high_crossover_adj,
eq.samplerate);
cascade_filter_setup(eq.treble_r, HIGHPASS, 2, eq.mid_high_crossover_adj,
eq.samplerate);
eq.bass1_l.cutoff = low_mid_crossover;
butterworth_biquad_coeffs(eq.bass1_l, eq.samplerate);
@@ -574,9 +604,10 @@ inline void spliteq_update(spliteq& eq, double hp_freq, double lp_freq, double l
butterworth_biquad_coeffs(eq.treble2_r, eq.samplerate);
}
inline void spliteq_update(spliteq& eq, double bass_gain, double mid_gain, double treble_gain)
inline void spliteq_update(spliteq& eq, double bass_gain, double mid_gain,
double treble_gain)
{
trnr::spliteq_update(eq, eq.hp_l.amount, eq.lp_l.amount, eq.low_mid_crossover * 2.0, eq.mid_high_crossover * 2.0,
bass_gain, mid_gain, treble_gain);
trnr::spliteq_update(eq, eq.hp_l.amount, eq.lp_l.amount, eq.low_mid_crossover * 2.0,
eq.mid_high_crossover * 2.0, bass_gain, mid_gain, treble_gain);
}
} // namespace trnr

View File

@@ -1,3 +1,39 @@
/*
* ysfv.h
* Copyright (c) 2016 Chris Johnson
* Copyright (c) 2025 Christopher Herb
* Based on work:
* - YLowpass by Chris Johnson, 2016
* - YHighpass by Chris Johnson, 2016
* - YBandpass by Chris Johnson, 2016
* - YNotch by Chris Johnson, 2016
* This file is a derivative/major refactor consolidating the above modules.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Changes:
* - 2025-11-06 Christopher Herb:
* - Consolidated YLowpass, YHighpass, YBandpass, YNotch into one (state-variable) filter
* - Templated audio buffer i/o
* - Converted to procedural programming style
*/
#pragma once
#define _USE_MATH_DEFINES
@@ -36,7 +72,7 @@ enum {
Y_BIQ_S_R1,
Y_BIQ_S_R2,
Y_BIQ_TOTAL
}; // coefnncient interpolating biquad filter, stereo
};
enum {
Y_FIX_FREQ,
@@ -51,7 +87,7 @@ enum {
Y_FIX_S_R1,
Y_FIX_S_R2,
Y_FIX_TOTAL
}; // fixed frequency biquad filter for ultrasonics, stereo
};
/////////////
// LOWPASS //
@@ -1104,8 +1140,8 @@ inline void ysvf_set_param(ysvf& y, ysvf_parameters param, float value)
}
template <typename t_sample>
inline void y_process_samples(ysvf& y, t_sample** inputs, t_sample** outputs,
int block_size)
inline void ysvf_process_samples(ysvf& y, t_sample** inputs, t_sample** outputs,
int block_size)
{
switch (y.filter_type) {
case Y_LOWPASS: