Skip to content

Commit

Permalink
drum filter fix, effects gain compensation
Browse files Browse the repository at this point in the history
  • Loading branch information
copych authored Feb 10, 2023
1 parent 742e876 commit b649552
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 154 deletions.
8 changes: 5 additions & 3 deletions AcidBanger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ sSynthCCs synth2_ramps[NUM_SYNTH_CCS] = {
};

sSynthCCs drum_ramps[NUM_DRUM_CCS] = {
//cc cpl def min max reset
//cc cpl def min max reset
{CC_808_CUTOFF, 0, 64, 64, 127, true},
{CC_808_RESO, 0, 0, 0, 127, true},
{CC_808_RESO, 0, 64, 0, 127, true},
{CC_808_SD_TONE, 0, 64, 64, 127, true},
#ifndef NO_PSRAM
{CC_808_REVERB_SEND, 0, 5, 30, 127, true}, // reverb is not available with no psram
{CC_808_DELAY_SEND, 0, 0, 64, 127, true}, // delay for drums needs more delay time (read 'RAM') than we can afford
#endif
{CC_808_BD_DECAY, 0, 127, 50, 127, true},
{CC_808_BD_DECAY, 0, 127, 50, 127, true},
{CC_808_BD_TONE, 0, 64, 40, 64, true}
};

Expand Down Expand Up @@ -1224,8 +1224,10 @@ void run_tick() {
run_ui();
button_divider = 0;

#ifdef DEBUG_TIMING
// DEBF ("synt1=%dus synt2=%dus drums=%dus mixer=%dus DMA_BUF=%dus\r\n" , s1T, s2T, drT, fxT, DMA_BUF_TIME);
DEBF ("Core0=%dus Core1=%dus DMA_BUF=%dus\r\n" , s2T + drT + fxT, s1T, DMA_BUF_TIME);
#endif
}

/* If MIDI is playing, then check for tick */
Expand Down
4 changes: 2 additions & 2 deletions AcidBox.ino
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ static void audio_task2(void *userData) {


/*
* Some service routines *****************************************************************************************************************************
* Some debug service routines *****************************************************************************************************************************
*/

void readPots() {
static const float snap = 0.005;
static const float snap = 0.008f;
static float tmp;
static const float NORMALIZE_ADC = 1.0f / 4096.0f;
for (uint8_t i = 0; i < POT_NUM; i++) {
Expand Down
1 change: 1 addition & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//#define DEBUG_SAMPLER
//#define DEBUG_JUKEBOX
//#define DEBUG_FX
//#define DEBUG_TIMING

//#define USE_INTERNAL_DAC // use this for testing, SOUND QUALITY SACRIFICED: NOISY 8BIT STEREO
//#define NO_PSRAM // if you don't have PSRAM on your board, then use this define, but REVERB TO BE SACRIFICED, SMALL DRUM KIT SAMPLES USED
Expand Down
14 changes: 8 additions & 6 deletions fx_filtercrusher.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ void FxFilterCrusher::Process( float* left, float* right ) {
Filter_Process(right, &mainFilterR_LP);
Filter_Process(left, &mainFilterL_HP);
Filter_Process(right, &mainFilterR_HP);
/*
cutoff_lp_slow = (float)cutoff_lp_slow * 0.99f + 0.01f * ((float)lowpassC - (float)cutoff_lp_slow);
cutoff_hp_slow = (float)cutoff_hp_slow * 0.99f + 0.01f * ((float)highpassC - (float)cutoff_hp_slow);
*/

cutoff_lp_slow = (float)cutoff_lp_slow * 0.9f + 0.1f * ((float)lowpassC - (float)cutoff_lp_slow);
cutoff_hp_slow = (float)cutoff_hp_slow * 0.9f + 0.1f * ((float)highpassC - (float)cutoff_hp_slow);


cutoff_lp_slow = lowpassC ;
cutoff_hp_slow = highpassC ;
/* we can not calculate in each cycle */
if ( effect_prescaler % 8 == 0 ) {
Filter_CalculateTP(cutoff_lp_slow, filtReso, &filterGlobalC_LP);
Expand Down Expand Up @@ -53,7 +55,7 @@ inline void FxFilterCrusher::Filter_CalculateTP(float c, float reso, struct filt
cosOmega = sine[WAVEFORM_I((uint32_t)((float)((1ULL << 31) - 1) * omega + (float)((1ULL << 30) - 1)))];
sinOmega = sine[WAVEFORM_I((uint32_t)((float)((1ULL << 31) - 1) * omega))];

alpha = sinOmega * one_div(2.0 * Q);
alpha = sinOmega * one_div(2.0f * Q);
b[0] = (1 - cosOmega) * 0.5f;
b[1] = 1 - cosOmega;
b[2] = b[0];
Expand Down Expand Up @@ -100,7 +102,7 @@ inline void FxFilterCrusher::Filter_CalculateHP(float c, float reso, struct filt
cosOmega = sine[WAVEFORM_I((uint32_t)((float)((1ULL << 31) - 1) * omega + (float)((1ULL << 30) - 1)))];
sinOmega = sine[WAVEFORM_I((uint32_t)((float)((1ULL << 31) - 1) * omega))];

alpha = sinOmega * one_div(2.0 * Q);
alpha = sinOmega * one_div(2.0f * Q);
b[0] = (1 + cosOmega) * 0.5f;
b[1] = -(1 + cosOmega);
b[2] = b[0];
Expand Down
194 changes: 97 additions & 97 deletions midi_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,116 +6,116 @@

#ifdef GM_MIDI
// 303 Synths MIDI CC
#define CC_303_PORTATIME 5
#define CC_303_VOLUME 7
#define CC_303_PORTAMENTO 65
#define CC_303_PAN 10
#define CC_303_WAVEFORM 70
#define CC_303_RESO 71
#define CC_303_CUTOFF 74
#define CC_303_ATTACK 73
#define CC_303_DECAY 72
#define CC_303_ENVMOD_LVL 75
#define CC_303_ACCENT_LVL 76
#define CC_303_REVERB_SEND 91
#define CC_303_DELAY_SEND 92
#define CC_303_DISTORTION 94
#define CC_303_OVERDRIVE 95
#define CC_303_SATURATOR 128
#define CC_303_PORTATIME 5
#define CC_303_VOLUME 7
#define CC_303_PORTAMENTO 65
#define CC_303_PAN 10
#define CC_303_WAVEFORM 70
#define CC_303_RESO 71
#define CC_303_CUTOFF 74
#define CC_303_ATTACK 73
#define CC_303_DECAY 72
#define CC_303_ENVMOD_LVL 75
#define CC_303_ACCENT_LVL 76
#define CC_303_REVERB_SEND 91
#define CC_303_DELAY_SEND 92
#define CC_303_DISTORTION 94
#define CC_303_OVERDRIVE 95
#define CC_303_SATURATOR 128

// 808 Drums MIDI CC
#define CC_808_VOLUME 7
#define CC_808_NOTE_PAN 8
#define CC_808_PAN 10
#define CC_808_RESO 71
#define CC_808_CUTOFF 74
#define CC_808_REVERB_SEND 91
#define CC_808_DELAY_SEND 92
#define CC_808_DISTORTION 94
#define CC_808_PITCH 89
#define CC_808_NOTE_SEL 90 // select note, all the following CC note modifiers will be applied to this sample as it was RPN or NRPN
#define CC_808_NOTE_ATTACK 73
#define CC_808_NOTE_DECAY 72
#define CC_808_BD_TONE 21 // Specific per drum control
#define CC_808_BD_DECAY 23
#define CC_808_BD_LEVEL 24
#define CC_808_SD_TONE 25
#define CC_808_SD_SNAP 26
#define CC_808_SD_LEVEL 29
#define CC_808_CH_TUNE 61
#define CC_808_CH_LEVEL 63
#define CC_808_OH_TUNE 80
#define CC_808_OH_DECAY 81
#define CC_808_OH_LEVEL 82
#define CC_808_VOLUME 7
#define CC_808_NOTE_PAN 8
#define CC_808_PAN 10
#define CC_808_RESO 71
#define CC_808_CUTOFF 74
#define CC_808_REVERB_SEND 91
#define CC_808_DELAY_SEND 92
#define CC_808_DISTORTION 94
#define CC_808_PITCH 89
#define CC_808_NOTE_SEL 90 // select note, all the following CC note modifiers will be applied to this sample as it was RPN or NRPN
#define CC_808_NOTE_ATTACK 73
#define CC_808_NOTE_DECAY 72
#define CC_808_BD_TONE 21 // Specific per drum control
#define CC_808_BD_DECAY 23
#define CC_808_BD_LEVEL 24
#define CC_808_SD_TONE 25
#define CC_808_SD_SNAP 26
#define CC_808_SD_LEVEL 29
#define CC_808_CH_TUNE 61
#define CC_808_CH_LEVEL 63
#define CC_808_OH_TUNE 80
#define CC_808_OH_DECAY 81
#define CC_808_OH_LEVEL 82

// Global
#define CC_ANY_COMPRESSOR 93
#define CC_ANY_DELAY_TIME 84
#define CC_ANY_DELAY_FB 85
#define CC_ANY_DELAY_LVL 86
#define CC_ANY_REVERB_TIME 87
#define CC_ANY_REVERB_LVL 88
#define CC_ANY_RESET_CCS 121
#define CC_ANY_NOTES_OFF 123
#define CC_ANY_SOUND_OFF 120
#define CC_ANY_COMPRESSOR 93
#define CC_ANY_DELAY_TIME 84
#define CC_ANY_DELAY_FB 85
#define CC_ANY_DELAY_LVL 86
#define CC_ANY_REVERB_TIME 87
#define CC_ANY_REVERB_LVL 88
#define CC_ANY_RESET_CCS 121
#define CC_ANY_NOTES_OFF 123
#define CC_ANY_SOUND_OFF 120
#endif




#ifdef VINTAGE_MIDI
// 303 Synths MIDI CC
#define CC_303_PORTATIME 5
#define CC_303_VOLUME 11
#define CC_303_PORTAMENTO 65
#define CC_303_PAN 10
#define CC_303_WAVEFORM 70
#define CC_303_RESO 71
#define CC_303_CUTOFF 74
#define CC_303_ATTACK 73
#define CC_303_DECAY 75
#define CC_303_ENVMOD_LVL 12
#define CC_303_ACCENT_LVL 76
#define CC_303_REVERB_SEND 91
#define CC_303_DELAY_SEND 19
#define CC_303_DISTORTION 17
#define CC_303_SATURATOR 95
#define CC_303_PORTATIME 5
#define CC_303_VOLUME 11
#define CC_303_PORTAMENTO 65
#define CC_303_PAN 10
#define CC_303_WAVEFORM 70
#define CC_303_RESO 71
#define CC_303_CUTOFF 74
#define CC_303_ATTACK 73
#define CC_303_DECAY 75
#define CC_303_ENVMOD_LVL 12
#define CC_303_ACCENT_LVL 76
#define CC_303_REVERB_SEND 91
#define CC_303_DELAY_SEND 19
#define CC_303_DISTORTION 17
#define CC_303_SATURATOR 95

// 808 Drums MIDI CC
#define CC_808_VOLUME 7
#define CC_808_NOTE_PAN 8
#define CC_808_PAN 10
#define CC_808_RESO 71
#define CC_808_CUTOFF 74
#define CC_808_REVERB_SEND 91
#define CC_808_DELAY_SEND 92
#define CC_808_DISTORTION 94
#define CC_808_PITCH 89
#define CC_808_NOTE_SEL 90 // select note, all the following CC note modifiers will be applied to this sample as it was RPN or NRPN
#define CC_808_NOTE_ATTACK 73 // universal for all drums
#define CC_808_NOTE_DECAY 72
#define CC_808_BD_TONE 21 // Specific per drum control
#define CC_808_BD_DECAY 23
#define CC_808_BD_LEVEL 24
#define CC_808_SD_TONE 25
#define CC_808_SD_SNAP 26
#define CC_808_SD_LEVEL 29
#define CC_808_CH_TUNE 61
#define CC_808_CH_LEVEL 63
#define CC_808_OH_TUNE 80
#define CC_808_OH_DECAY 81
#define CC_808_OH_LEVEL 82


#define CC_ANY_COMPRESSOR 93
#define CC_ANY_DELAY_TIME 84
#define CC_ANY_DELAY_FB 85
#define CC_ANY_DELAY_LVL 86
#define CC_ANY_REVERB_TIME 87
#define CC_ANY_REVERB_LVL 88
#define CC_ANY_RESET_CCS 121
#define CC_ANY_NOTES_OFF 123
#define CC_ANY_SOUND_OFF 120
#define CC_808_VOLUME 7
#define CC_808_NOTE_PAN 8
#define CC_808_PAN 10
#define CC_808_RESO 71
#define CC_808_CUTOFF 74
#define CC_808_REVERB_SEND 91
#define CC_808_DELAY_SEND 92
#define CC_808_DISTORTION 94
#define CC_808_PITCH 89
#define CC_808_NOTE_SEL 90 // select note, all the following CC note modifiers will be applied to this sample as it was RPN or NRPN
#define CC_808_NOTE_ATTACK 73 // universal for all drums
#define CC_808_NOTE_DECAY 72
#define CC_808_BD_TONE 21 // Specific per drum control
#define CC_808_BD_DECAY 23
#define CC_808_BD_LEVEL 24
#define CC_808_SD_TONE 25
#define CC_808_SD_SNAP 26
#define CC_808_SD_LEVEL 29
#define CC_808_CH_TUNE 61
#define CC_808_CH_LEVEL 63
#define CC_808_OH_TUNE 80
#define CC_808_OH_DECAY 81
#define CC_808_OH_LEVEL 82


#define CC_ANY_COMPRESSOR 93
#define CC_ANY_DELAY_TIME 84
#define CC_ANY_DELAY_FB 85
#define CC_ANY_DELAY_LVL 86
#define CC_ANY_REVERB_TIME 87
#define CC_ANY_REVERB_LVL 88
#define CC_ANY_RESET_CCS 121
#define CC_ANY_NOTES_OFF 123
#define CC_ANY_SOUND_OFF 120



Expand Down
81 changes: 41 additions & 40 deletions overdrive.h
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
#pragma once
#ifndef DSY_OVERDRIVE_H
#define DSY_OVERDRIVE_H


/** @file overdrive.h */

/**
@brief Distortion / Overdrive Module
@author Ported by Ben Sergentanis
@date Jan 2021
Ported from pichenettes/eurorack/plaits/dsp/fx/overdrive.h \n
to an independent module. \n
Original code written by Emilie Gillet in 2014. \n
*/
class Overdrive
{
public:
Overdrive() {}
~Overdrive() {}

/** Initializes the module with 0 gain */
void Init();

/** Get the next sample
\param in Input to be overdriven
*/
float Process(float in);

/** Set the amount of drive
\param drive Works from 0-1
*/
void SetDrive(float drive);

private:
float drive_;
float pre_gain_;
float post_gain_;
};
#endif
#pragma once
#ifndef DSY_OVERDRIVE_H
#define DSY_OVERDRIVE_H


/** @file overdrive.h */

/**
@brief Distortion / Overdrive Module
@author Ported by Ben Sergentanis
@date Jan 2021
Ported from pichenettes/eurorack/plaits/dsp/fx/overdrive.h \n
to an independent module. \n
Original code written by Emilie Gillet in 2014. \n
*/
class Overdrive
{
public:
Overdrive() {}
~Overdrive() {}

/** Initializes the module with 0 gain */
void Init();

/** Get the next sample
\param in Input to be overdriven
*/
float Process(float in);

/** Set the amount of drive
\param drive Works from 0-1
*/
void SetDrive(float drive);

private:
float drive_;
float pre_gain_;
float post_gain_;
float compens_;
};
#endif
Loading

0 comments on commit b649552

Please sign in to comment.