Code cleanup: formatiing of all files with the internal Arduino-IDE code formatter.

Replacing env.cpp and env.h with the newest msfa version with some fixes
pull/37/head
Holger Wirtz 4 years ago
parent b5f75705bf
commit 48710fa0a3
  1. 131
      EngineMkI.cpp
  2. 32
      EngineMkI.h
  3. 84
      EngineOpl.cpp
  4. 38
      EngineOpl.h
  5. 3
      MicroDexed.ino
  6. 28
      aligned_buf.h
  7. 2
      config.h
  8. 2
      dexed.cpp
  9. 245
      effect_freeverbf.cpp
  10. 64
      effect_freeverbf.h
  11. 188
      env.cc
  12. 107
      env.cpp
  13. 37
      env.h
  14. 30
      exp2.h
  15. 38
      fm_core.cpp
  16. 36
      fm_core.h
  17. 283
      fm_op_kernel.cc
  18. 29
      fm_op_kernel.cpp
  19. 28
      fm_op_kernel.h
  20. 28
      freqlut.cpp
  21. 28
      freqlut.h
  22. 28
      lfo.cpp
  23. 28
      lfo.h
  24. 2
      midinotes.h
  25. 29
      module.h
  26. 145
      my_effect_freeverb.cpp
  27. 56
      my_effect_freeverb.h
  28. 30
      pitchenv.cpp
  29. 31
      pitchenv.h
  30. 28
      sin.h
  31. 2
      source_microdexed.h

@ -1,25 +1,25 @@
/*
* Copyright (C) 2015-2017 Pascal Gauthier.
*
* 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
*
* The code is based on ppplay https://github.com/stohrendorf/ppplay and opl3
* math documentation :
* https://github.com/gtaylormb/opl3_fpga/blob/master/docs/opl3math/opl3math.pdf
*
*/
Copyright (C) 2015-2017 Pascal Gauthier.
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
The code is based on ppplay https://github.com/stohrendorf/ppplay and opl3
math documentation :
https://github.com/gtaylormb/opl3_fpga/blob/master/docs/opl3math/opl3math.pdf
*/
#include "EngineMkI.h"
#define _USE_MATH_DEFINES
@ -30,43 +30,43 @@
#include "exp2.h"
#ifdef DEBUG
#include "time.h"
//#define MKIDEBUG
#include "time.h"
//#define MKIDEBUG
#endif
#ifdef _WIN32
#if _MSC_VER < 1800
FRAC_NUM log2(FRAC_NUM n) {
FRAC_NUM log2(FRAC_NUM n) {
//return log(n) / log(2.0);
return LOG_FUNC(n) / LOG_FUNC(2.0);
}
FRAC_NUM round(FRAC_NUM n) {
}
FRAC_NUM round(FRAC_NUM n) {
return n < 0.0 ? ceil(n - 0.5) : floor(n + 0.5);
}
}
#endif
__declspec(align(16)) const int zeros[N] = {0};
__declspec(align(16)) const int zeros[N] = {0};
#else
const int32_t __attribute__ ((aligned(16))) zeros[_N_] = {0};
const int32_t __attribute__ ((aligned(16))) zeros[_N_] = {0};
#endif
static const uint16_t NEGATIVE_BIT = 0x8000;
static const uint16_t ENV_BITDEPTH = 14;
static const uint16_t SINLOG_BITDEPTH = 10;
static const uint16_t SINLOG_TABLESIZE = 1<<SINLOG_BITDEPTH;
static const uint16_t SINLOG_TABLESIZE = 1 << SINLOG_BITDEPTH;
static uint16_t sinLogTable[SINLOG_TABLESIZE];
static const uint16_t SINEXP_BITDEPTH = 10;
static const uint16_t SINEXP_TABLESIZE = 1<<SINEXP_BITDEPTH;
static const uint16_t SINEXP_TABLESIZE = 1 << SINEXP_BITDEPTH;
static uint16_t sinExpTable[SINEXP_TABLESIZE];
const uint16_t ENV_MAX = 1<<ENV_BITDEPTH;
const uint16_t ENV_MAX = 1 << ENV_BITDEPTH;
static inline uint16_t sinLog(uint16_t phi) {
const uint16_t SINLOG_TABLEFILTER = SINLOG_TABLESIZE-1;
const uint16_t SINLOG_TABLEFILTER = SINLOG_TABLESIZE - 1;
const uint16_t index = (phi & SINLOG_TABLEFILTER);
switch( ( phi & (SINLOG_TABLESIZE * 3) ) ) {
switch ( ( phi & (SINLOG_TABLESIZE * 3) ) ) {
case 0:
return sinLogTable[index];
case SINLOG_TABLESIZE:
@ -81,15 +81,15 @@ static inline uint16_t sinLog(uint16_t phi) {
EngineMkI::EngineMkI() {
float bitReso = SINLOG_TABLESIZE;
for(int i=0;i<SINLOG_TABLESIZE;i++) {
for (int i = 0; i < SINLOG_TABLESIZE; i++) {
//float x1 = sin(((0.5+i)/bitReso) * M_PI/2.0);
float x1 = SIN_FUNC(((0.5+i)/bitReso) * M_PI/2.0);
float x1 = SIN_FUNC(((0.5 + i) / bitReso) * M_PI / 2.0);
sinLogTable[i] = round(-1024 * log2(x1));
}
bitReso = SINEXP_TABLESIZE;
for(int i=0;i<SINEXP_TABLESIZE;i++) {
float x1 = (pow(2, float(i)/bitReso)-1) * 4096;
for (int i = 0; i < SINEXP_TABLESIZE; i++) {
float x1 = (pow(2, float(i) / bitReso) - 1) * 4096;
sinExpTable[i] = round(x1);
}
@ -97,8 +97,8 @@ EngineMkI::EngineMkI() {
char buffer[4096];
int pos = 0;
for(int i=0;i<SINLOG_TABLESIZE;i++) {
pos += sprintf(buffer+pos, "%d ", sinLogTable[i]);
for (int i = 0; i < SINLOG_TABLESIZE; i++) {
pos += sprintf(buffer + pos, "%d ", sinLogTable[i]);
if ( pos > 90 ) {
buffer[0] = 0;
pos = 0;
@ -106,8 +106,8 @@ EngineMkI::EngineMkI() {
}
buffer[0] = 0;
pos = 0;
for(int i=0;i<SINEXP_TABLESIZE;i++) {
pos += sprintf(buffer+pos, "%d ", sinExpTable[i]);
for (int i = 0; i < SINEXP_TABLESIZE; i++) {
pos += sprintf(buffer + pos, "%d ", sinExpTable[i]);
if ( pos > 90 ) {
buffer[0] = 0;
pos = 0;
@ -137,7 +137,7 @@ inline int32_t mkiSin(int32_t phase, uint16_t env) {
}
#endif
if( isSigned )
if ( isSigned )
return (-result - 1) << 13;
else
return result << 13;
@ -153,7 +153,7 @@ void EngineMkI::compute(int32_t *output, const int32_t *input,
for (int i = 0; i < _N_; i++) {
gain += dgain;
int32_t y = mkiSin((phase+input[i]), gain);
int32_t y = mkiSin((phase + input[i]), gain);
output[i] = y + adder[i];
phase += freq;
}
@ -189,7 +189,7 @@ void EngineMkI::compute_fb(int32_t *output, int32_t phase0, int32_t freq,
gain += dgain;
int32_t scaled_fb = (y0 + y) >> (fb_shift + 1);
y0 = y;
y = mkiSin((phase+scaled_fb), gain);
y = mkiSin((phase + scaled_fb), gain);
output[i] = y + adder[i];
phase += freq;
}
@ -209,13 +209,13 @@ void EngineMkI::compute_fb2(int32_t *output, FmOpParams *parms, int32_t gain01,
phase[0] = parms[0].phase;
phase[1] = parms[1].phase;
parms[1].gain_out = (ENV_MAX-(parms[1].level_in >> (28-ENV_BITDEPTH)));
parms[1].gain_out = (ENV_MAX - (parms[1].level_in >> (28 - ENV_BITDEPTH)));
gain[0] = gain01;
gain[1] = parms[1].gain_out == 0 ? (ENV_MAX-1) : parms[1].gain_out;
gain[1] = parms[1].gain_out == 0 ? (ENV_MAX - 1) : parms[1].gain_out;
dgain[0] = (gain02 - gain01 + (_N_ >> 1)) >> LG_N;
dgain[1] = (parms[1].gain_out - (parms[1].gain_out == 0 ? (ENV_MAX-1) : parms[1].gain_out));
dgain[1] = (parms[1].gain_out - (parms[1].gain_out == 0 ? (ENV_MAX - 1) : parms[1].gain_out));
for (int i = 0; i < _N_; i++) {
int32_t scaled_fb = (y0 + y) >> (fb_shift + 1);
@ -223,12 +223,12 @@ void EngineMkI::compute_fb2(int32_t *output, FmOpParams *parms, int32_t gain01,
// op 0
gain[0] += dgain[0];
y0 = y;
y = mkiSin(phase[0]+scaled_fb, gain[0]);
y = mkiSin(phase[0] + scaled_fb, gain[0]);
phase[0] += parms[0].freq;
// op 1
gain[1] += dgain[1];
y = mkiSin(phase[1]+y, gain[1]);
y = mkiSin(phase[1] + y, gain[1]);
phase[1] += parms[1].freq;
output[i] = y;
@ -249,16 +249,16 @@ void EngineMkI::compute_fb3(int32_t *output, FmOpParams *parms, int32_t gain01,
phase[1] = parms[1].phase;
phase[2] = parms[2].phase;
parms[1].gain_out = (ENV_MAX-(parms[1].level_in >> (28-ENV_BITDEPTH)));
parms[2].gain_out = (ENV_MAX-(parms[2].level_in >> (28-ENV_BITDEPTH)));
parms[1].gain_out = (ENV_MAX - (parms[1].level_in >> (28 - ENV_BITDEPTH)));
parms[2].gain_out = (ENV_MAX - (parms[2].level_in >> (28 - ENV_BITDEPTH)));
gain[0] = gain01;
gain[1] = parms[1].gain_out == 0 ? (ENV_MAX-1) : parms[1].gain_out;
gain[2] = parms[2].gain_out == 0 ? (ENV_MAX-1) : parms[2].gain_out;
gain[1] = parms[1].gain_out == 0 ? (ENV_MAX - 1) : parms[1].gain_out;
gain[2] = parms[2].gain_out == 0 ? (ENV_MAX - 1) : parms[2].gain_out;
dgain[0] = (gain02 - gain01 + (_N_ >> 1)) >> LG_N;
dgain[1] = (parms[1].gain_out - (parms[1].gain_out == 0 ? (ENV_MAX-1) : parms[1].gain_out));
dgain[2] = (parms[2].gain_out - (parms[2].gain_out == 0 ? (ENV_MAX-1) : parms[2].gain_out));
dgain[1] = (parms[1].gain_out - (parms[1].gain_out == 0 ? (ENV_MAX - 1) : parms[1].gain_out));
dgain[2] = (parms[2].gain_out - (parms[2].gain_out == 0 ? (ENV_MAX - 1) : parms[2].gain_out));
for (int i = 0; i < _N_; i++) {
@ -267,17 +267,17 @@ void EngineMkI::compute_fb3(int32_t *output, FmOpParams *parms, int32_t gain01,
// op 0
gain[0] += dgain[0];
y0 = y;
y = mkiSin(phase[0]+scaled_fb, gain[0]);
y = mkiSin(phase[0] + scaled_fb, gain[0]);
phase[0] += parms[0].freq;
// op 1
gain[1] += dgain[1];
y = mkiSin(phase[1]+y, gain[1]);
y = mkiSin(phase[1] + y, gain[1]);
phase[1] += parms[1].freq;
// op 2
gain[2] += dgain[2];
y = mkiSin(phase[2]+y, gain[2]);
y = mkiSin(phase[2] + y, gain[2]);
phase[2] += parms[2].freq;
output[i] = y;
@ -287,12 +287,12 @@ void EngineMkI::compute_fb3(int32_t *output, FmOpParams *parms, int32_t gain01,
}
void EngineMkI::render(int32_t *output, FmOpParams *params, int algorithm, int32_t *fb_buf, int32_t feedback_shift) {
const int kLevelThresh = ENV_MAX-100;
const int kLevelThresh = ENV_MAX - 100;
FmAlgorithm alg = algorithms[algorithm];
bool has_contents[3] = { true, false, false };
bool fb_on = feedback_shift < 16;
switch(algorithm) {
switch (algorithm) {
case 3 : case 5 :
if ( fb_on )
alg.ops[0] = 0xc4;
@ -305,8 +305,8 @@ void EngineMkI::render(int32_t *output, FmOpParams *params, int algorithm, int32
int inbus = (flags >> 4) & 3;
int outbus = flags & 3;
int32_t *outptr = (outbus == 0) ? output : buf_[outbus - 1].get();
int32_t gain1 = param.gain_out == 0 ? (ENV_MAX-1) : param.gain_out;
int32_t gain2 = ENV_MAX-(param.level_in >> (28-ENV_BITDEPTH));
int32_t gain1 = param.gain_out == 0 ? (ENV_MAX - 1) : param.gain_out;
int32_t gain2 = ENV_MAX - (param.level_in >> (28 - ENV_BITDEPTH));
param.gain_out = gain2;
if (gain1 <= kLevelThresh || gain2 <= kLevelThresh) {
@ -321,14 +321,14 @@ void EngineMkI::render(int32_t *output, FmOpParams *params, int algorithm, int32
switch ( algorithm ) {
// three operator feedback, process exception for ALGO 4
case 3 :
compute_fb3(outptr, params, gain1, gain2, fb_buf, min((feedback_shift+2), 16));
compute_fb3(outptr, params, gain1, gain2, fb_buf, min((feedback_shift + 2), 16));
params[1].phase += params[1].freq << LG_N; // hack, we already processed op-5 - op-4
params[2].phase += params[2].freq << LG_N; // yuk yuk
op += 2; // ignore the 2 other operators
break;
// two operator feedback, process exception for ALGO 6
case 5 :
compute_fb2(outptr, params, gain1, gain2, fb_buf, min((feedback_shift+2), 16));
compute_fb2(outptr, params, gain1, gain2, fb_buf, min((feedback_shift + 2), 16));
params[1].phase += params[1].freq << LG_N; // yuk, hack, we already processed op-5
op++; // ignore next operator;
break;
@ -351,4 +351,3 @@ void EngineMkI::render(int32_t *output, FmOpParams *params, int algorithm, int32
param.phase += param.freq << LG_N;
}
}

@ -1,19 +1,19 @@
/*
* Copyright 2014 Pascal Gauthier.
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2014 Pascal Gauthier.
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef ENGINEMKI_H_INCLUDED
#define ENGINEMKI_H_INCLUDED
@ -27,7 +27,7 @@
class EngineMkI : public FmCore {
public:
public:
EngineMkI();
void render(int32_t *output, FmOpParams *params, int algorithm, int32_t *fb_buf, int32_t feedback_shift);

@ -1,34 +1,34 @@
/*
* Copyright (C) 2014 Pascal Gauthier.
* Copyright (C) 2012 Steffen Ohrendorf <steffen.ohrendorf@gmx.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
*
* Original Java Code: Copyright (C) 2008 Robson Cozendey <robson@cozendey.com>
*
* Some code based on forum posts in: http://forums.submarine.org.uk/phpBB/viewforum.php?f=9,
* Copyright (C) 2010-2013 by carbon14 and opl3
*
*/
Copyright (C) 2014 Pascal Gauthier.
Copyright (C) 2012 Steffen Ohrendorf <steffen.ohrendorf@gmx.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
Original Java Code: Copyright (C) 2008 Robson Cozendey <robson@cozendey.com>
Some code based on forum posts in: http://forums.submarine.org.uk/phpBB/viewforum.php?f=9,
Copyright (C) 2010-2013 by carbon14 and opl3
*/
#include "EngineOpl.h"
#ifdef _WIN32
__declspec(align(16)) const int zeros[N] = {0};
__declspec(align(16)) const int zeros[N] = {0};
#else
const int32_t __attribute__ ((aligned(16))) zeros[_N_] = {0};
const int32_t __attribute__ ((aligned(16))) zeros[_N_] = {0};
#endif
uint16_t SignBit = 0x8000;
@ -74,7 +74,7 @@ uint16_t sinExpTable[256] = {
inline uint16_t sinLog(uint16_t phi) {
const uint8_t index = (phi & 0xff);
switch( ( phi & 0x0300 ) ) {
switch ( ( phi & 0x0300 ) ) {
case 0x0000:
// rising quarter wave Shape A
return sinLogTable[index];
@ -92,11 +92,11 @@ inline uint16_t sinLog(uint16_t phi) {
// 16 env units are ~3dB and halve the output
/**
* @brief OPL Sine Wave calculation
* @param[in] phase Wave phase (0..1023)
* @param[in] env Envelope value (0..511)
* @warning @a env will not be checked for correct values.
*/
@brief OPL Sine Wave calculation
@param[in] phase Wave phase (0..1023)
@param[in] env Envelope value (0..511)
@warning @a env will not be checked for correct values.
*/
inline int16_t oplSin( uint16_t phase, uint16_t env ) {
uint16_t expVal = sinLog(phase) + (env << 3);
const bool isSigned = expVal & SignBit;
@ -108,7 +108,7 @@ inline int16_t oplSin( uint16_t phase, uint16_t env ) {
result <<= 1;
result >>= ( expVal >> 8 ); // exp
if( isSigned ) {
if ( isSigned ) {
// -1 for one's complement
return -result - 1;
} else {
@ -124,7 +124,7 @@ void EngineOpl::compute(int32_t *output, const int32_t *input, int32_t phase0, i
for (int i = 0; i < _N_; i++) {
gain += dgain;
int32_t y = oplSin((phase+input[i]) >> 14, gain);
int32_t y = oplSin((phase + input[i]) >> 14, gain);
output[i] = (y << 14) + adder[i];
phase += freq;
}
@ -158,7 +158,7 @@ void EngineOpl::compute_fb(int32_t *output, int32_t phase0, int32_t freq,
gain += dgain;
int32_t scaled_fb = (y0 + y) >> (fb_shift + 1);
y0 = y;
y = oplSin((phase+scaled_fb) >> 14, gain) << 14;
y = oplSin((phase + scaled_fb) >> 14, gain) << 14;
output[i] = y + adder[i];
phase += freq;
}
@ -168,7 +168,7 @@ void EngineOpl::compute_fb(int32_t *output, int32_t phase0, int32_t freq,
}
void EngineOpl::render(int32_t *output, FmOpParams *params, int algorithm,int32_t *fb_buf, int32_t feedback_shift) {
void EngineOpl::render(int32_t *output, FmOpParams *params, int algorithm, int32_t *fb_buf, int32_t feedback_shift) {
const int kLevelThresh = 507; // really ????
const FmAlgorithm alg = algorithms[algorithm];
bool has_contents[3] = { true, false, false };
@ -180,7 +180,7 @@ void EngineOpl::render(int32_t *output, FmOpParams *params, int algorithm,int32_
int outbus = flags & 3;
int32_t *outptr = (outbus == 0) ? output : buf_[outbus - 1].get();
int32_t gain1 = param.gain_out == 0 ? 511 : param.gain_out;
int32_t gain2 = 512-(param.level_in >> 19);
int32_t gain2 = 512 - (param.level_in >> 19);
param.gain_out = gain2;
if (gain1 <= kLevelThresh || gain2 <= kLevelThresh) {
@ -211,15 +211,3 @@ void EngineOpl::render(int32_t *output, FmOpParams *params, int algorithm,int32_
param.phase += param.freq << LG_N;
}
}

@ -1,22 +1,22 @@
/**
*
* Copyright (c) 2014 Pascal Gauthier.
*
* 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
*
*/
Copyright (c) 2014 Pascal Gauthier.
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 ENGINEOPL_H_INCLUDED
#define ENGINEOPL_H_INCLUDED
@ -29,7 +29,7 @@
class EngineOpl : public FmCore {
public:
public:
virtual void render(int32_t *output, FmOpParams *params, int algorithm,
int32_t *fb_buf, int32_t feedback_shift);
void compute(int32_t *output, const int32_t *input, int32_t phase0, int32_t freq, int32_t gain1, int32_t gain2, bool add);

@ -1864,9 +1864,6 @@ void set_fx_params(void)
modchorus_filter[instance_id]->setLowpass(2, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter[instance_id]->setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3);
#endif
//chorus_mixer[instance_id]->gain(0, 1.0 - pseudo_log_curve(mapfloat(configuration.fx.chorus_level[instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5)));
//chorus_mixer[instance_id]->gain(1, pseudo_log_curve(mapfloat(configuration.fx.chorus_level[instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5)));
//chorus_mixer[instance_id]->gain(0, 1.0 - mapfloat(configuration.fx.chorus_level[instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5));
chorus_mixer[instance_id]->gain(0, 1.0);
chorus_mixer[instance_id]->gain(1, mapfloat(configuration.fx.chorus_level[instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5));

@ -1,18 +1,18 @@
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2013 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// A convenient wrapper for buffers with alignment constraints

@ -114,7 +114,7 @@
#define MOD_FILTER_OUTPUT MOD_BUTTERWORTH_FILTER_OUTPUT // MOD_LINKWITZ_RILEY_FILTER_OUTPUT MOD_BUTTERWORTH_FILTER_OUTPUT MOD_NO_FILTER_OUTPUT
#define MOD_FILTER_CUTOFF_HZ 2000
// REVERB parameters
#define REVERB_ANTIALIAS_FRQ 7500
//#define REVERB_ANTIALIAS_FRQ 7500
//#define PATCHED_FREEVERB 1
#define FREEVERB_FLOAT 1
// ANTIALIAS frequency

@ -753,7 +753,7 @@ void Dexed::setATController(uint8_t at_range, uint8_t at_assign, uint8_t at_mode
void Dexed::setPortamentoMode(uint8_t portamento_mode, uint8_t portamento_glissando, uint8_t portamento_time)
{
controllers.portamento_cc = portamento_time;
controllers.portamento_enable_cc=portamento_mode>63;
controllers.portamento_enable_cc = portamento_mode > 63;
if (portamento_time > 0)
controllers.portamento_enable_cc = true;

@ -1,28 +1,28 @@
/* Audio Library for Teensy 3.X
* Copyright (c) 2018, Paul Stoffregen, paul@pjrc.com
*
* Development of this audio library was funded by PJRC.COM, LLC by sales of
* Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
* open source software by purchasing Teensy or other PJRC products.
*
* 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, development funding 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.
*/
Copyright (c) 2018, Paul Stoffregen, paul@pjrc.com
Development of this audio library was funded by PJRC.COM, LLC by sales of
Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
open source software by purchasing Teensy or other PJRC products.
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, development funding 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.
*/
// A Floating point implementation of Freeverb by Jezar at Dreampoint
// http://blog.bjornroche.com/2012/06/freeverb-original-public-domain-code-by.html
@ -34,14 +34,14 @@
AudioEffectFreeverbFloat::AudioEffectFreeverbFloat() : AudioStream(1, inputQueueArray)
{
for(unsigned int i = 0; i < sizeof(comb1buf)/sizeof(float); i++) comb1buf[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb2buf)/sizeof(float); i++) comb2buf[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb3buf)/sizeof(float); i++) comb3buf[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb4buf)/sizeof(float); i++) comb4buf[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb5buf)/sizeof(float); i++) comb5buf[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb6buf)/sizeof(float); i++) comb6buf[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb7buf)/sizeof(float); i++) comb7buf[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb8buf)/sizeof(float); i++) comb8buf[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb1buf) / sizeof(float); i++) comb1buf[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb2buf) / sizeof(float); i++) comb2buf[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb3buf) / sizeof(float); i++) comb3buf[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb4buf) / sizeof(float); i++) comb4buf[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb5buf) / sizeof(float); i++) comb5buf[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb6buf) / sizeof(float); i++) comb6buf[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb7buf) / sizeof(float); i++) comb7buf[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb8buf) / sizeof(float); i++) comb8buf[i] = 0.0;
comb1index = 0;
comb2index = 0;
comb3index = 0;
@ -61,10 +61,10 @@ AudioEffectFreeverbFloat::AudioEffectFreeverbFloat() : AudioStream(1, inputQueue
combdamp1 = 6553.0;
combdamp2 = 26215.0;
combfeeback = 27524.0;
for(unsigned int i = 0; i < sizeof(allpass1buf)/sizeof(float); i++) allpass1buf[i] = 0.0;
for(unsigned int i = 0; i < sizeof(allpass2buf)/sizeof(float); i++) allpass2buf[i] = 0.0;
for(unsigned int i = 0; i < sizeof(allpass3buf)/sizeof(float); i++) allpass3buf[i] = 0.0;
for(unsigned int i = 0; i < sizeof(allpass4buf)/sizeof(float); i++) allpass4buf[i] = 0.0;
for (unsigned int i = 0; i < sizeof(allpass1buf) / sizeof(float); i++) allpass1buf[i] = 0.0;
for (unsigned int i = 0; i < sizeof(allpass2buf) / sizeof(float); i++) allpass2buf[i] = 0.0;
for (unsigned int i = 0; i < sizeof(allpass3buf) / sizeof(float); i++) allpass3buf[i] = 0.0;
for (unsigned int i = 0; i < sizeof(allpass4buf) / sizeof(float); i++) allpass4buf[i] = 0.0;
allpass1index = 0;
allpass2index = 0;
allpass3index = 0;
@ -105,34 +105,35 @@ static int16_t sat16i(int32_t n, int rshift) {
// care of negative numbers
n = n / (float) (1<<rshift);
return n;
} */
} */
// TODO: move this to one of the data files, use in output_adat.cpp, output_tdm.cpp, etc
static const audio_block_t zeroblock = {
0, 0, 0, {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#if AUDIO_BLOCK_SAMPLES > 16
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 32
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 48
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 64
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 80
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 96
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 112
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
} };
}
};
void AudioEffectFreeverbFloat::update()
{
@ -152,7 +153,7 @@ void AudioEffectFreeverbFloat::update()
block = receiveReadOnly(0);
if (!block) block = &zeroblock;
for (i=0; i < AUDIO_BLOCK_SAMPLES; i++) {
for (i = 0; i < AUDIO_BLOCK_SAMPLES; i++) {
// TODO: scale numerical range depending on roomsize & damping
//input = sat16(block->data[i] * 8738, 17); // for numerical headroom
input = (float)block->data[i] / 32768.0f;
@ -162,49 +163,49 @@ void AudioEffectFreeverbFloat::update()
sum += bufout;
comb1filter = bufout * combdamp2 + comb1filter * combdamp1;
comb1buf[comb1index] = input + comb1filter * combfeeback;
if (++comb1index >= sizeof(comb1buf)/sizeof(float)) comb1index = 0;
if (++comb1index >= sizeof(comb1buf) / sizeof(float)) comb1index = 0;
bufout = comb2buf[comb2index];
sum += bufout;
comb2filter = bufout * combdamp2 + comb2filter * combdamp1;
comb2buf[comb2index] = input + comb2filter * combfeeback;
if (++comb2index >= sizeof(comb2buf)/sizeof(float)) comb2index = 0;
if (++comb2index >= sizeof(comb2buf) / sizeof(float)) comb2index = 0;
bufout = comb3buf[comb3index];
sum += bufout;
comb3filter = bufout * combdamp2 + comb3filter * combdamp1;
comb3buf[comb3index] = input + comb3filter * combfeeback;
if (++comb3index >= sizeof(comb3buf)/sizeof(float)) comb3index = 0;
if (++comb3index >= sizeof(comb3buf) / sizeof(float)) comb3index = 0;
bufout = comb4buf[comb4index];
sum += bufout;
comb4filter = bufout * combdamp2 + comb4filter * combdamp1;
comb4buf[comb4index] = input + comb4filter * combfeeback;
if (++comb4index >= sizeof(comb4buf)/sizeof(float)) comb4index = 0;
if (++comb4index >= sizeof(comb4buf) / sizeof(float)) comb4index = 0;
bufout = comb5buf[comb5index];
sum += bufout;
comb5filter = bufout * combdamp2 + comb5filter * combdamp1;
comb5buf[comb5index] = input + comb5filter * combfeeback;
if (++comb5index >= sizeof(comb5buf)/sizeof(float)) comb5index = 0;
if (++comb5index >= sizeof(comb5buf) / sizeof(float)) comb5index = 0;
bufout = comb6buf[comb6index];
sum += bufout;
comb6filter = bufout * combdamp2 + comb6filter * combdamp1;
comb6buf[comb6index] = input + comb6filter * combfeeback;
if (++comb6index >= sizeof(comb6buf)/sizeof(float)) comb6index = 0;
if (++comb6index >= sizeof(comb6buf) / sizeof(float)) comb6index = 0;
bufout = comb7buf[comb7index];
sum += bufout;
comb7filter = bufout * combdamp2 + comb7filter * combdamp1;
comb7buf[comb7index] = input + comb7filter * combfeeback;
if (++comb7index >= sizeof(comb7buf)/sizeof(float)) comb7index = 0;
if (++comb7index >= sizeof(comb7buf) / sizeof(float)) comb7index = 0;
bufout = comb8buf[comb8index];
sum += bufout;
comb8filter = bufout * combdamp2 + comb8filter * combdamp1;
comb8buf[comb8index] = input + comb8filter * combfeeback;
if (++comb8index >= sizeof(comb8buf)/sizeof(float)) comb8index = 0;
if (++comb8index >= sizeof(comb8buf) / sizeof(float)) comb8index = 0;
//output = sat16(sum * 31457.0, 17);
//output = sum * 31457.0/131072.0f;
@ -212,23 +213,23 @@ void AudioEffectFreeverbFloat::update()
bufout = allpass1buf[allpass1index];
allpass1buf[allpass1index] = output + (bufout / 2.0);
output = (bufout - output) /2.0;
if (++allpass1index >= sizeof(allpass1buf)/sizeof(float)) allpass1index = 0;
output = (bufout - output) / 2.0;
if (++allpass1index >= sizeof(allpass1buf) / sizeof(float)) allpass1index = 0;
bufout = allpass2buf[allpass2index];
allpass2buf[allpass2index] = output + (bufout / 2.0);
output = (bufout - output) /2.0;
if (++allpass2index >= sizeof(allpass2buf)/sizeof(float)) allpass2index = 0;
output = (bufout - output) / 2.0;
if (++allpass2index >= sizeof(allpass2buf) / sizeof(float)) allpass2index = 0;
bufout = allpass3buf[allpass3index];
allpass3buf[allpass3index] = output + (bufout / 2.0);
output = (bufout - output) /2.0;
if (++allpass3index >= sizeof(allpass3buf)/sizeof(float)) allpass3index = 0;
output = (bufout - output) / 2.0;
if (++allpass3index >= sizeof(allpass3buf) / sizeof(float)) allpass3index = 0;
bufout = allpass4buf[allpass4index];
allpass4buf[allpass4index] = output + (bufout / 2.0);
output = (bufout - output) /2.0;
if (++allpass4index >= sizeof(allpass4buf)/sizeof(float)) allpass4index = 0;
output = (bufout - output) / 2.0;
if (++allpass4index >= sizeof(allpass4buf) / sizeof(float)) allpass4index = 0;
//outblock->data[i] = sat16i(output * 30.0, 0);
outblock->data[i] = sat16i(output * 32768.0, 0);
@ -247,14 +248,14 @@ void AudioEffectFreeverbFloat::update()
AudioEffectFreeverbStereoFloat::AudioEffectFreeverbStereoFloat() : AudioStream(1, inputQueueArray)
{
for(unsigned int i = 0; i < sizeof(comb1bufL)/sizeof(float); i++) comb1bufL[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb2bufL)/sizeof(float); i++) comb2bufL[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb3bufL)/sizeof(float); i++) comb3bufL[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb4bufL)/sizeof(float); i++) comb4bufL[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb5bufL)/sizeof(float); i++) comb5bufL[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb6bufL)/sizeof(float); i++) comb6bufL[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb7bufL)/sizeof(float); i++) comb7bufL[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb8bufL)/sizeof(float); i++) comb8bufL[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb1bufL) / sizeof(float); i++) comb1bufL[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb2bufL) / sizeof(float); i++) comb2bufL[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb3bufL) / sizeof(float); i++) comb3bufL[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb4bufL) / sizeof(float); i++) comb4bufL[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb5bufL) / sizeof(float); i++) comb5bufL[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb6bufL) / sizeof(float); i++) comb6bufL[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb7bufL) / sizeof(float); i++) comb7bufL[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb8bufL) / sizeof(float); i++) comb8bufL[i] = 0.0;
comb1indexL = 0;
comb2indexL = 0;
comb3indexL = 0;
@ -271,14 +272,14 @@ AudioEffectFreeverbStereoFloat::AudioEffectFreeverbStereoFloat() : AudioStream(1
comb6filterL = 0.0;
comb7filterL = 0.0;
comb8filterL = 0.0;
for(unsigned int i = 0; i < sizeof(comb1bufR)/sizeof(float); i++) comb1bufR[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb2bufR)/sizeof(float); i++) comb2bufR[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb3bufR)/sizeof(float); i++) comb3bufR[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb4bufR)/sizeof(float); i++) comb4bufR[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb5bufR)/sizeof(float); i++) comb5bufR[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb6bufR)/sizeof(float); i++) comb6bufR[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb7bufR)/sizeof(float); i++) comb7bufR[i] = 0.0;
for(unsigned int i = 0; i < sizeof(comb8bufR)/sizeof(float); i++) comb8bufR[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb1bufR) / sizeof(float); i++) comb1bufR[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb2bufR) / sizeof(float); i++) comb2bufR[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb3bufR) / sizeof(float); i++) comb3bufR[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb4bufR) / sizeof(float); i++) comb4bufR[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb5bufR) / sizeof(float); i++) comb5bufR[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb6bufR) / sizeof(float); i++) comb6bufR[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb7bufR) / sizeof(float); i++) comb7bufR[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb8bufR) / sizeof(float); i++) comb8bufR[i] = 0.0;
comb1indexR = 0;
comb2indexR = 0;
comb3indexR = 0;
@ -298,18 +299,18 @@ AudioEffectFreeverbStereoFloat::AudioEffectFreeverbStereoFloat() : AudioStream(1
combdamp1 = 6553.0;
combdamp2 = 26215.0;
combfeeback = 27524.0;
for(unsigned int i = 0; i < sizeof(allpass1bufL)/sizeof(float); i++) allpass1bufL[i] = 0.0;
for(unsigned int i = 0; i < sizeof(allpass2bufL)/sizeof(float); i++) allpass2bufL[i] = 0.0;
for(unsigned int i = 0; i < sizeof(allpass3bufL)/sizeof(float); i++) allpass3bufL[i] = 0.0;
for(unsigned int i = 0; i < sizeof(allpass4bufL)/sizeof(float); i++) allpass4bufL[i] = 0.0;
for (unsigned int i = 0; i < sizeof(allpass1bufL) / sizeof(float); i++) allpass1bufL[i] = 0.0;
for (unsigned int i = 0; i < sizeof(allpass2bufL) / sizeof(float); i++) allpass2bufL[i] = 0.0;
for (unsigned int i = 0; i < sizeof(allpass3bufL) / sizeof(float); i++) allpass3bufL[i] = 0.0;
for (unsigned int i = 0; i < sizeof(allpass4bufL) / sizeof(float); i++) allpass4bufL[i] = 0.0;
allpass1indexL = 0;
allpass2indexL = 0;
allpass3indexL = 0;
allpass4indexL = 0;
for(unsigned int i = 0; i < sizeof(allpass1bufR)/sizeof(float); i++) allpass1bufR[i] = 0.0;
for(unsigned int i = 0; i < sizeof(allpass2bufR)/sizeof(float); i++) allpass2bufR[i] = 0.0;
for(unsigned int i = 0; i < sizeof(allpass3bufR)/sizeof(float); i++) allpass3bufR[i] = 0.0;
for(unsigned int i = 0; i < sizeof(allpass4bufR)/sizeof(float); i++) allpass4bufR[i] = 0.0;
for (unsigned int i = 0; i < sizeof(allpass1bufR) / sizeof(float); i++) allpass1bufR[i] = 0.0;
for (unsigned int i = 0; i < sizeof(allpass2bufR) / sizeof(float); i++) allpass2bufR[i] = 0.0;
for (unsigned int i = 0; i < sizeof(allpass3bufR) / sizeof(float); i++) allpass3bufR[i] = 0.0;
for (unsigned int i = 0; i < sizeof(allpass4bufR) / sizeof(float); i++) allpass4bufR[i] = 0.0;
allpass1indexR = 0;
allpass2indexR = 0;
allpass3indexR = 0;
@ -337,7 +338,7 @@ void AudioEffectFreeverbStereoFloat::update()
}
if (!block) block = &zeroblock;
for (i=0; i < AUDIO_BLOCK_SAMPLES; i++) {
for (i = 0; i < AUDIO_BLOCK_SAMPLES; i++) {
// TODO: scale numerical range depending on roomsize & damping
//input = sat16(block->data[i] * 8738.0, 17); // for numerical headroom
input = block->data[i] / 32768.0;
@ -347,49 +348,49 @@ void AudioEffectFreeverbStereoFloat::update()
sum += bufout;
comb1filterL = bufout * combdamp2 + comb1filterL * combdamp1;
comb1bufL[comb1indexL] = input + comb1filterL * combfeeback;
if (++comb1indexL >= sizeof(comb1bufL)/sizeof(float)) comb1indexL = 0;
if (++comb1indexL >= sizeof(comb1bufL) / sizeof(float)) comb1indexL = 0;
bufout = comb2bufL[comb2indexL];
sum += bufout;
comb2filterL = bufout * combdamp2 + comb2filterL * combdamp1;
comb2bufL[comb2indexL] = input + comb2filterL * combfeeback;
if (++comb2indexL >= sizeof(comb2bufL)/sizeof(float)) comb2indexL = 0;
if (++comb2indexL >= sizeof(comb2bufL) / sizeof(float)) comb2indexL = 0;
bufout = comb3bufL[comb3indexL];
sum += bufout;
comb3filterL = bufout * combdamp2 + comb3filterL * combdamp1;
comb3bufL[comb3indexL] = input + comb3filterL * combfeeback;
if (++comb3indexL >= sizeof(comb3bufL)/sizeof(float)) comb3indexL = 0;
if (++comb3indexL >= sizeof(comb3bufL) / sizeof(float)) comb3indexL = 0;
bufout = comb4bufL[comb4indexL];
sum += bufout;
comb4filterL = bufout * combdamp2 + comb4filterL * combdamp1;
comb4bufL[comb4indexL] = input +comb4filterL * combfeeback;
if (++comb4indexL >= sizeof(comb4bufL)/sizeof(float)) comb4indexL = 0;
comb4bufL[comb4indexL] = input + comb4filterL * combfeeback;
if (++comb4indexL >= sizeof(comb4bufL) / sizeof(float)) comb4indexL = 0;
bufout = comb5bufL[comb5indexL];
sum += bufout;
comb5filterL = bufout * combdamp2 + comb5filterL * combdamp1;
comb5bufL[comb5indexL] = input + comb5filterL * combfeeback;
if (++comb5indexL >= sizeof(comb5bufL)/sizeof(float)) comb5indexL = 0;
if (++comb5indexL >= sizeof(comb5bufL) / sizeof(float)) comb5indexL = 0;
bufout = comb6bufL[comb6indexL];
sum += bufout;
comb6filterL = bufout * combdamp2 + comb6filterL * combdamp1;
comb6bufL[comb6indexL] = input + comb6filterL * combfeeback;
if (++comb6indexL >= sizeof(comb6bufL)/sizeof(float)) comb6indexL = 0;
if (++comb6indexL >= sizeof(comb6bufL) / sizeof(float)) comb6indexL = 0;
bufout = comb7bufL[comb7indexL];
sum += bufout;
comb7filterL = bufout * combdamp2 + comb7filterL * combdamp1;
comb7bufL[comb7indexL] = input + comb7filterL * combfeeback;
if (++comb7indexL >= sizeof(comb7bufL)/sizeof(float)) comb7indexL = 0;
if (++comb7indexL >= sizeof(comb7bufL) / sizeof(float)) comb7indexL = 0;
bufout = comb8bufL[comb8indexL];
sum += bufout;
comb8filterL = bufout * combdamp2 + comb8filterL * combdamp1;
comb8bufL[comb8indexL] = input + comb8filterL * combfeeback;
if (++comb8indexL >= sizeof(comb8bufL)/sizeof(float)) comb8indexL = 0;
if (++comb8indexL >= sizeof(comb8bufL) / sizeof(float)) comb8indexL = 0;
//outputL = sat16(sum * 31457, 17);
//outputL = sum * 31457.0/131072.0f;
@ -400,49 +401,49 @@ void AudioEffectFreeverbStereoFloat::update()
sum += bufout;
comb1filterR = bufout * combdamp2 + comb1filterR * combdamp1;
comb1bufR[comb1indexR] = input + comb1filterR * combfeeback;
if (++comb1indexR >= sizeof(comb1bufR)/sizeof(float)) comb1indexR = 0;
if (++comb1indexR >= sizeof(comb1bufR) / sizeof(float)) comb1indexR = 0;
bufout = comb2bufR[comb2indexR];
sum += bufout;
comb2filterR = bufout * combdamp2 + comb2filterR * combdamp1;
comb2bufR[comb2indexR] = input + comb2filterR * combfeeback;
if (++comb2indexR >= sizeof(comb2bufR)/sizeof(float)) comb2indexR = 0;
if (++comb2indexR >= sizeof(comb2bufR) / sizeof(float)) comb2indexR = 0;
bufout = comb3bufR[comb3indexR];
sum += bufout;
comb3filterR = bufout * combdamp2 + comb3filterR * combdamp1;
comb3bufR[comb3indexR] = input + comb3filterR * combfeeback;
if (++comb3indexR >= sizeof(comb3bufR)/sizeof(float)) comb3indexR = 0;
if (++comb3indexR >= sizeof(comb3bufR) / sizeof(float)) comb3indexR = 0;
bufout = comb4bufR[comb4indexR];
sum += bufout;
comb4filterR = bufout * combdamp2 + comb4filterR * combdamp1;
comb4bufR[comb4indexR] = input + comb4filterR * combfeeback;
if (++comb4indexR >= sizeof(comb4bufR)/sizeof(float)) comb4indexR = 0;
if (++comb4indexR >= sizeof(comb4bufR) / sizeof(float)) comb4indexR = 0;
bufout = comb5bufR[comb5indexR];
sum += bufout;
comb5filterR = bufout * combdamp2 + comb5filterR * combdamp1;
comb5bufR[comb5indexR] = input + comb5filterR * combfeeback;
if (++comb5indexR >= sizeof(comb5bufR)/sizeof(float)) comb5indexR = 0;
if (++comb5indexR >= sizeof(comb5bufR) / sizeof(float)) comb5indexR = 0;
bufout = comb6bufR[comb6indexR];
sum += bufout;
comb6filterR = bufout * combdamp2 + comb6filterR * combdamp1;
comb6bufR[comb6indexR] = input + comb6filterR * combfeeback;
if (++comb6indexR >= sizeof(comb6bufR)/sizeof(float)) comb6indexR = 0;
if (++comb6indexR >= sizeof(comb6bufR) / sizeof(float)) comb6indexR = 0;
bufout = comb7bufR[comb7indexR];
sum += bufout;
comb7filterR = bufout * combdamp2 + comb7filterR * combdamp1;
comb7bufR[comb7indexR] = input + comb7filterR * combfeeback;
if (++comb7indexR >= sizeof(comb7bufR)/sizeof(float)) comb7indexR = 0;
if (++comb7indexR >= sizeof(comb7bufR) / sizeof(float)) comb7indexR = 0;
bufout = comb8bufR[comb8indexR];
sum += bufout;
comb8filterR = bufout * combdamp2 + comb8filterR * combdamp1;
comb8bufR[comb8indexR] = input + comb8filterR * combfeeback;
if (++comb8indexR >= sizeof(comb8bufR)/sizeof(float)) comb8indexR = 0;
if (++comb8indexR >= sizeof(comb8bufR) / sizeof(float)) comb8indexR = 0;
//outputR = sat16(sum * 31457, 17);
//outputR = sum * 31457.0/131072.0f;
@ -450,23 +451,23 @@ void AudioEffectFreeverbStereoFloat::update()
bufout = allpass1bufL[allpass1indexL];
allpass1bufL[allpass1indexL] = outputL + (bufout / 2.0);
outputL = (bufout - outputL)/2.0;
if (++allpass1indexL >= sizeof(allpass1bufL)/sizeof(float)) allpass1indexL = 0;
outputL = (bufout - outputL) / 2.0;
if (++allpass1indexL >= sizeof(allpass1bufL) / sizeof(float)) allpass1indexL = 0;
bufout = allpass2bufL[allpass2indexL];
allpass2bufL[allpass2indexL] = outputL + (bufout / 2.0);
outputL = (bufout - outputL)/2.0;
if (++allpass2indexL >= sizeof(allpass2bufL)/sizeof(float)) allpass2indexL = 0;
outputL = (bufout - outputL) / 2.0;
if (++allpass2indexL >= sizeof(allpass2bufL) / sizeof(float)) allpass2indexL = 0;
bufout = allpass3bufL[allpass3indexL];
allpass3bufL[allpass3indexL] = outputL + (bufout / 2.0);
outputL = (bufout - outputL)/2.0;
if (++allpass3indexL >= sizeof(allpass3bufL)/sizeof(float)) allpass3indexL = 0;
outputL = (bufout - outputL) / 2.0;
if (++allpass3indexL >= sizeof(allpass3bufL) / sizeof(float)) allpass3indexL = 0;
bufout = allpass4bufL[allpass4indexL];
allpass4bufL[allpass4indexL] = outputL + (bufout / 2.0);
outputL = (bufout - outputL)/2.0;
if (++allpass4indexL >= sizeof(allpass4bufL)/sizeof(float)) allpass4indexL = 0;
outputL = (bufout - outputL) / 2.0;
if (++allpass4indexL >= sizeof(allpass4bufL) / sizeof(float)) allpass4indexL = 0;
//outblockL->data[i] = sat16i(outputL * 30.0, 0);
outblockL->data[i] = sat16i(outputL * 32768.0, 0);
@ -474,23 +475,23 @@ void AudioEffectFreeverbStereoFloat::update()
bufout = allpass1bufR[allpass1indexR];
allpass1bufR[allpass1indexR] = outputR + (bufout / 2.0);
//outputR = sat16(bufout - outputR, 1);
outputR = (bufout - outputR)/2.0;
if (++allpass1indexR >= sizeof(allpass1bufR)/sizeof(float)) allpass1indexR = 0;
outputR = (bufout - outputR) / 2.0;
if (++allpass1indexR >= sizeof(allpass1bufR) / sizeof(float)) allpass1indexR = 0;
bufout = allpass2bufR[allpass2indexR];
allpass2bufR[allpass2indexR] = outputR + (bufout / 2.0);
outputR = (bufout - outputR)/2.0;
if (++allpass2indexR >= sizeof(allpass2bufR)/sizeof(float)) allpass2indexR = 0;
outputR = (bufout - outputR) / 2.0;
if (++allpass2indexR >= sizeof(allpass2bufR) / sizeof(float)) allpass2indexR = 0;
bufout = allpass3bufR[allpass3indexR];
allpass3bufR[allpass3indexR] = outputR + (bufout / 2.0);
outputR = (bufout - outputR)/2.0;
if (++allpass3indexR >= sizeof(allpass3bufR)/sizeof(float)) allpass3indexR = 0;
outputR = (bufout - outputR) / 2.0;
if (++allpass3indexR >= sizeof(allpass3bufR) / sizeof(float)) allpass3indexR = 0;
bufout = allpass4bufR[allpass4indexR];
allpass4bufR[allpass4indexR] = outputR + (bufout / 2.0);
outputR = (bufout - outputR)/2.0;
if (++allpass4indexR >= sizeof(allpass4bufR)/sizeof(float)) allpass4indexR = 0;
outputR = (bufout - outputR) / 2.0;
if (++allpass4indexR >= sizeof(allpass4bufR) / sizeof(float)) allpass4indexR = 0;
//outblockR->data[i] = sat16i(outputR * 30.0, 0);
outblockR->data[i] = sat16i(outputR * 32768.0, 0);

@ -1,28 +1,28 @@
/* Audio Library for Teensy 3.X
* Copyright (c) 2018, Paul Stoffregen, paul@pjrc.com
*
* Development of this audio library was funded by PJRC.COM, LLC by sales of
* Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
* open source software by purchasing Teensy or other PJRC products.
*
* 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, development funding 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.
*/
Copyright (c) 2018, Paul Stoffregen, paul@pjrc.com
Development of this audio library was funded by PJRC.COM, LLC by sales of
Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
open source software by purchasing Teensy or other PJRC products.
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, development funding 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.
*/
#ifndef effect_freeverb_f_h_
#define effect_freeverb_f_h_
@ -31,28 +31,28 @@
class AudioEffectFreeverbFloat : public AudioStream
{
public:
public:
AudioEffectFreeverbFloat();
virtual void update();
void roomsize(float n) {
if (n > 1.0f) n = 1.0f;
else if (n < 0.0) n = 0.0f;
//combfeeback = (n * 9175.04f) + 22937.0;
combfeeback = (n * 9175.04f/32768.0f) + 22937.0/32768.0f;
combfeeback = (n * 9175.04f / 32768.0f) + 22937.0 / 32768.0f;
}
void damping(float n) {
if (n > 1.0f) n = 1.0f;
else if (n < 0.0) n = 0.0f;
//float x1 = (n * 13107.2f);
//float x2 = 32768.0 - x1;
float x1 = (n * 13107.2f/ 32768.0f);
float x1 = (n * 13107.2f / 32768.0f);
float x2 = 1.0 - x1;
__disable_irq();
combdamp1 = x1;
combdamp2 = x2;
__enable_irq();
}
private:
private:
audio_block_t *inputQueueArray[1];
float comb1buf[1116];
float comb2buf[1188];
@ -94,28 +94,28 @@ private:
class AudioEffectFreeverbStereoFloat : public AudioStream
{
public:
public:
AudioEffectFreeverbStereoFloat();
virtual void update();
void roomsize(float n) {
if (n > 1.0f) n = 1.0f;
else if (n < 0.0) n = 0.0f;
//combfeeback = (n * 9175.04f) + 22937.0;
combfeeback = (n * 9175.04f/32768.0f) + 22937.0/32768.0f;
combfeeback = (n * 9175.04f / 32768.0f) + 22937.0 / 32768.0f;
}
void damping(float n) {
if (n > 1.0f) n = 1.0f;
else if (n < 0.0) n = 0.0f;
//float x1 = (n * 13107.2f);
//float x2 = 32768.0 - x1;
float x1 = (n * 13107.2f/ 32768.0f);
float x1 = (n * 13107.2f / 32768.0f);
float x2 = 1.0 - x1;
__disable_irq();
combdamp1 = x1;
combdamp2 = x2;
__enable_irq();
}
private:
private:
audio_block_t *inputQueueArray[1];
float comb1bufL[1116];
float comb2bufL[1188];

188
env.cc

@ -1,188 +0,0 @@
/*
* Copyright 2017 Pascal Gauthier.
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <math.h>
#include "synth.h"
#include "env.h"
//using namespace std;
uint32_t Env::sr_multiplier = (1<<24);
const int levellut[] = {
0, 5, 9, 13, 17, 20, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 42, 43, 45, 46
};
#ifdef ACCURATE_ENVELOPE
const int statics[] = {
1764000, 1764000, 1411200, 1411200, 1190700, 1014300, 992250,
882000, 705600, 705600, 584325, 507150, 502740, 441000, 418950,
352800, 308700, 286650, 253575, 220500, 220500, 176400, 145530,
145530, 125685, 110250, 110250, 88200, 88200, 74970, 61740,
61740, 55125, 48510, 44100, 37485, 31311, 30870, 27562, 27562,
22050, 18522, 17640, 15435, 14112, 13230, 11025, 9261, 9261, 7717,
6615, 6615, 5512, 5512, 4410, 3969, 3969, 3439, 2866, 2690, 2249,
1984, 1896, 1808, 1411, 1367, 1234, 1146, 926, 837, 837, 705,
573, 573, 529, 441, 441
// and so on, I stopped measuring after R=76 (needs to be FRAC_NUM-checked anyway)
};
#endif
void Env::init_sr(FRAC_NUM sampleRate) {
sr_multiplier = (44100.0 / sampleRate) * (1<<24);
}
void Env::init(const int r[4], const int l[4], int ol, int rate_scaling) {
for (int i = 0; i < 4; i++) {
rates_[i] = r[i];
levels_[i] = l[i];
}
outlevel_ = ol;
rate_scaling_ = rate_scaling;
level_ = 0;
down_ = true;
advance(0);
}
int32_t Env::getsample() {
#ifdef ACCURATE_ENVELOPE
if (staticcount_) {
staticcount_ -= N;
if (staticcount_ <= 0) {
staticcount_ = 0;
advance(ix_ + 1);
}
}
#endif
if (ix_ < 3 || ((ix_ < 4) && !down_)) {
if (rising_) {
const int jumptarget = 1716;
if (level_ < (jumptarget << 16)) {
level_ = jumptarget << 16;
}
level_ += (((17 << 24) - level_) >> 24) * inc_;
// TODO: should probably be more accurate when inc is large
if (level_ >= targetlevel_) {
level_ = targetlevel_;
advance(ix_ + 1);
}
}
else if (staticcount_) {
;
}
else { // !rising
level_ -= inc_;
if (level_ <= targetlevel_) {
level_ = targetlevel_;
advance(ix_ + 1);
}
}
}
// TODO: this would be a good place to set level to 0 when under threshold
return level_;
}
void Env::keydown(bool d) {
if (down_ != d) {
down_ = d;
advance(d ? 0 : 3);
}
}
int Env::scaleoutlevel(int outlevel) {
return outlevel >= 20 ? 28 + outlevel : levellut[outlevel];
}
void Env::advance(int newix) {
ix_ = newix;
if (ix_ < 4) {
int newlevel = levels_[ix_];
int actuallevel = scaleoutlevel(newlevel) >> 1;
actuallevel = (actuallevel << 6) + outlevel_ - 4256;
actuallevel = actuallevel < 16 ? 16 : actuallevel;
// level here is same as Java impl
targetlevel_ = actuallevel << 16;
rising_ = (targetlevel_ > level_);
// rate
int qrate = (rates_[ix_] * 41) >> 6;
qrate += rate_scaling_;
qrate = min(qrate, 63);
#ifdef ACCURATE_ENVELOPE
if (targetlevel_ == level_) {
// approximate number of samples at 44.100 kHz to achieve the time
// empirically gathered using 2 TF1s, could probably use some FRAC_NUM-checking
// and cleanup, but it's pretty close for now.
int staticrate = rates_[ix_];
staticrate += rate_scaling_; // needs to be checked, as well, but seems correct
staticrate = min(staticrate, 99);
staticcount_ = staticrate < 77 ? statics[staticrate] : 20 * (99 - staticrate);
staticcount_ = (int)(((int64_t)staticcount_ * (int64_t)sr_multiplier) >> 24);
}
else {
staticcount_ = 0;
}
#endif
inc_ = (4 + (qrate & 3)) << (2 + LG_N + (qrate >> 2));
// meh, this should be fixed elsewhere
inc_ = (int)(((int64_t)inc_ * (int64_t)sr_multiplier) >> 24);
}
}
void Env::update(const int r[4], const int l[4], int ol, int rate_scaling) {
for (int i = 0; i < 4; i++) {
rates_[i] = r[i];
levels_[i] = l[i];
}
outlevel_ = ol;
rate_scaling_ = rate_scaling;
if ( down_ ) {
// for now we simply reset ourselve at level 3
int newlevel = levels_[2];
int actuallevel = scaleoutlevel(newlevel) >> 1;
actuallevel = (actuallevel << 6) - 4256;
actuallevel = actuallevel < 16 ? 16 : actuallevel;
targetlevel_ = actuallevel << 16;
advance(2);
}
}
void Env::getPosition(char *step) {
*step = ix_;
}
void Env::transfer(Env &src) {
for(int i=0;i<4;i++) {
rates_[i] = src.rates_[i];
levels_[i] = src.levels_[i];
}
outlevel_ = src.outlevel_;
rate_scaling_ = src.rate_scaling_;
level_ = src.level_;
targetlevel_ = src.targetlevel_;
rising_= src.rising_;
ix_ = src.ix_;
down_ = src.down_;
#ifdef ACCURATE_ENVELOPE
staticcount_ = src.staticcount_;
#endif
inc_ = src.inc_;
}

@ -1,19 +1,19 @@
/*
* Copyright 2017 Pascal Gauthier.
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2017 Pascal Gauthier.
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <math.h>
@ -22,17 +22,32 @@
//using namespace std;
uint32_t Env::sr_multiplier = (1<<24);
uint32_t Env::sr_multiplier = (1 << 24);
const int levellut[] = {
0, 5, 9, 13, 17, 20, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 42, 43, 45, 46
};
void Env::init_sr(FRAC_NUM sampleRate) {
sr_multiplier = (44100.0 / sampleRate) * (1<<24);
#ifdef ACCURATE_ENVELOPE
const int statics[] = {
1764000, 1764000, 1411200, 1411200, 1190700, 1014300, 992250,
882000, 705600, 705600, 584325, 507150, 502740, 441000, 418950,
352800, 308700, 286650, 253575, 220500, 220500, 176400, 145530,
145530, 125685, 110250, 110250, 88200, 88200, 74970, 61740,
61740, 55125, 48510, 44100, 37485, 31311, 30870, 27562, 27562,
22050, 18522, 17640, 15435, 14112, 13230, 11025, 9261, 9261, 7717,
6615, 6615, 5512, 5512, 4410, 3969, 3969, 3439, 2866, 2690, 2249,
1984, 1896, 1808, 1411, 1367, 1234, 1146, 926, 837, 837, 705,
573, 573, 529, 441, 441
// and so on, I stopped measuring after R=76 (needs to be double-checked anyway)
};
#endif
void Env::init_sr(double sampleRate) {
sr_multiplier = (44100.0 / sampleRate) * (1 << 24);
}
void Env::init(const int r[4], const int l[4], int32_t ol, int rate_scaling) {
void Env::init(const int r[4], const int l[4], int ol, int rate_scaling) {
for (int i = 0; i < 4; i++) {
rates_[i] = r[i];
levels_[i] = l[i];
@ -45,8 +60,21 @@ void Env::init(const int r[4], const int l[4], int32_t ol, int rate_scaling) {
}
int32_t Env::getsample() {
#ifdef ACCURATE_ENVELOPE
if (staticcount_) {
staticcount_ -= _N_;
if (staticcount_ <= 0) {
staticcount_ = 0;
advance(ix_ + 1);
}
}
#endif
if (ix_ < 3 || ((ix_ < 4) && !down_)) {
if (rising_) {
if (staticcount_) {
;
}
else if (rising_) {
const int jumptarget = 1716;
if (level_ < (jumptarget << 16)) {
level_ = jumptarget << 16;
@ -57,7 +85,8 @@ int32_t Env::getsample() {
level_ = targetlevel_;
advance(ix_ + 1);
}
} else { // !rising
}
else { // !rising
level_ -= inc_;
if (level_ <= targetlevel_) {
level_ = targetlevel_;
@ -95,14 +124,32 @@ void Env::advance(int newix) {
int qrate = (rates_[ix_] * 41) >> 6;
qrate += rate_scaling_;
qrate = min(qrate, 63);
inc_ = (4 + (qrate & 3)) << (2 + LG_N + (qrate >> 2));
#ifdef ACCURATE_ENVELOPE
if (targetlevel_ == level_ || (ix_ == 0 && newlevel == 0)) {
// approximate number of samples at 44.100 kHz to achieve the time
// empirically gathered using 2 TF1s, could probably use some double-checking
// and cleanup, but it's pretty close for now.
int staticrate = rates_[ix_];
staticrate += rate_scaling_; // needs to be checked, as well, but seems correct
staticrate = min(staticrate, 99);
staticcount_ = staticrate < 77 ? statics[staticrate] : 20 * (99 - staticrate);
if (staticrate < 77 && (ix_ == 0 && newlevel == 0)) {
staticcount_ /= 20; // attack is scaled faster
}
staticcount_ = (int)(((int64_t)staticcount_ * (int64_t)sr_multiplier) >> 24);
}
else {
staticcount_ = 0;
}
#endif
inc_ = (4 + (qrate & 3)) << (2 + LG_N + (qrate >> 2));
// meh, this should be fixed elsewhere
inc_ = ((int64_t)inc_ * (int64_t)sr_multiplier) >> 24;
inc_ = (int)(((int64_t)inc_ * (int64_t)sr_multiplier) >> 24);
}
}
void Env::update(const int r[4], const int l[4], int32_t ol, int rate_scaling) {
void Env::update(const int r[4], const int l[4], int ol, int rate_scaling) {
for (int i = 0; i < 4; i++) {
rates_[i] = r[i];
levels_[i] = l[i];
@ -110,7 +157,7 @@ void Env::update(const int r[4], const int l[4], int32_t ol, int rate_scaling) {
outlevel_ = ol;
rate_scaling_ = rate_scaling;
if ( down_ ) {
// for now we simply reset ourselve at level 3
// for now we simply reset ourselves at level 3
int newlevel = levels_[2];
int actuallevel = scaleoutlevel(newlevel) >> 1;
actuallevel = (actuallevel << 6) - 4256;
@ -125,7 +172,7 @@ void Env::getPosition(char *step) {
}
void Env::transfer(Env &src) {
for(int i=0;i<4;i++) {
for (int i = 0; i < 4; i++) {
rates_[i] = src.rates_[i];
levels_[i] = src.levels_[i];
}
@ -133,9 +180,11 @@ void Env::transfer(Env &src) {
rate_scaling_ = src.rate_scaling_;
level_ = src.level_;
targetlevel_ = src.targetlevel_;
rising_= src.rising_;
rising_ = src.rising_;
ix_ = src.ix_;
inc_ = src.inc_;
down_ = src.down_;
#ifdef ACCURATE_ENVELOPE
staticcount_ = src.staticcount_;
#endif
inc_ = src.inc_;
}

37
env.h

@ -1,19 +1,19 @@
/*
* Copyright 2017 Pascal Gauthier.
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2017 Pascal Gauthier.
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef __ENV_H
#define __ENV_H
@ -31,10 +31,10 @@ class Env {
// (ie, value 0..99). The outlevel parameter is calibrated in microsteps
// (ie units of approx .023 dB), with 99 * 32 = nominal full scale. The
// rate_scaling parameter is in qRate units (ie 0..63).
void init(const int rates[4], const int levels[4], int32_t outlevel,
void init(const int rates[4], const int levels[4], int outlevel,
int rate_scaling);
void update(const int rates[4], const int levels[4], int32_t outlevel,
void update(const int rates[4], const int levels[4], int outlevel,
int rate_scaling);
// Result is in Q24/doubling log format. Also, result is subsampled
// for every N samples.
@ -48,7 +48,7 @@ class Env {
static int scaleoutlevel(int outlevel);
void getPosition(char *step);
static void init_sr(FRAC_NUM sample_rate);
static void init_sr(double sample_rate);
void transfer(Env &src);
private:
@ -79,4 +79,3 @@ class Env {
};
#endif // __ENV_H

@ -1,18 +1,18 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
class Exp2 {
public:
@ -66,7 +66,7 @@ int32_t Tanh::lookup(int32_t x) {
if (x >= (17 << 23)) {
return signum ^ (1 << 24);
}
int32_t sx = ((int64_t)-48408812 * (int64_t)x) >> 24;
int32_t sx = ((int64_t) - 48408812 * (int64_t)x) >> 24;
return signum ^ ((1 << 24) - 2 * Exp2::lookup(sx));
} else {
const int SHIFT = 26 - TANH_LG_N_SAMPLES;

@ -1,18 +1,18 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifdef VERBOSE
#include <iostream>
@ -71,13 +71,13 @@ int n_out(const FmAlgorithm &alg) {
uint8_t FmCore::get_carrier_operators(uint8_t algorithm)
{
uint8_t op_out=0;
FmAlgorithm alg=algorithms[algorithm];
uint8_t op_out = 0;
FmAlgorithm alg = algorithms[algorithm];
for(uint8_t i=0; i<6;i++)
for (uint8_t i = 0; i < 6; i++)
{
if((alg.ops[i]&OUT_BUS_ADD)==OUT_BUS_ADD)
op_out|=1<<i;
if ((alg.ops[i]&OUT_BUS_ADD) == OUT_BUS_ADD)
op_out |= 1 << i;
}
return op_out;

@ -1,18 +1,18 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef __FM_CORE_H
#define __FM_CORE_H
@ -25,7 +25,7 @@
class FmOperatorInfo {
public:
public:
int in;
int out;
};
@ -41,17 +41,17 @@ enum FmOperatorFlags {
};
class FmAlgorithm {
public:
public:
int ops[6];
};
class FmCore {
public:
public:
virtual ~FmCore() {};
static void dump();
uint8_t get_carrier_operators(uint8_t algorithm);
virtual void render(int32_t *output, FmOpParams *params, int algorithm, int32_t *fb_buf, int feedback_gain);
protected:
protected:
AlignedBuf<int32_t, _N_>buf_[2];
const static FmAlgorithm algorithms[32];
};

@ -1,283 +0,0 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <math.h>
#include <cstdlib>
#ifdef HAVE_NEON
#include <cpu-features.h>
#endif
#include "synth.h"
#include "sin.h"
#include "fm_op_kernel.h"
#ifdef HAVE_NEONx
static bool hasNeon() {
return true;
return (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
}
extern "C"
void neon_fm_kernel(const int *in, const int *busin, int *out, int count,
int32_t phase0, int32_t freq, int32_t gain1, int32_t dgain);
const int32_t __attribute__ ((aligned(16))) zeros[N] = {0};
#else
static bool hasNeon() {
return false;
}
#endif
void FmOpKernel::compute(int32_t *output, const int32_t *input,
int32_t phase0, int32_t freq,
int32_t gain1, int32_t gain2, bool add) {
int32_t dgain = (gain2 - gain1 + (N >> 1)) >> LG_N;
int32_t gain = gain1;
int32_t phase = phase0;
if (hasNeon()) {
#ifdef HAVE_NEON
neon_fm_kernel(input, add ? output : zeros, output, _N_,
phase0, freq, gain, dgain);
#endif
} else {
if (add) {
for (int i = 0; i < _N_; i++) {
gain += dgain;
int32_t y = Sin::lookup(phase + input[i]);
int32_t y1 = ((int64_t)y * (int64_t)gain) >> 24;
output[i] += y1;
phase += freq;
}
} else {
for (int i = 0; i < _N_; i++) {
gain += dgain;
int32_t y = Sin::lookup(phase + input[i]);
int32_t y1 = ((int64_t)y * (int64_t)gain) >> 24;
output[i] = y1;
phase += freq;
}
}
}
}
void FmOpKernel::compute_pure(int32_t *output, int32_t phase0, int32_t freq,
int32_t gain1, int32_t gain2, bool add) {
int32_t dgain = (gain2 - gain1 + (N >> 1)) >> LG_N;
int32_t gain = gain1;
int32_t phase = phase0;
if (hasNeon()) {
#ifdef HAVE_NEON
neon_fm_kernel(zeros, add ? output : zeros, output, _N_,
phase0, freq, gain, dgain);
#endif
} else {
if (add) {
for (int i = 0; i < _N_; i++) {
gain += dgain;
int32_t y = Sin::lookup(phase);
int32_t y1 = ((int64_t)y * (int64_t)gain) >> 24;
output[i] += y1;
phase += freq;
}
} else {
for (int i = 0; i < _N_; i++) {
gain += dgain;
int32_t y = Sin::lookup(phase);
int32_t y1 = ((int64_t)y * (int64_t)gain) >> 24;
output[i] = y1;
phase += freq;
}
}
}
}
#define noDOUBLE_ACCURACY
#define HIGH_ACCURACY
void FmOpKernel::compute_fb(int32_t *output, int32_t phase0, int32_t freq,
int32_t gain1, int32_t gain2,
int32_t *fb_buf, int fb_shift, bool add) {
int32_t dgain = (gain2 - gain1 + (N >> 1)) >> LG_N;
int32_t gain = gain1;
int32_t phase = phase0;
int32_t y0 = fb_buf[0];
int32_t y = fb_buf[1];
if (add) {
for (int i = 0; i < _N_; i++) {
gain += dgain;
int32_t scaled_fb = (y0 + y) >> (fb_shift + 1);
y0 = y;
y = Sin::lookup(phase + scaled_fb);
y = ((int64_t)y * (int64_t)gain) >> 24;
output[i] += y;
phase += freq;
}
} else {
for (int i = 0; i < _N_; i++) {
gain += dgain;
int32_t scaled_fb = (y0 + y) >> (fb_shift + 1);
y0 = y;
y = Sin::lookup(phase + scaled_fb);
y = ((int64_t)y * (int64_t)gain) >> 24;
output[i] = y;
phase += freq;
}
}
fb_buf[0] = y0;
fb_buf[1] = y;
}
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
// Experimental sine wave generators below
#if 0
// Results: accuracy 64.3 mean, 170 worst case
// high accuracy: 5.0 mean, 49 worst case
void FmOpKernel::compute_pure(int32_t *output, int32_t phase0, int32_t freq,
int32_t gain1, int32_t gain2, bool add) {
int32_t dgain = (gain2 - gain1 + (N >> 1)) >> LG_N;
int32_t gain = gain1;
int32_t phase = phase0;
#ifdef HIGH_ACCURACY
int32_t u = Sin::compute10(phase << 6);
u = ((int64_t)u * gain) >> 30;
int32_t v = Sin::compute10((phase << 6) + (1 << 28)); // quarter cycle
v = ((int64_t)v * gain) >> 30;
int32_t s = Sin::compute10(freq << 6);
int32_t c = Sin::compute10((freq << 6) + (1 << 28));
#else
int32_t u = Sin::compute(phase);
u = ((int64_t)u * gain) >> 24;
int32_t v = Sin::compute(phase + (1 << 22)); // quarter cycle
v = ((int64_t)v * gain) >> 24;
int32_t s = Sin::compute(freq) << 6;
int32_t c = Sin::compute(freq + (1 << 22)) << 6;
#endif
for (int i = 0; i < _N_; i++) {
output[i] = u;
int32_t t = ((int64_t)v * (int64_t)c - (int64_t)u * (int64_t)s) >> 30;
u = ((int64_t)u * (int64_t)c + (int64_t)v * (int64_t)s) >> 30;
v = t;
}
}
#endif
#if 0
// Results: accuracy 392.3 mean, 15190 worst case (near freq = 0.5)
// for freq < 0.25, 275.2 mean, 716 worst
// high accuracy: 57.4 mean, 7559 worst
// freq < 0.25: 17.9 mean, 78 worst
void FmOpKernel::compute_pure(int32_t *output, int32_t phase0, int32_t freq,
int32_t gain1, int32_t gain2, bool add) {
int32_t dgain = (gain2 - gain1 + (N >> 1)) >> LG_N;
int32_t gain = gain1;
int32_t phase = phase0;
#ifdef HIGH_ACCURACY
int32_t u = floor(gain * sin(phase * (M_PI / (1 << 23))) + 0.5);
int32_t v = floor(gain * cos((phase - freq * 0.5) * (M_PI / (1 << 23))) + 0.5);
int32_t a = floor((1 << 25) * sin(freq * (M_PI / (1 << 24))) + 0.5);
#else
int32_t u = Sin::compute(phase);
u = ((int64_t)u * gain) >> 24;
int32_t v = Sin::compute(phase + (1 << 22) - (freq >> 1));
v = ((int64_t)v * gain) >> 24;
int32_t a = Sin::compute(freq >> 1) << 1;
#endif
for (int i = 0; i < _N_; i++) {
output[i] = u;
v -= ((int64_t)a * (int64_t)u) >> 24;
u += ((int64_t)a * (int64_t)v) >> 24;
}
}
#endif
#if 0
// Results: accuracy 370.0 mean, 15480 worst case (near freq = 0.5)
// with FRAC_NUM accuracy initialization: mean 1.55, worst 58 (near freq = 0)
// with high accuracy: mean 4.2, worst 292 (near freq = 0.5)
void FmOpKernel::compute_pure(int32_t *output, int32_t phase0, int32_t freq,
int32_t gain1, int32_t gain2, bool add) {
int32_t dgain = (gain2 - gain1 + (N >> 1)) >> LG_N;
int32_t gain = gain1;
int32_t phase = phase0;
#ifdef DOUBLE_ACCURACY
int32_t u = floor((1 << 30) * sin(phase * (M_PI / (1 << 23))) + 0.5);
FRAC_NUM a_d = sin(freq * (M_PI / (1 << 24)));
int32_t v = floor((1LL << 31) * a_d * cos((phase - freq * 0.5) *
(M_PI / (1 << 23))) + 0.5);
int32_t aa = floor((1LL << 31) * a_d * a_d + 0.5);
#else
#ifdef HIGH_ACCURACY
int32_t u = Sin::compute10(phase << 6);
int32_t v = Sin::compute10((phase << 6) + (1 << 28) - (freq << 5));
int32_t a = Sin::compute10(freq << 5);
v = ((int64_t)v * (int64_t)a) >> 29;
int32_t aa = ((int64_t)a * (int64_t)a) >> 29;
#else
int32_t u = Sin::compute(phase) << 6;
int32_t v = Sin::compute(phase + (1 << 22) - (freq >> 1));
int32_t a = Sin::compute(freq >> 1);
v = ((int64_t)v * (int64_t)a) >> 17;
int32_t aa = ((int64_t)a * (int64_t)a) >> 17;
#endif
#endif
if (aa < 0) aa = (1 << 31) - 1;
for (int i = 0; i < _N_; i++) {
gain += dgain;
output[i] = ((int64_t)u * (int64_t)gain) >> 30;
v -= ((int64_t)aa * (int64_t)u) >> 29;
u += v;
}
}
#endif
#if 0
// Results:: accuracy 112.3 mean, 4262 worst (near freq = 0.5)
// high accuracy 2.9 mean, 143 worst
void FmOpKernel::compute_pure(int32_t *output, int32_t phase0, int32_t freq,
int32_t gain1, int32_t gain2, bool add) {
int32_t dgain = (gain2 - gain1 + (N >> 1)) >> LG_N;
int32_t gain = gain1;
int32_t phase = phase0;
#ifdef HIGH_ACCURACY
int32_t u = Sin::compute10(phase << 6);
int32_t lastu = Sin::compute10((phase - freq) << 6);
int32_t a = Sin::compute10((freq << 6) + (1 << 28)) << 1;
#else
int32_t u = Sin::compute(phase) << 6;
int32_t lastu = Sin::compute(phase - freq) << 6;
int32_t a = Sin::compute(freq + (1 << 22)) << 7;
#endif
if (a < 0 && freq < 256) a = (1 << 31) - 1;
if (a > 0 && freq > 0x7fff00) a = -(1 << 31);
for (int i = 0; i < _N_; i++) {
gain += dgain;
output[i] = ((int64_t)u * (int64_t)gain) >> 30;
//output[i] = u;
int32_t newu = (((int64_t)u * (int64_t)a) >> 30) - lastu;
lastu = u;
u = newu;
}
}
#endif

@ -1,18 +1,18 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "config.h"
#include <math.h>
@ -281,4 +281,3 @@ void FmOpKernel::compute_pure(int32_t *output, int32_t phase0, int32_t freq,
}
}
#endif

@ -1,18 +1,18 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef __FM_OP_KERNEL_H
#define __FM_OP_KERNEL_H

@ -1,18 +1,18 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Resolve frequency signal (1.0 in Q24 format = 1 octave) to phase delta.

@ -1,18 +1,18 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "synth.h"

@ -1,18 +1,18 @@
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2013 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Low frequency oscillator, compatible with DX7

28
lfo.h

@ -1,18 +1,18 @@
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2013 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Low frequency oscillator, compatible with DX7

@ -1,5 +1,5 @@
/*************************************************
* MIDI note values
MIDI note values
*************************************************/
#ifndef _MIDINOTES_H

@ -1,18 +1,18 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef SYNTH_MODULE_H
#define SYNTH_MODULE_H
@ -28,4 +28,3 @@ class Module {
};
#endif // SYNTH_MODULE_H

@ -1,28 +1,28 @@
/* Audio Library for Teensy 3.X
* Copyright (c) 2018, Paul Stoffregen, paul@pjrc.com
*
* Development of this audio library was funded by PJRC.COM, LLC by sales of
* Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
* open source software by purchasing Teensy or other PJRC products.
*
* 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, development funding 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.
*/
Copyright (c) 2018, Paul Stoffregen, paul@pjrc.com
Development of this audio library was funded by PJRC.COM, LLC by sales of
Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
open source software by purchasing Teensy or other PJRC products.
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, development funding 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.
*/
// A fixed point implementation of Freeverb by Jezar at Dreampoint
// http://blog.bjornroche.com/2012/06/freeverb-original-public-domain-code-by.html
@ -94,30 +94,31 @@ static int16_t sat16(int32_t n, int rshift) {
// TODO: move this to one of the data files, use in output_adat.cpp, output_tdm.cpp, etc
static const audio_block_t zeroblock = {
0, 0, 0, {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#if AUDIO_BLOCK_SAMPLES > 16
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 32
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 48
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 64
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 80
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 96
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 112
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
} };
}
};
void MyAudioEffectFreeverb::update()
{
@ -137,7 +138,7 @@ void MyAudioEffectFreeverb::update()
block = receiveReadOnly(0);
if (!block) block = &zeroblock;
for (i=0; i < AUDIO_BLOCK_SAMPLES; i++) {
for (i = 0; i < AUDIO_BLOCK_SAMPLES; i++) {
// TODO: scale numerical range depending on roomsize & damping
input = sat16(block->data[i] * 8738, 17); // for numerical headroom
sum = 0;
@ -146,71 +147,71 @@ void MyAudioEffectFreeverb::update()
sum += bufout;
comb1filter = sat16(bufout * combdamp2 + comb1filter * combdamp1, 15);
comb1buf[comb1index] = sat16(input + sat16(comb1filter * combfeeback, 15), 0);
if (++comb1index >= sizeof(comb1buf)/sizeof(int16_t)) comb1index = 0;
if (++comb1index >= sizeof(comb1buf) / sizeof(int16_t)) comb1index = 0;
bufout = comb2buf[comb2index];
sum += bufout;
comb2filter = sat16(bufout * combdamp2 + comb2filter * combdamp1, 15);
comb2buf[comb2index] = sat16(input + sat16(comb2filter * combfeeback, 15), 0);
if (++comb2index >= sizeof(comb2buf)/sizeof(int16_t)) comb2index = 0;
if (++comb2index >= sizeof(comb2buf) / sizeof(int16_t)) comb2index = 0;
bufout = comb3buf[comb3index];
sum += bufout;
comb3filter = sat16(bufout * combdamp2 + comb3filter * combdamp1, 15);
comb3buf[comb3index] = sat16(input + sat16(comb3filter * combfeeback, 15), 0);
if (++comb3index >= sizeof(comb3buf)/sizeof(int16_t)) comb3index = 0;
if (++comb3index >= sizeof(comb3buf) / sizeof(int16_t)) comb3index = 0;
bufout = comb4buf[comb4index];
sum += bufout;
comb4filter = sat16(bufout * combdamp2 + comb4filter * combdamp1, 15);
comb4buf[comb4index] = sat16(input + sat16(comb4filter * combfeeback, 15), 0);
if (++comb4index >= sizeof(comb4buf)/sizeof(int16_t)) comb4index = 0;
if (++comb4index >= sizeof(comb4buf) / sizeof(int16_t)) comb4index = 0;
bufout = comb5buf[comb5index];
sum += bufout;
comb5filter = sat16(bufout * combdamp2 + comb5filter * combdamp1, 15);
comb5buf[comb5index] = sat16(input + sat16(comb5filter * combfeeback, 15), 0);
if (++comb5index >= sizeof(comb5buf)/sizeof(int16_t)) comb5index = 0;
if (++comb5index >= sizeof(comb5buf) / sizeof(int16_t)) comb5index = 0;
bufout = comb6buf[comb6index];
sum += bufout;
comb6filter = sat16(bufout * combdamp2 + comb6filter * combdamp1, 15);
comb6buf[comb6index] = sat16(input + sat16(comb6filter * combfeeback, 15), 0);
if (++comb6index >= sizeof(comb6buf)/sizeof(int16_t)) comb6index = 0;
if (++comb6index >= sizeof(comb6buf) / sizeof(int16_t)) comb6index = 0;
bufout = comb7buf[comb7index];
sum += bufout;
comb7filter = sat16(bufout * combdamp2 + comb7filter * combdamp1, 15);
comb7buf[comb7index] = sat16(input + sat16(comb7filter * combfeeback, 15), 0);
if (++comb7index >= sizeof(comb7buf)/sizeof(int16_t)) comb7index = 0;
if (++comb7index >= sizeof(comb7buf) / sizeof(int16_t)) comb7index = 0;
bufout = comb8buf[comb8index];
sum += bufout;
comb8filter = sat16(bufout * combdamp2 + comb8filter * combdamp1, 15);
comb8buf[comb8index] = sat16(input + sat16(comb8filter * combfeeback, 15), 0);
if (++comb8index >= sizeof(comb8buf)/sizeof(int16_t)) comb8index = 0;
if (++comb8index >= sizeof(comb8buf) / sizeof(int16_t)) comb8index = 0;
output = sat16(sum * 31457, 17);
bufout = allpass1buf[allpass1index];
allpass1buf[allpass1index] = output + (bufout >> 1);
output = sat16(bufout - output, 1);
if (++allpass1index >= sizeof(allpass1buf)/sizeof(int16_t)) allpass1index = 0;
if (++allpass1index >= sizeof(allpass1buf) / sizeof(int16_t)) allpass1index = 0;
bufout = allpass2buf[allpass2index];
allpass2buf[allpass2index] = output + (bufout >> 1);
output = sat16(bufout - output, 1);
if (++allpass2index >= sizeof(allpass2buf)/sizeof(int16_t)) allpass2index = 0;
if (++allpass2index >= sizeof(allpass2buf) / sizeof(int16_t)) allpass2index = 0;
bufout = allpass3buf[allpass3index];
allpass3buf[allpass3index] = output + (bufout >> 1);
output = sat16(bufout - output, 1);
if (++allpass3index >= sizeof(allpass3buf)/sizeof(int16_t)) allpass3index = 0;
if (++allpass3index >= sizeof(allpass3buf) / sizeof(int16_t)) allpass3index = 0;
bufout = allpass4buf[allpass4index];
allpass4buf[allpass4index] = output + (bufout >> 1);
output = sat16(bufout - output, 1);
if (++allpass4index >= sizeof(allpass4buf)/sizeof(int16_t)) allpass4index = 0;
if (++allpass4index >= sizeof(allpass4buf) / sizeof(int16_t)) allpass4index = 0;
outblock->data[i] = sat16(output * 30, 0);
}
@ -318,7 +319,7 @@ void MyAudioEffectFreeverbStereo::update()
}
if (!block) block = &zeroblock;
for (i=0; i < AUDIO_BLOCK_SAMPLES; i++) {
for (i = 0; i < AUDIO_BLOCK_SAMPLES; i++) {
// TODO: scale numerical range depending on roomsize & damping
input = sat16(block->data[i] * 8738, 17); // for numerical headroom
sum = 0;
@ -327,49 +328,49 @@ void MyAudioEffectFreeverbStereo::update()
sum += bufout;
comb1filterL = sat16(bufout * combdamp2 + comb1filterL * combdamp1, 15);
comb1bufL[comb1indexL] = sat16(input + sat16(comb1filterL * combfeeback, 15), 0);
if (++comb1indexL >= sizeof(comb1bufL)/sizeof(int16_t)) comb1indexL = 0;
if (++comb1indexL >= sizeof(comb1bufL) / sizeof(int16_t)) comb1indexL = 0;
bufout = comb2bufL[comb2indexL];
sum += bufout;
comb2filterL = sat16(bufout * combdamp2 + comb2filterL * combdamp1, 15);
comb2bufL[comb2indexL] = sat16(input + sat16(comb2filterL * combfeeback, 15), 0);
if (++comb2indexL >= sizeof(comb2bufL)/sizeof(int16_t)) comb2indexL = 0;
if (++comb2indexL >= sizeof(comb2bufL) / sizeof(int16_t)) comb2indexL = 0;
bufout = comb3bufL[comb3indexL];
sum += bufout;
comb3filterL = sat16(bufout * combdamp2 + comb3filterL * combdamp1, 15);
comb3bufL[comb3indexL] = sat16(input + sat16(comb3filterL * combfeeback, 15), 0);
if (++comb3indexL >= sizeof(comb3bufL)/sizeof(int16_t)) comb3indexL = 0;
if (++comb3indexL >= sizeof(comb3bufL) / sizeof(int16_t)) comb3indexL = 0;
bufout = comb4bufL[comb4indexL];
sum += bufout;
comb4filterL = sat16(bufout * combdamp2 + comb4filterL * combdamp1, 15);
comb4bufL[comb4indexL] = sat16(input + sat16(comb4filterL * combfeeback, 15), 0);
if (++comb4indexL >= sizeof(comb4bufL)/sizeof(int16_t)) comb4indexL = 0;
if (++comb4indexL >= sizeof(comb4bufL) / sizeof(int16_t)) comb4indexL = 0;
bufout = comb5bufL[comb5indexL];
sum += bufout;
comb5filterL = sat16(bufout * combdamp2 + comb5filterL * combdamp1, 15);
comb5bufL[comb5indexL] = sat16(input + sat16(comb5filterL * combfeeback, 15), 0);
if (++comb5indexL >= sizeof(comb5bufL)/sizeof(int16_t)) comb5indexL = 0;
if (++comb5indexL >= sizeof(comb5bufL) / sizeof(int16_t)) comb5indexL = 0;
bufout = comb6bufL[comb6indexL];
sum += bufout;
comb6filterL = sat16(bufout * combdamp2 + comb6filterL * combdamp1, 15);
comb6bufL[comb6indexL] = sat16(input + sat16(comb6filterL * combfeeback, 15), 0);
if (++comb6indexL >= sizeof(comb6bufL)/sizeof(int16_t)) comb6indexL = 0;
if (++comb6indexL >= sizeof(comb6bufL) / sizeof(int16_t)) comb6indexL = 0;
bufout = comb7bufL[comb7indexL];
sum += bufout;
comb7filterL = sat16(bufout * combdamp2 + comb7filterL * combdamp1, 15);
comb7bufL[comb7indexL] = sat16(input + sat16(comb7filterL * combfeeback, 15), 0);
if (++comb7indexL >= sizeof(comb7bufL)/sizeof(int16_t)) comb7indexL = 0;
if (++comb7indexL >= sizeof(comb7bufL) / sizeof(int16_t)) comb7indexL = 0;
bufout = comb8bufL[comb8indexL];
sum += bufout;
comb8filterL = sat16(bufout * combdamp2 + comb8filterL * combdamp1, 15);
comb8bufL[comb8indexL] = sat16(input + sat16(comb8filterL * combfeeback, 15), 0);
if (++comb8indexL >= sizeof(comb8bufL)/sizeof(int16_t)) comb8indexL = 0;
if (++comb8indexL >= sizeof(comb8bufL) / sizeof(int16_t)) comb8indexL = 0;
outputL = sat16(sum * 31457, 17);
sum = 0;
@ -378,93 +379,93 @@ void MyAudioEffectFreeverbStereo::update()
sum += bufout;
comb1filterR = sat16(bufout * combdamp2 + comb1filterR * combdamp1, 15);
comb1bufR[comb1indexR] = sat16(input + sat16(comb1filterR * combfeeback, 15), 0);
if (++comb1indexR >= sizeof(comb1bufR)/sizeof(int16_t)) comb1indexR = 0;
if (++comb1indexR >= sizeof(comb1bufR) / sizeof(int16_t)) comb1indexR = 0;
bufout = comb2bufR[comb2indexR];
sum += bufout;
comb2filterR = sat16(bufout * combdamp2 + comb2filterR * combdamp1, 15);
comb2bufR[comb2indexR] = sat16(input + sat16(comb2filterR * combfeeback, 15), 0);
if (++comb2indexR >= sizeof(comb2bufR)/sizeof(int16_t)) comb2indexR = 0;
if (++comb2indexR >= sizeof(comb2bufR) / sizeof(int16_t)) comb2indexR = 0;
bufout = comb3bufR[comb3indexR];
sum += bufout;
comb3filterR = sat16(bufout * combdamp2 + comb3filterR * combdamp1, 15);
comb3bufR[comb3indexR] = sat16(input + sat16(comb3filterR * combfeeback, 15), 0);
if (++comb3indexR >= sizeof(comb3bufR)/sizeof(int16_t)) comb3indexR = 0;
if (++comb3indexR >= sizeof(comb3bufR) / sizeof(int16_t)) comb3indexR = 0;
bufout = comb4bufR[comb4indexR];
sum += bufout;
comb4filterR = sat16(bufout * combdamp2 + comb4filterR * combdamp1, 15);
comb4bufR[comb4indexR] = sat16(input + sat16(comb4filterR * combfeeback, 15), 0);
if (++comb4indexR >= sizeof(comb4bufR)/sizeof(int16_t)) comb4indexR = 0;
if (++comb4indexR >= sizeof(comb4bufR) / sizeof(int16_t)) comb4indexR = 0;
bufout = comb5bufR[comb5indexR];
sum += bufout;
comb5filterR = sat16(bufout * combdamp2 + comb5filterR * combdamp1, 15);
comb5bufR[comb5indexR] = sat16(input + sat16(comb5filterR * combfeeback, 15), 0);
if (++comb5indexR >= sizeof(comb5bufR)/sizeof(int16_t)) comb5indexR = 0;
if (++comb5indexR >= sizeof(comb5bufR) / sizeof(int16_t)) comb5indexR = 0;
bufout = comb6bufR[comb6indexR];
sum += bufout;
comb6filterR = sat16(bufout * combdamp2 + comb6filterR * combdamp1, 15);
comb6bufR[comb6indexR] = sat16(input + sat16(comb6filterR * combfeeback, 15), 0);
if (++comb6indexR >= sizeof(comb6bufR)/sizeof(int16_t)) comb6indexR = 0;
if (++comb6indexR >= sizeof(comb6bufR) / sizeof(int16_t)) comb6indexR = 0;
bufout = comb7bufR[comb7indexR];
sum += bufout;
comb7filterR = sat16(bufout * combdamp2 + comb7filterR * combdamp1, 15);
comb7bufR[comb7indexR] = sat16(input + sat16(comb7filterR * combfeeback, 15), 0);
if (++comb7indexR >= sizeof(comb7bufR)/sizeof(int16_t)) comb7indexR = 0;
if (++comb7indexR >= sizeof(comb7bufR) / sizeof(int16_t)) comb7indexR = 0;
bufout = comb8bufR[comb8indexR];
sum += bufout;
comb8filterR = sat16(bufout * combdamp2 + comb8filterR * combdamp1, 15);
comb8bufR[comb8indexR] = sat16(input + sat16(comb8filterR * combfeeback, 15), 0);
if (++comb8indexR >= sizeof(comb8bufR)/sizeof(int16_t)) comb8indexR = 0;
if (++comb8indexR >= sizeof(comb8bufR) / sizeof(int16_t)) comb8indexR = 0;
outputR = sat16(sum * 31457, 17);
bufout = allpass1bufL[allpass1indexL];
allpass1bufL[allpass1indexL] = outputL + (bufout >> 1);
outputL = sat16(bufout - outputL, 1);
if (++allpass1indexL >= sizeof(allpass1bufL)/sizeof(int16_t)) allpass1indexL = 0;
if (++allpass1indexL >= sizeof(allpass1bufL) / sizeof(int16_t)) allpass1indexL = 0;
bufout = allpass2bufL[allpass2indexL];
allpass2bufL[allpass2indexL] = outputL + (bufout >> 1);
outputL = sat16(bufout - outputL, 1);
if (++allpass2indexL >= sizeof(allpass2bufL)/sizeof(int16_t)) allpass2indexL = 0;
if (++allpass2indexL >= sizeof(allpass2bufL) / sizeof(int16_t)) allpass2indexL = 0;
bufout = allpass3bufL[allpass3indexL];
allpass3bufL[allpass3indexL] = outputL + (bufout >> 1);
outputL = sat16(bufout - outputL, 1);
if (++allpass3indexL >= sizeof(allpass3bufL)/sizeof(int16_t)) allpass3indexL = 0;
if (++allpass3indexL >= sizeof(allpass3bufL) / sizeof(int16_t)) allpass3indexL = 0;
bufout = allpass4bufL[allpass4indexL];
allpass4bufL[allpass4indexL] = outputL + (bufout >> 1);
outputL = sat16(bufout - outputL, 1);
if (++allpass4indexL >= sizeof(allpass4bufL)/sizeof(int16_t)) allpass4indexL = 0;
if (++allpass4indexL >= sizeof(allpass4bufL) / sizeof(int16_t)) allpass4indexL = 0;
outblockL->data[i] = sat16(outputL * 30, 0);
bufout = allpass1bufR[allpass1indexR];
allpass1bufR[allpass1indexR] = outputR + (bufout >> 1);
outputR = sat16(bufout - outputR, 1);
if (++allpass1indexR >= sizeof(allpass1bufR)/sizeof(int16_t)) allpass1indexR = 0;
if (++allpass1indexR >= sizeof(allpass1bufR) / sizeof(int16_t)) allpass1indexR = 0;
bufout = allpass2bufR[allpass2indexR];
allpass2bufR[allpass2indexR] = outputR + (bufout >> 1);
outputR = sat16(bufout - outputR, 1);
if (++allpass2indexR >= sizeof(allpass2bufR)/sizeof(int16_t)) allpass2indexR = 0;
if (++allpass2indexR >= sizeof(allpass2bufR) / sizeof(int16_t)) allpass2indexR = 0;
bufout = allpass3bufR[allpass3indexR];
allpass3bufR[allpass3indexR] = outputR + (bufout >> 1);
outputR = sat16(bufout - outputR, 1);
if (++allpass3indexR >= sizeof(allpass3bufR)/sizeof(int16_t)) allpass3indexR = 0;
if (++allpass3indexR >= sizeof(allpass3bufR) / sizeof(int16_t)) allpass3indexR = 0;
bufout = allpass4bufR[allpass4indexR];
allpass4bufR[allpass4indexR] = outputR + (bufout >> 1);
outputR = sat16(bufout - outputR, 1);
if (++allpass4indexR >= sizeof(allpass4bufR)/sizeof(int16_t)) allpass4indexR = 0;
if (++allpass4indexR >= sizeof(allpass4bufR) / sizeof(int16_t)) allpass4indexR = 0;
outblockR->data[i] = sat16(outputL * 30, 0);
}

@ -1,28 +1,28 @@
/* Audio Library for Teensy 3.X
* Copyright (c) 2018, Paul Stoffregen, paul@pjrc.com
*
* Development of this audio library was funded by PJRC.COM, LLC by sales of
* Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
* open source software by purchasing Teensy or other PJRC products.
*
* 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, development funding 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.
*/
Copyright (c) 2018, Paul Stoffregen, paul@pjrc.com
Development of this audio library was funded by PJRC.COM, LLC by sales of
Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
open source software by purchasing Teensy or other PJRC products.
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, development funding 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.
*/
#ifndef my_effect_freeverb_h_
#define my_effect_freeverb_h_
@ -31,7 +31,7 @@
class MyAudioEffectFreeverb : public AudioStream
{
public:
public:
MyAudioEffectFreeverb();
virtual void update();
void roomsize(float n) {
@ -49,7 +49,7 @@ public:
combdamp2 = x2;
__enable_irq();
}
private:
private:
audio_block_t *inputQueueArray[1];
int16_t comb1buf[1116];
int16_t comb2buf[1188];
@ -91,7 +91,7 @@ private:
class MyAudioEffectFreeverbStereo : public AudioStream
{
public:
public:
MyAudioEffectFreeverbStereo();
virtual void update();
void roomsize(float n) {
@ -109,7 +109,7 @@ public:
combdamp2 = x2;
__enable_irq();
}
private:
private:
audio_block_t *inputQueueArray[1];
int16_t comb1bufL[1116];
int16_t comb2bufL[1188];

@ -1,18 +1,18 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "synth.h"
#include "pitchenv.h"
@ -91,5 +91,3 @@ void PitchEnv::advance(int newix) {
void PitchEnv::getPosition(char *step) {
*step = ix_;
}

@ -1,18 +1,18 @@
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2013 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef __PITCHENV_H
#define __PITCHENV_H
@ -49,5 +49,4 @@ class PitchEnv {
extern const uint8_t pitchenv_rate[];
extern const int8_t pitchenv_tab[];
#endif // __PITCHENV_H
#endif // __PITCHENV_H

28
sin.h

@ -1,18 +1,18 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
class Sin {
public:

@ -14,7 +14,7 @@ class AudioSourceMicroDexed : public AudioStream, public Dexed {
void update(void)
{
if (in_update==true)
if (in_update == true)
{
xrun++;
return;

Loading…
Cancel
Save