Skip to content

Commit

Permalink
fix for the internal DAC
Browse files Browse the repository at this point in the history
highest available cutoff frequency pre-calculating depending on sample rate
  • Loading branch information
copych authored Feb 1, 2023
1 parent 4018859 commit 508e2b7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//#define DEBUG_JUKEBOX
//#define DEBUG_FX

//#define USE_INTERNAL_DAC // use this for testing, SOUND QUALITY SACRIFICED: 8BIT STEREO
#define USE_INTERNAL_DAC // use this for testing, SOUND QUALITY SACRIFICED: 8BIT STEREO
//#define NO_PSRAM // if you don't have PSRAM on your board, then use this define, but REVERB AND DELAY'D BE SACRIFICED, SMALL DRUM KIT SAMPLES USED

#define MIDI_ON // use this option if you want to operate by MIDI
Expand All @@ -19,7 +19,7 @@
#define MIN_CUTOFF_FREQ 250.0f

#ifdef USE_INTERNAL_DAC
#define SAMPLE_RATE 22050 // price for increasing this value is less delay time
#define SAMPLE_RATE 44100 // price for increasing this value is less delay time
#else
#define SAMPLE_RATE 44100
#endif
Expand Down
1 change: 1 addition & 0 deletions rosic_TeeBeeFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class TeeBeeFilter
float resonanceSkewed; // mapped resonance parameter to make it behave more musical
float sampleRate; // the sample rate in Hz
float twoPiOverSampleRate; // 2*PI/sampleRate
float highLimit; // highest cutoff freq allowing stable behaviour
float compens; // drive gain correction
float bias; // reso bias compensation
int mode; // the selected filter-mode
Expand Down
5 changes: 3 additions & 2 deletions rosic_TeeBeeFilter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void TeeBeeFilter::SetSampleRate(float newSampleRate)
if( newSampleRate > 0.0 )
sampleRate = newSampleRate;
twoPiOverSampleRate = 2.0*PI/sampleRate;
highLimit = sampleRate / 4.18f;
feedbackHighpass.setSampleRate(newSampleRate);
calculateCoefficientsExact();
}
Expand Down Expand Up @@ -84,8 +85,8 @@ inline void TeeBeeFilter::SetCutoff(float newCutoff, bool updateCoefficients)
{
if ( newCutoff < 200.0f ) // an absolute floor for the cutoff frequency - tweakable
cutoff = 200.0f;
else if ( newCutoff > 10550.0f )
cutoff = 10550.0f;
else if ( newCutoff > highLimit ) // seems to be stable with the current settings, higher values may lead to nan, +inf or -inf during processing
cutoff = highLimit;
else
cutoff = newCutoff;

Expand Down

0 comments on commit 508e2b7

Please sign in to comment.