parent
f2fcd10b2b
commit
d98fdd9997
@ -0,0 +1,143 @@ |
||||
/*
|
||||
MicroDexed |
||||
|
||||
MicroDexed is a port of the Dexed sound engine |
||||
(https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6/4.x with audio shield.
|
||||
Dexed ist heavily based on https://github.com/google/music-synthesizer-for-android
|
||||
|
||||
(c)2018-2021 H. Wirtz <wirtz@parasitstudio.de> |
||||
|
||||
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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#include <Arduino.h> |
||||
#include <Audio.h> |
||||
#include "control_sgtl5000plus.h" |
||||
|
||||
void AudioControlSGTL5000Plus::init_parametric_eq(void) |
||||
{ |
||||
eqSelect(PARAMETRIC_EQUALIZER); |
||||
eqFilterCount(num_bands); |
||||
|
||||
filter_type = new uint8_t[num_bands]; |
||||
Fc = new float[num_bands]; |
||||
Q = new float[num_bands]; |
||||
peakGainDB = new float[num_bands]; |
||||
|
||||
setEQType(1, GRAPHIC_EQ_TYPE_0); |
||||
setEQFc(1, GRAPHIC_EQ_CENTER_FRQ_0); |
||||
setEQQ(1, GRAPHIC_EQ_Q_0); |
||||
setEQGain(1, 0.0); |
||||
|
||||
if (num_bands > 1) |
||||
{ |
||||
setEQType(2, GRAPHIC_EQ_TYPE_1); |
||||
setEQFc(2, GRAPHIC_EQ_CENTER_FRQ_1); |
||||
setEQQ(2, GRAPHIC_EQ_Q_1); |
||||
setEQGain(2, 0.0); |
||||
} |
||||
|
||||
if (num_bands > 2) |
||||
{ |
||||
setEQType(3, GRAPHIC_EQ_TYPE_2); |
||||
setEQFc(3, GRAPHIC_EQ_CENTER_FRQ_2); |
||||
setEQQ(3, GRAPHIC_EQ_Q_2); |
||||
setEQGain(3, 0.0); |
||||
} |
||||
|
||||
if (num_bands > 3) |
||||
{ |
||||
setEQType(4, GRAPHIC_EQ_TYPE_3); |
||||
setEQFc(4, GRAPHIC_EQ_CENTER_FRQ_3); |
||||
setEQQ(4, GRAPHIC_EQ_Q_3); |
||||
setEQGain(4, 0.0); |
||||
} |
||||
|
||||
if (num_bands > 4) |
||||
{ |
||||
setEQType(5, GRAPHIC_EQ_TYPE_4); |
||||
setEQFc(5, GRAPHIC_EQ_CENTER_FRQ_4); |
||||
setEQQ(5, GRAPHIC_EQ_Q_4); |
||||
setEQGain(5, 0.0); |
||||
} |
||||
|
||||
if (num_bands > 5) |
||||
{ |
||||
setEQType(6, GRAPHIC_EQ_TYPE_5); |
||||
setEQFc(6, GRAPHIC_EQ_CENTER_FRQ_5); |
||||
setEQQ(6, GRAPHIC_EQ_Q_5); |
||||
setEQGain(6, 0.0); |
||||
} |
||||
|
||||
if (num_bands > 6) |
||||
{ |
||||
setEQType(7, GRAPHIC_EQ_TYPE_6); |
||||
setEQFc(7, GRAPHIC_EQ_CENTER_FRQ_6); |
||||
setEQQ(7, GRAPHIC_EQ_Q_6); |
||||
setEQGain(7, 0.0); |
||||
} |
||||
} |
||||
|
||||
void AudioControlSGTL5000Plus::setEQType(uint8_t band, uint8_t ft) |
||||
{ |
||||
if (filter_type) |
||||
{ |
||||
int filter[5]; |
||||
|
||||
band = constrain(band, 1, num_bands); |
||||
filter_type[band - 1] = ft; |
||||
calcBiquad(filter_type[band - 1], Fc[band - 1], peakGainDB[band - 1], Q[band - 1], 524288, AUDIO_SAMPLE_RATE, filter); |
||||
//eqFilter(band, filter);
|
||||
} |
||||
} |
||||
|
||||
void AudioControlSGTL5000Plus::setEQFc(uint8_t band, float frq) |
||||
{ |
||||
if (Fc) |
||||
{ |
||||
int filter[5]; |
||||
|
||||
band = constrain(band, 1, num_bands); |
||||
Fc[band - 1] = frq; |
||||
calcBiquad(filter_type[band - 1], Fc[band - 1], peakGainDB[band - 1], Q[band - 1], 524288, AUDIO_SAMPLE_RATE, filter); |
||||
//eqFilter(band, filter);
|
||||
} |
||||
} |
||||
|
||||
void AudioControlSGTL5000Plus::setEQQ(uint8_t band, float q) |
||||
{ |
||||
if (Q) |
||||
{ |
||||
int filter[5]; |
||||
|
||||
band = constrain(band, 1, num_bands); |
||||
Q[band - 1] = q; |
||||
calcBiquad(filter_type[band - 1], Fc[band - 1], peakGainDB[band - 1], Q[band - 1], 524288, AUDIO_SAMPLE_RATE, filter); |
||||
//eqFilter(band, filter);
|
||||
} |
||||
} |
||||
|
||||
void AudioControlSGTL5000Plus::setEQGain(uint8_t band, float gain) |
||||
{ |
||||
if (peakGainDB) |
||||
{ |
||||
int filter[5]; |
||||
|
||||
band = constrain(band, 1, num_bands); |
||||
peakGainDB[band - 1] = gain; |
||||
calcBiquad(filter_type[band - 1], Fc[band - 1], peakGainDB[band - 1], Q[band - 1], 524288, AUDIO_SAMPLE_RATE, filter); |
||||
//eqFilter(band, filter);
|
||||
} |
||||
} |
@ -0,0 +1,80 @@ |
||||
/*
|
||||
MicroDexed |
||||
|
||||
MicroDexed is a port of the Dexed sound engine |
||||
(https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6/4.x with audio shield.
|
||||
Dexed ist heavily based on https://github.com/google/music-synthesizer-for-android
|
||||
|
||||
(c)2018-2021 H. Wirtz <wirtz@parasitstudio.de> |
||||
|
||||
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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#ifndef _SGTL5000PLUS_H_ |
||||
#define _SGTL5000PLUS_H_ |
||||
|
||||
#include <Arduino.h> |
||||
#include <Audio.h> |
||||
|
||||
#define GRAPHIC_EQ_TYPE_0 FILTER_HIPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_0 50.0 |
||||
#define GRAPHIC_EQ_Q_0 6.0 |
||||
|
||||
#define GRAPHIC_EQ_TYPE_1 FILTER_BANDPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_1 120.0 |
||||
#define GRAPHIC_EQ_Q_1 6.0 |
||||
|
||||
#define GRAPHIC_EQ_TYPE_2 FILTER_BANDPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_2 220.0 |
||||
#define GRAPHIC_EQ_Q_2 6.0 |
||||
|
||||
#define GRAPHIC_EQ_TYPE_3 FILTER_BANDPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_3 1000.0 |
||||
#define GRAPHIC_EQ_Q_3 6.0 |
||||
|
||||
#define GRAPHIC_EQ_TYPE_4 FILTER_BANDPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_4 2000.0 |
||||
#define GRAPHIC_EQ_Q_4 6.0 |
||||
|
||||
#define GRAPHIC_EQ_TYPE_5 FILTER_BANDPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_5 7000.0 |
||||
#define GRAPHIC_EQ_Q_5 2.0 |
||||
|
||||
#define GRAPHIC_EQ_TYPE_6 FILTER_LOPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_6 10000.0 |
||||
#define GRAPHIC_EQ_Q_6 6.0 |
||||
|
||||
class AudioControlSGTL5000Plus : public AudioControlSGTL5000 |
||||
{ |
||||
public: |
||||
AudioControlSGTL5000Plus(uint8_t n = 7) { |
||||
num_bands = constrain(n, 1, 7); |
||||
init_parametric_eq(); |
||||
}; |
||||
void setEQType(uint8_t band, uint8_t ft); |
||||
void setEQFc(uint8_t band, float frq); |
||||
void setEQQ(uint8_t band, float q); |
||||
void setEQGain(uint8_t band, float gain); |
||||
|
||||
private: |
||||
void init_parametric_eq(void); |
||||
uint8_t num_bands; |
||||
int* filter_coeff; |
||||
uint8_t* filter_type; |
||||
float* Fc; |
||||
float* Q; |
||||
float* peakGainDB; |
||||
}; |
||||
#endif |
@ -1,329 +0,0 @@ |
||||
#ifdef SGTL5000_AUDIO_ENHANCE |
||||
|
||||
#include <Arduino.h> |
||||
#include <Audio.h> |
||||
|
||||
#define EQ_LOWPASS 0 |
||||
#define EQ_HIGHPASS 1 |
||||
#define EQ_BANDPASS 2 |
||||
#define EQ_NOTCH 3 |
||||
#define EQ_PEAK 4 |
||||
#define EQ_LOWSHELF 5 |
||||
#define EQ_HIGHSHELF 6 |
||||
|
||||
#define GRAPHIC_EQ_TYPE_0 EQ_HIGHPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_0 115.0 |
||||
#define GRAPHIC_EQ_Q_0 2.0 |
||||
|
||||
#define GRAPHIC_EQ_TYPE_1 EQ_BANDPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_1 330.0 |
||||
#define GRAPHIC_EQ_Q_1 2.0 |
||||
|
||||
#define GRAPHIC_EQ_TYPE_2 EQ_BANDPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_2 990.0 |
||||
#define GRAPHIC_EQ_Q_2 2.0 |
||||
|
||||
#define GRAPHIC_EQ_TYPE_3 EQ_BANDPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_3 2000.0 |
||||
#define GRAPHIC_EQ_Q_3 2.0 |
||||
|
||||
#define GRAPHIC_EQ_TYPE_4 EQ_BANDPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_4 4000.0 |
||||
#define GRAPHIC_EQ_Q_4 2.0 |
||||
|
||||
#define GRAPHIC_EQ_TYPE_5 EQ_BANDPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_5 9900.0 |
||||
#define GRAPHIC_EQ_Q_5 2.0 |
||||
|
||||
#define GRAPHIC_EQ_TYPE_6 EQ_LOWPASS |
||||
#define GRAPHIC_EQ_CENTER_FRQ_6 11000.0 |
||||
#define GRAPHIC_EQ_Q_6 2.0 |
||||
|
||||
extern AudioControlSGTL5000 sgtl5000_1; |
||||
|
||||
class BiquadCoef |
||||
{ |
||||
public: |
||||
BiquadCoef(uint8_t num_bands); |
||||
~BiquadCoef(); |
||||
|
||||
void set_eq_type(uint8_t band, uint8_t ft); |
||||
void set_eq_Fc(uint8_t band, float32_t frq); |
||||
void set_eq_Q(uint8_t band, float32_t q); |
||||
void set_gain(uint8_t band, float32_t gain); |
||||
void get_coef(uint8_t band, int* c); |
||||
|
||||
private: |
||||
void calcBiquadCoefficients(uint8_t band); |
||||
|
||||
uint8_t num_bands; |
||||
|
||||
uint8_t *filter_type; |
||||
float32_t *Fc; |
||||
float32_t *Q; |
||||
float32_t *peakGainDB; |
||||
|
||||
float32_t *a0; |
||||
float32_t *a1; |
||||
float32_t *a2; |
||||
float32_t *b1; |
||||
float32_t *b2; |
||||
}; |
||||
|
||||
BiquadCoef::BiquadCoef(uint8_t num_bands) |
||||
{ |
||||
num_bands = constrain(num_bands, 1, 7); |
||||
|
||||
sgtl5000_1.eqFilterCount(num_bands); |
||||
|
||||
filter_type = new uint8_t[num_bands]; |
||||
Fc = new float32_t[num_bands]; |
||||
Q = new float32_t[num_bands]; |
||||
peakGainDB = new float32_t[num_bands]; |
||||
a0 = new float32_t[num_bands]; |
||||
a1 = new float32_t[num_bands]; |
||||
a2 = new float32_t[num_bands]; |
||||
b1 = new float32_t[num_bands]; |
||||
b2 = new float32_t[num_bands]; |
||||
|
||||
set_eq_type(0, GRAPHIC_EQ_TYPE_0); |
||||
set_eq_Fc(0, GRAPHIC_EQ_CENTER_FRQ_0); |
||||
set_eq_Q(0, GRAPHIC_EQ_Q_0); |
||||
set_gain(0, 0.0); |
||||
|
||||
if (num_bands > 1) |
||||
{ |
||||
set_eq_type(1, GRAPHIC_EQ_TYPE_1); |
||||
set_eq_Fc(1, GRAPHIC_EQ_CENTER_FRQ_1); |
||||
set_eq_Q(1, GRAPHIC_EQ_Q_1); |
||||
set_gain(1, 0.0); |
||||
} |
||||
|
||||
if (num_bands > 2) |
||||
{ |
||||
set_eq_type(2, GRAPHIC_EQ_TYPE_2); |
||||
set_eq_Fc(2, GRAPHIC_EQ_CENTER_FRQ_2); |
||||
set_eq_Q(2, GRAPHIC_EQ_Q_2); |
||||
set_gain(2, 0.0); |
||||
} |
||||
|
||||
if (num_bands > 3) |
||||
{ |
||||
set_eq_type(3, GRAPHIC_EQ_TYPE_3); |
||||
set_eq_Fc(3, GRAPHIC_EQ_CENTER_FRQ_3); |
||||
set_eq_Q(3, GRAPHIC_EQ_Q_3); |
||||
set_gain(3, 0.0); |
||||
} |
||||
|
||||
if (num_bands > 4) |
||||
{ |
||||
set_eq_type(4, GRAPHIC_EQ_TYPE_4); |
||||
set_eq_Fc(4, GRAPHIC_EQ_CENTER_FRQ_4); |
||||
set_eq_Q(4, GRAPHIC_EQ_Q_4); |
||||
set_gain(4, 0.0); |
||||
} |
||||
|
||||
if (num_bands > 5) |
||||
{ |
||||
set_eq_type(5, GRAPHIC_EQ_TYPE_5); |
||||
set_eq_Fc(5, GRAPHIC_EQ_CENTER_FRQ_5); |
||||
set_eq_Q(5, GRAPHIC_EQ_Q_5); |
||||
set_gain(5, 0.0); |
||||
} |
||||
|
||||
if (num_bands > 6) |
||||
{ |
||||
set_eq_type(6, GRAPHIC_EQ_TYPE_6); |
||||
set_eq_Fc(6, GRAPHIC_EQ_CENTER_FRQ_6); |
||||
set_eq_Q(6, GRAPHIC_EQ_Q_6); |
||||
set_gain(6, 0.0); |
||||
} |
||||
|
||||
for (uint8_t i = 0; i < num_bands; i++) |
||||
{ |
||||
int tmp[num_bands]; |
||||
|
||||
calcBiquadCoefficients(i); |
||||
get_coef(i, tmp); |
||||
sgtl5000_1.eqFilter(i, tmp); |
||||
} |
||||
} |
||||
|
||||
BiquadCoef::~BiquadCoef() |
||||
{ |
||||
; |
||||
} |
||||
|
||||
void BiquadCoef::set_eq_type(uint8_t band, uint8_t ft) |
||||
{ |
||||
int tmp[num_bands]; |
||||
|
||||
filter_type[band] = ft; |
||||
calcBiquadCoefficients(band); |
||||
get_coef(band, tmp); |
||||
sgtl5000_1.eqFilter(band, tmp); |
||||
} |
||||
|
||||
void BiquadCoef::set_eq_Fc(uint8_t band, float32_t frq) |
||||
{ |
||||
int tmp[num_bands]; |
||||
|
||||
Fc[band] = frq; |
||||
calcBiquadCoefficients(band); |
||||
get_coef(band, tmp); |
||||
sgtl5000_1.eqFilter(band, tmp); |
||||
} |
||||
|
||||
void BiquadCoef::set_eq_Q(uint8_t band, float32_t q) |
||||
{ |
||||
int tmp[num_bands]; |
||||
|
||||
Q[band] = q; |
||||
calcBiquadCoefficients(band); |
||||
get_coef(band, tmp); |
||||
sgtl5000_1.eqFilter(band, tmp); |
||||
} |
||||
|
||||
void BiquadCoef::set_gain(uint8_t band, float32_t gain) |
||||
{ |
||||
int tmp[num_bands]; |
||||
|
||||
peakGainDB[band] = gain; |
||||
calcBiquadCoefficients(band); |
||||
get_coef(band, tmp); |
||||
sgtl5000_1.eqFilter(band, tmp); |
||||
} |
||||
|
||||
void BiquadCoef::get_coef(uint8_t band, int* c) |
||||
{ |
||||
if (c != NULL) |
||||
{ |
||||
c[0] = a0[band] * 0x8000; |
||||
c[1] = a1[band] * 0x8000; |
||||
c[2] = a2[band] * 0x8000; |
||||
c[3] = b1[band] * 0x8000; |
||||
c[4] = b2[band] * 0x8000; |
||||
} |
||||
} |
||||
|
||||
// Taken from https://www.earlevel.com/main/2012/11/26/biquad-c-source-code/
|
||||
//
|
||||
// Biquad.h
|
||||
//
|
||||
// Created by Nigel Redmon on 11/24/12
|
||||
// EarLevel Engineering: earlevel.com
|
||||
// Copyright 2012 Nigel Redmon
|
||||
//
|
||||
// For a complete explanation of the Biquad code:
|
||||
// http://www.earlevel.com/main/2012/11/25/biquad-c-source-code/
|
||||
//
|
||||
// License:
|
||||
//
|
||||
// This source code is provided as is, without warranty.
|
||||
// You may copy and distribute verbatim copies of this document.
|
||||
// You may modify and use this source code to create binary code
|
||||
// for your own purposes, free or commercial.
|
||||
//
|
||||
void BiquadCoef::calcBiquadCoefficients(uint8_t band) |
||||
{ |
||||
if (band > num_bands) |
||||
band = num_bands; |
||||
|
||||
float32_t norm; |
||||
float32_t V = pow(10, fabs(peakGainDB[band]) / 20.0); |
||||
float32_t K = tan(M_PI * Fc[band]); |
||||
switch (filter_type[band]) { |
||||
case EQ_LOWPASS: |
||||
norm = 1 / (1 + K / Q[band] + K * K); |
||||
a0[band] = K * K * norm; |
||||
a1[band] = 2 * a0[band]; |
||||
a2[band] = a0[band]; |
||||
b1[band] = 2 * (K * K - 1) * norm; |
||||
b2[band] = (1 - K / Q[band] + K * K) * norm; |
||||
break; |
||||
|
||||
case EQ_HIGHPASS: |
||||
norm = 1 / (1 + K / Q[band] + K * K); |
||||
a0[band] = 1 * norm; |
||||
a1[band] = -2 * a0[band]; |
||||
a2[band] = a0[band]; |
||||
b1[band] = 2 * (K * K - 1) * norm; |
||||
b2[band] = (1 - K / Q[band] + K * K) * norm; |
||||
break; |
||||
|
||||
case EQ_BANDPASS: |
||||
norm = 1 / (1 + K / Q[band] + K * K); |
||||
a0[band] = K / Q[band] * norm; |
||||
a1[band] = 0; |
||||
a2[band] = -a0[band]; |
||||
b1[band] = 2 * (K * K - 1) * norm; |
||||
b2[band] = (1 - K / Q[band] + K * K) * norm; |
||||
break; |
||||
|
||||
case EQ_NOTCH: |
||||
norm = 1 / (1 + K / Q[band] + K * K); |
||||
a0[band] = (1 + K * K) * norm; |
||||
a1[band] = 2 * (K * K - 1) * norm; |
||||
a2[band] = a0[band]; |
||||
b1[band] = a1[band]; |
||||
b2[band] = (1 - K / Q[band] + K * K) * norm; |
||||
break; |
||||
|
||||
case EQ_PEAK: |
||||
if (peakGainDB[band] >= 0) { // boost
|
||||
norm = 1 / (1 + 1 / Q[band] * K + K * K); |
||||
a0[band] = (1 + V / Q[band] * K + K * K) * norm; |
||||
a1[band] = 2 * (K * K - 1) * norm; |
||||
a2[band] = (1 - V / Q[band] * K + K * K) * norm; |
||||
b1[band] = a1[band]; |
||||
b2[band] = (1 - 1 / Q[band] * K + K * K) * norm; |
||||
} |
||||
else { // cut
|
||||
norm = 1 / (1 + V / Q[band] * K + K * K); |
||||
a0[band] = (1 + 1 / Q[band] * K + K * K) * norm; |
||||
a1[band] = 2 * (K * K - 1) * norm; |
||||
a2[band] = (1 - 1 / Q[band] * K + K * K) * norm; |
||||
b1[band] = a1[band]; |
||||
b2[band] = (1 - V / Q[band] * K + K * K) * norm; |
||||
} |
||||
break; |
||||
case EQ_LOWSHELF: |
||||
if (peakGainDB[band] >= 0) { // boost
|
||||
norm = 1 / (1 + sqrt(2) * K + K * K); |
||||
a0[band] = (1 + sqrt(2 * V) * K + V * K * K) * norm; |
||||
a1[band] = 2 * (V * K * K - 1) * norm; |
||||
a2[band] = (1 - sqrt(2 * V) * K + V * K * K) * norm; |
||||
b1[band] = 2 * (K * K - 1) * norm; |
||||
b2[band] = (1 - sqrt(2) * K + K * K) * norm; |
||||
} |
||||
else { // cut
|
||||
norm = 1 / (1 + sqrt(2 * V) * K + V * K * K); |
||||
a0[band] = (1 + sqrt(2) * K + K * K) * norm; |
||||
a1[band] = 2 * (K * K - 1) * norm; |
||||
a2[band] = (1 - sqrt(2) * K + K * K) * norm; |
||||
b1[band] = 2 * (V * K * K - 1) * norm; |
||||
b2[band] = (1 - sqrt(2 * V) * K + V * K * K) * norm; |
||||
} |
||||
break; |
||||
case EQ_HIGHSHELF: |
||||
if (peakGainDB[band] >= 0) { // boost
|
||||
norm = 1 / (1 + sqrt(2) * K + K * K); |
||||
a0[band] = (V + sqrt(2 * V) * K + K * K) * norm; |
||||
a1[band] = 2 * (K * K - V) * norm; |
||||
a2[band] = (V - sqrt(2 * V) * K + K * K) * norm; |
||||
b1[band] = 2 * (K * K - 1) * norm; |
||||
b2[band] = (1 - sqrt(2) * K + K * K) * norm; |
||||
} |
||||
else { // cut
|
||||
norm = 1 / (V + sqrt(2 * V) * K + K * K); |
||||
a0[band] = (1 + sqrt(2) * K + K * K) * norm; |
||||
a1[band] = 2 * (K * K - 1) * norm; |
||||
a2[band] = (1 - sqrt(2) * K + K * K) * norm; |
||||
b1[band] = 2 * (K * K - V) * norm; |
||||
b2[band] = (V - sqrt(2 * V) * K + K * K) * norm; |
||||
} |
||||
break; |
||||
} |
||||
return; |
||||
} |
||||
#endif |
Loading…
Reference in new issue