From 1abb151ffd047b7e6fbd988ae601f50d1a63c412 Mon Sep 17 00:00:00 2001 From: boblark Date: Thu, 10 Mar 2022 09:51:42 -0800 Subject: [PATCH] Restored outputScale. My mistakegit add output_i2s_f32.h --- output_i2s_f32.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/output_i2s_f32.h b/output_i2s_f32.h index abcc606..bfea439 100644 --- a/output_i2s_f32.h +++ b/output_i2s_f32.h @@ -1,6 +1,6 @@ /* * ***** output_i2s_f32.h ***** - * + * * Audio Library for Teensy 3.X * Copyright (c) 2014, Paul Stoffregen, paul@pjrc.com * @@ -26,7 +26,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - /* + /* * Extended by Chip Audette, OpenAudio, May 2019 * Converted to F32 and to variable audio block length * The F32 conversion is under the MIT License. Use at your own risk. @@ -47,14 +47,20 @@ class AudioOutputI2S_F32 : public AudioStream_F32 //GUI: inputs:2, outputs:0 //this line used for automatic generation of GUI node public: //uses default AUDIO_SAMPLE_RATE and BLOCK_SIZE_SAMPLES from AudioStream.h: - AudioOutputI2S_F32(void) : AudioStream_F32(2, inputQueueArray) { begin();} + AudioOutputI2S_F32(void) : AudioStream_F32(2, inputQueueArray) { begin();} // Allow variable sample rate and block size: AudioOutputI2S_F32(const AudioSettings_F32 &settings) : AudioStream_F32(2, inputQueueArray) - { + { sample_rate_Hz = settings.sample_rate_Hz; audio_block_samples = settings.audio_block_samples; - begin(); + begin(); } + + // outputScale is a gain control for both left and right. If set exactly + // to 1.0f it is left as a pass-through. + void setGain(float _oscale) { + outputScale = _oscale; + } virtual void update(void); void begin(void); void begin(bool); @@ -75,7 +81,7 @@ public: static void scale_f32_to_i16( float32_t *p_f32, float32_t *p_i16, int len) ; static void scale_f32_to_i24( float32_t *p_f32, float32_t *p_i16, int len) ; static void scale_f32_to_i32( float32_t *p_f32, float32_t *p_i32, int len) ; - + static float setI2SFreq_T3(const float); // I2S clock for T3,x protected: AudioOutputI2S_F32(int dummy): AudioStream_F32(2, inputQueueArray) {} // to be used only inside AudioOutputI2Sslave !! @@ -101,6 +107,7 @@ private: static float sample_rate_Hz; static int audio_block_samples; volatile uint8_t enabled = 1; + float outputScale = 1.0f; // Quick volume control }; class AudioOutputI2Sslave_F32 : public AudioOutputI2S_F32