Browse Source

changed defines to be more specific

See conversation https://github.com/PaulStoffregen/Audio/pull/194
dds
Benjamin 8 years ago
parent
commit
246a7f6977
2 changed files with 23 additions and 23 deletions
  1. +19
    -19
      output_pt8211.cpp
  2. +4
    -4
      output_pt8211.h

+ 19
- 19
output_pt8211.cpp View File

uint16_t AudioOutputPT8211::block_left_offset = 0; uint16_t AudioOutputPT8211::block_left_offset = 0;
uint16_t AudioOutputPT8211::block_right_offset = 0; uint16_t AudioOutputPT8211::block_right_offset = 0;
bool AudioOutputPT8211::update_responsibility = false; bool AudioOutputPT8211::update_responsibility = false;
#if defined(OVERSAMPLING)
#if defined(AUDIO_PT8211_OVERSAMPLING)
DMAMEM static uint32_t i2s_tx_buffer[AUDIO_BLOCK_SAMPLES*4]; DMAMEM static uint32_t i2s_tx_buffer[AUDIO_BLOCK_SAMPLES*4];
#else #else
DMAMEM static uint32_t i2s_tx_buffer[AUDIO_BLOCK_SAMPLES]; DMAMEM static uint32_t i2s_tx_buffer[AUDIO_BLOCK_SAMPLES];
if (saddr < (uint32_t)i2s_tx_buffer + sizeof(i2s_tx_buffer) / 2) { if (saddr < (uint32_t)i2s_tx_buffer + sizeof(i2s_tx_buffer) / 2) {
// DMA is transmitting the first half of the buffer // DMA is transmitting the first half of the buffer
// so we must fill the second half // so we must fill the second half
#if defined(OVERSAMPLING)
#if defined(AUDIO_PT8211_OVERSAMPLING)
dest = (int16_t *)&i2s_tx_buffer[(AUDIO_BLOCK_SAMPLES/2)*4]; dest = (int16_t *)&i2s_tx_buffer[(AUDIO_BLOCK_SAMPLES/2)*4];
#else #else
dest = (int16_t *)&i2s_tx_buffer[AUDIO_BLOCK_SAMPLES/2]; dest = (int16_t *)&i2s_tx_buffer[AUDIO_BLOCK_SAMPLES/2];
offsetL = AudioOutputPT8211::block_left_offset; offsetL = AudioOutputPT8211::block_left_offset;
offsetR = AudioOutputPT8211::block_right_offset; offsetR = AudioOutputPT8211::block_right_offset;
#if defined(OVERSAMPLING)
#if defined(AUDIO_PT8211_OVERSAMPLING)
static int32_t oldL = 0; static int32_t oldL = 0;
static int32_t oldR = 0; static int32_t oldR = 0;
#endif #endif
if (blockL && blockR) { if (blockL && blockR) {
#if defined(OVERSAMPLING)
#if defined(INTERPOLATION_LINEAR)
#if defined(AUDIO_PT8211_OVERSAMPLING)
#if defined(AUDIO_PT8211_INTERPOLATION_LINEAR)
for (int i=0; i< AUDIO_BLOCK_SAMPLES / 2; i++, offsetL++, offsetR++) { for (int i=0; i< AUDIO_BLOCK_SAMPLES / 2; i++, offsetL++, offsetR++) {
int32_t valL = blockL->data[offsetL]; int32_t valL = blockL->data[offsetL];
int32_t valR = blockR->data[offsetR]; int32_t valR = blockR->data[offsetR];
oldL = valL; oldL = valL;
oldR = valR; oldR = valR;
} }
#elif defined(INTERPOLATION_CIC)
#elif defined(AUDIO_PT8211_INTERPOLATION_CIC)
for (int i=0; i< AUDIO_BLOCK_SAMPLES / 2; i++, offsetL++, offsetR++) { for (int i=0; i< AUDIO_BLOCK_SAMPLES / 2; i++, offsetL++, offsetR++) {
int32_t valL = blockL->data[offsetL]; int32_t valL = blockL->data[offsetL];
int32_t valR = blockR->data[offsetR]; int32_t valR = blockR->data[offsetR];
} }
#else #else
#error no interpolation method defined for oversampling. #error no interpolation method defined for oversampling.
#endif //defined(INTERPOLATION_LINEAR)
#endif //defined(AUDIO_PT8211_INTERPOLATION_LINEAR)
#else #else
memcpy_tointerleaveLR(dest, blockL->data + offsetL, blockR->data + offsetR); memcpy_tointerleaveLR(dest, blockL->data + offsetL, blockR->data + offsetR);
offsetL += AUDIO_BLOCK_SAMPLES / 2; offsetL += AUDIO_BLOCK_SAMPLES / 2;
offsetR += AUDIO_BLOCK_SAMPLES / 2; offsetR += AUDIO_BLOCK_SAMPLES / 2;
#endif //defined(OVERSAMPLING)
#endif //defined(AUDIO_PT8211_OVERSAMPLING)
} else if (blockL) { } else if (blockL) {
#if defined(OVERSAMPLING)
#if defined(INTERPOLATION_LINEAR)
#if defined(AUDIO_PT8211_OVERSAMPLING)
#if defined(AUDIO_PT8211_INTERPOLATION_LINEAR)
for (int i=0; i< AUDIO_BLOCK_SAMPLES / 2; i++, offsetL++) { for (int i=0; i< AUDIO_BLOCK_SAMPLES / 2; i++, offsetL++) {
int32_t val = blockL->data[offsetL]; int32_t val = blockL->data[offsetL];
int32_t n = (oldL+val) >> 1; int32_t n = (oldL+val) >> 1;
dest+=8; dest+=8;
oldL = val; oldL = val;
} }
#elif defined(INTERPOLATION_CIC)
#elif defined(AUDIO_PT8211_INTERPOLATION_CIC)
for (int i=0; i< AUDIO_BLOCK_SAMPLES / 2; i++, offsetL++, offsetR++) { for (int i=0; i< AUDIO_BLOCK_SAMPLES / 2; i++, offsetL++, offsetR++) {
int32_t valL = blockL->data[offsetL]; int32_t valL = blockL->data[offsetL];


} }
#else #else
#error no interpolation method defined for oversampling. #error no interpolation method defined for oversampling.
#endif //defined(INTERPOLATION_LINEAR)
#endif //defined(AUDIO_PT8211_INTERPOLATION_LINEAR)
#else #else
memcpy_tointerleaveL(dest, blockL->data + offsetL); memcpy_tointerleaveL(dest, blockL->data + offsetL);
offsetL += (AUDIO_BLOCK_SAMPLES / 2); offsetL += (AUDIO_BLOCK_SAMPLES / 2);
#endif //defined(OVERSAMPLING)
#endif //defined(AUDIO_PT8211_OVERSAMPLING)
} else if (blockR) { } else if (blockR) {
#if defined(OVERSAMPLING)
#if defined(INTERPOLATION_LINEAR)
#if defined(AUDIO_PT8211_OVERSAMPLING)
#if defined(AUDIO_PT8211_INTERPOLATION_LINEAR)
for (int i=0; i< AUDIO_BLOCK_SAMPLES / 2; i++, offsetR++) { for (int i=0; i< AUDIO_BLOCK_SAMPLES / 2; i++, offsetR++) {
int32_t val = blockR->data[offsetR]; int32_t val = blockR->data[offsetR];
int32_t n = (oldR+val) >> 1; int32_t n = (oldR+val) >> 1;
dest+=8; dest+=8;
oldR = val; oldR = val;
} }
#elif defined(INTERPOLATION_CIC)
#elif defined(AUDIO_PT8211_INTERPOLATION_CIC)
for (int i=0; i< AUDIO_BLOCK_SAMPLES / 2; i++, offsetL++, offsetR++) { for (int i=0; i< AUDIO_BLOCK_SAMPLES / 2; i++, offsetL++, offsetR++) {
int32_t valR = blockR->data[offsetR]; int32_t valR = blockR->data[offsetR];


} }
#else #else
#error no interpolation method defined for oversampling. #error no interpolation method defined for oversampling.
#endif //defined(INTERPOLATION_LINEAR)
#endif //defined(AUDIO_PT8211_INTERPOLATION_LINEAR)
#else #else
memcpy_tointerleaveR(dest, blockR->data + offsetR); memcpy_tointerleaveR(dest, blockR->data + offsetR);
offsetR += AUDIO_BLOCK_SAMPLES / 2; offsetR += AUDIO_BLOCK_SAMPLES / 2;
#endif //defined(OVERSAMPLING)
#endif //defined(AUDIO_PT8211_OVERSAMPLING)
} else { } else {
memset(dest,0,AUDIO_BLOCK_SAMPLES * 2); memset(dest,0,AUDIO_BLOCK_SAMPLES * 2);
return; return;
// configure transmitter // configure transmitter
I2S0_TMR = 0; I2S0_TMR = 0;
I2S0_TCR1 = I2S_TCR1_TFW(1); // watermark at half fifo size I2S0_TCR1 = I2S_TCR1_TFW(1); // watermark at half fifo size
#if defined(OVERSAMPLING)
#if defined(AUDIO_PT8211_OVERSAMPLING)
I2S0_TCR2 = I2S_TCR2_SYNC(0) | I2S_TCR2_BCP | I2S_TCR2_MSEL(1) | I2S_TCR2_BCD | I2S_TCR2_DIV(0); I2S0_TCR2 = I2S_TCR2_SYNC(0) | I2S_TCR2_BCP | I2S_TCR2_MSEL(1) | I2S_TCR2_BCD | I2S_TCR2_DIV(0);
#else #else
I2S0_TCR2 = I2S_TCR2_SYNC(0) | I2S_TCR2_BCP | I2S_TCR2_MSEL(1) | I2S_TCR2_BCD | I2S_TCR2_DIV(3); I2S0_TCR2 = I2S_TCR2_SYNC(0) | I2S_TCR2_BCP | I2S_TCR2_MSEL(1) | I2S_TCR2_BCD | I2S_TCR2_DIV(3);

+ 4
- 4
output_pt8211.h View File

#define output_pt8211_h_ #define output_pt8211_h_


//uncomment to enable oversampling: //uncomment to enable oversampling:
#define OVERSAMPLING
#define AUDIO_PT8211_OVERSAMPLING
//uncomment ONE of these to define interpolation type for oversampling: //uncomment ONE of these to define interpolation type for oversampling:
// #define INTERPOLATION_LINEAR
#define INTERPOLATION_CIC
// #define AUDIO_PT8211_INTERPOLATION_LINEAR
#define AUDIO_PT8211_INTERPOLATION_CIC


#include "Arduino.h" #include "Arduino.h"
#include "AudioStream.h" #include "AudioStream.h"
static bool update_responsibility; static bool update_responsibility;
static DMAChannel dma; static DMAChannel dma;
static void isr(void) static void isr(void)
#if defined(OVERSAMPLING)
#if defined(AUDIO_PT8211_OVERSAMPLING)
__attribute__((optimize("unroll-loops"))) __attribute__((optimize("unroll-loops")))
#endif #endif
; ;

Loading…
Cancel
Save