From 5ad4c2471fb14e89e0116791b6e8b1f993f8fcb8 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Wed, 20 Feb 2019 16:04:09 +0100 Subject: [PATCH] Fixed volume handlying for Teensy-Audio-Adapter. Enabled Teensy-Audio-Adapter (SGTL5000) buildin compressor/limiter. --- MicroDexed.ino | 16 ++++++++++++---- config.h | 4 +++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index e78ca36..297d427 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -170,13 +170,17 @@ void setup() #ifdef TEENSY_AUDIO_BOARD sgtl5000_1.enable(); - sgtl5000_1.dacVolumeRamp(); - //sgtl5000_1.dacVolumeRampLinear(); + //sgtl5000_1.dacVolumeRamp(); + sgtl5000_1.dacVolumeRampLinear(); + //sgtl5000_1.dacVolumeRampDisable(); sgtl5000_1.unmuteHeadphone(); sgtl5000_1.unmuteLineout(); sgtl5000_1.autoVolumeDisable(); // turn off AGC sgtl5000_1.volume(1.0, 1.0); sgtl5000_1.lineOutLevel(31); + sgtl5000_1.audioPostProcessorEnable(); + sgtl5000_1.autoVolumeControl(1, 1, 1, 0.9, 0.01, 0.05); + sgtl5000_1.autoVolumeEnable(); Serial.println(F("Teensy-Audio-Board enabled.")); #elif defined(TGA_AUDIO_BOARD) wm8731_1.enable(); @@ -684,11 +688,15 @@ void set_volume(float v, float p) Serial.print(tmp, DEC); Serial.print(F("/")); Serial.print(float(tmp) / SCHAR_MAX, DEC); - Serial.println(F("]")); + Serial.print(F("] ")); + Serial.print(sinf(p * PI / 2), 3); + Serial.print(F("/")); + Serial.println(cosf(p * PI / 2), 3); #endif + // http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html #ifdef TEENSY_AUDIO_BOARD - sgtl5000_1.dacVolume(v * sinf(p * PI / 2), v * cosf(p * PI / 2)); + sgtl5000_1.dacVolume(pow(v * sinf(p * PI / 2), 0.1), pow(v * cosf(p * PI / 2), 0.1)); #else volume_master.gain(v); volume_r.gain(sinf(p * PI / 2)); diff --git a/config.h b/config.h index 4d40b17..f654aa7 100644 --- a/config.h +++ b/config.h @@ -76,6 +76,7 @@ #define AUDIO_MEM 225 #endif #define DELAY_MAX_TIME 600.0 +#define REDUCE_LOUDNESS 1 #else #if AUDIO_BLOCK_SAMPLES == 64 #define AUDIO_MEM 900 @@ -83,9 +84,10 @@ #define AUDIO_MEM 450 #endif #define DELAY_MAX_TIME 1200.0 +#define REDUCE_LOUDNESS 0 #endif #define SAMPLE_RATE 44100 -#define REDUCE_LOUDNESS 1 + //************************************************************************************************* //* DEBUG OUTPUT SETTINGS