|
|
@ -1,6 +1,6 @@ |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* ***** output_i2s_f32.h ***** |
|
|
|
* ***** output_i2s_f32.h ***** |
|
|
|
*
|
|
|
|
* |
|
|
|
* Audio Library for Teensy 3.X |
|
|
|
* Audio Library for Teensy 3.X |
|
|
|
* Copyright (c) 2014, Paul Stoffregen, paul@pjrc.com |
|
|
|
* 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 |
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
|
|
* THE SOFTWARE. |
|
|
|
* THE SOFTWARE. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Extended by Chip Audette, OpenAudio, May 2019 |
|
|
|
* Extended by Chip Audette, OpenAudio, May 2019 |
|
|
|
* Converted to F32 and to variable audio block length |
|
|
|
* Converted to F32 and to variable audio block length |
|
|
|
* The F32 conversion is under the MIT License. Use at your own risk. |
|
|
|
* 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
|
|
|
|
//GUI: inputs:2, outputs:0 //this line used for automatic generation of GUI node
|
|
|
|
public: |
|
|
|
public: |
|
|
|
//uses default AUDIO_SAMPLE_RATE and BLOCK_SIZE_SAMPLES from AudioStream.h:
|
|
|
|
//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:
|
|
|
|
// Allow variable sample rate and block size:
|
|
|
|
AudioOutputI2S_F32(const AudioSettings_F32 &settings) : AudioStream_F32(2, inputQueueArray) |
|
|
|
AudioOutputI2S_F32(const AudioSettings_F32 &settings) : AudioStream_F32(2, inputQueueArray) |
|
|
|
{
|
|
|
|
{ |
|
|
|
sample_rate_Hz = settings.sample_rate_Hz; |
|
|
|
sample_rate_Hz = settings.sample_rate_Hz; |
|
|
|
audio_block_samples = settings.audio_block_samples; |
|
|
|
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); |
|
|
|
virtual void update(void); |
|
|
|
void begin(void); |
|
|
|
void begin(void); |
|
|
|
void begin(bool); |
|
|
|
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_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_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 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
|
|
|
|
static float setI2SFreq_T3(const float); // I2S clock for T3,x
|
|
|
|
protected: |
|
|
|
protected: |
|
|
|
AudioOutputI2S_F32(int dummy): AudioStream_F32(2, inputQueueArray) {} // to be used only inside AudioOutputI2Sslave !!
|
|
|
|
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 float sample_rate_Hz; |
|
|
|
static int audio_block_samples; |
|
|
|
static int audio_block_samples; |
|
|
|
volatile uint8_t enabled = 1; |
|
|
|
volatile uint8_t enabled = 1; |
|
|
|
|
|
|
|
float outputScale = 1.0f; // Quick volume control
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class AudioOutputI2Sslave_F32 : public AudioOutputI2S_F32 |
|
|
|
class AudioOutputI2Sslave_F32 : public AudioOutputI2S_F32 |
|
|
|