forked from PAWPAW-Mirror/lib_xua
Add ability to upsample I2S out (I2S_SAMPLE_FACTOR_OUT). Also fixed new
lib_src coeff naming.
This commit is contained in:
@@ -80,6 +80,16 @@ static int64_t outputDs3Sum[I2S_DOWNSAMPLE_CHANS_OUT];
|
||||
#endif // (I2S_DOWNSAMPLE_FACTOR_OUT > 1)
|
||||
#endif // (I2S_DOWNSAMPLE_FACTOR_IN > 1) || (I2S_DOWNSAMPLE_FACTOR_OUT > 1)
|
||||
|
||||
#ifndef I2S_UPSAMPLE_FACTOR_OUT
|
||||
#define I2S_UPSAMPLE_FACTOR_OUT 1
|
||||
#endif
|
||||
|
||||
static int outUpsamplingCounter = 0;
|
||||
#if (I2S_UPSAMPLE_FACTOR_OUT > 1)
|
||||
#include "src.h"
|
||||
static int32_t us3OutputDelayLine[I2S_CHANS_DAC][24];
|
||||
#endif /* (I2S_UPSAMPLE_FACTOR_OUT > 1) */
|
||||
|
||||
#if (DSD_CHANS_DAC != 0)
|
||||
extern buffered out port:32 p_dsd_dac[DSD_CHANS_DAC];
|
||||
extern buffered out port:32 p_dsd_clk;
|
||||
@@ -526,6 +536,10 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
|
||||
memset(&ds3Data.inputDelayLine, 0, sizeof ds3Data);
|
||||
#endif
|
||||
|
||||
#if (I2S_UPSAMPLE_FACTOR_OUT > 1)
|
||||
memset(us3OutputDelayLine, 0, sizeof us3OutputDelayLine);
|
||||
#endif
|
||||
|
||||
unsigned command = DoSampleTransfer(c_out, readBuffNo, underflowWord, i_audMan);
|
||||
|
||||
#ifdef ADAT_TX
|
||||
@@ -565,6 +579,7 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
|
||||
while (!syncError)
|
||||
#endif // CODEC_MASTER
|
||||
{
|
||||
|
||||
#if (DSD_CHANS_DAC != 0) && (NUM_USB_CHAN_OUT > 0)
|
||||
if(dsdMode == DSD_MODE_NATIVE)
|
||||
{
|
||||
@@ -711,7 +726,7 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
|
||||
src_ds3_voice_add_final_sample(
|
||||
inputDs3Sum[((frameCount-2)&(I2S_CHANS_PER_FRAME-1))+i],
|
||||
ds3Data.inputDelayLine[((frameCount-2)&(I2S_CHANS_PER_FRAME-1))+i][inDownsamplingCounter],
|
||||
src_ff3v_ds3_voice_coefs[inDownsamplingCounter],
|
||||
src_ff3v_fir_coefs[inDownsamplingCounter],
|
||||
samplesIn[readBuffNo][((frameCount-2)&(I2S_CHANS_PER_FRAME-1))]);
|
||||
}
|
||||
else
|
||||
@@ -720,7 +735,7 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
|
||||
src_ds3_voice_add_sample(
|
||||
inputDs3Sum[((frameCount-2)&(I2S_CHANS_PER_FRAME-1))+i],
|
||||
ds3Data.inputDelayLine[((frameCount-2)&(I2S_CHANS_PER_FRAME-1))+i][inDownsamplingCounter],
|
||||
src_ff3v_ds3_voice_coefs[inDownsamplingCounter],
|
||||
src_ff3v_fir_coefs[inDownsamplingCounter],
|
||||
samplesIn[readBuffNo][((frameCount-2)&(I2S_CHANS_PER_FRAME-1))]);
|
||||
}
|
||||
#endif // (I2S_DOWNSAMPLE_FACTOR_IN > 1)
|
||||
@@ -751,6 +766,17 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
|
||||
/* Output "even" channel to DAC (i.e. left) */
|
||||
for(int i = 0; i < I2S_CHANS_DAC; i+=I2S_CHANS_PER_FRAME)
|
||||
{
|
||||
#if (I2S_UPSAMPLE_FACTOR_OUT > 1)
|
||||
if(outUpsamplingCounter == 0) {
|
||||
samplesOut[frameCount+i] = src_us3_voice_input_sample(us3OutputDelayLine[i],
|
||||
src_ff3v_fir_coefs[2],
|
||||
samplesOut[frameCount+i]);
|
||||
} else { /* outUpsamplingCounter is 1 or 2 */
|
||||
samplesOut[frameCount+i] = src_us3_voice_get_next_sample(us3OutputDelayLine[i],
|
||||
src_ff3v_fir_coefs[2-outUpsamplingCounter]);
|
||||
}
|
||||
#endif /* (I2S_UPSAMPLE_FACTOR_OUT > 1) */
|
||||
|
||||
p_i2s_dac[index++] <: bitrev(samplesOut[frameCount +i]);
|
||||
}
|
||||
#endif
|
||||
@@ -849,7 +875,7 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
|
||||
src_ds3_voice_add_final_sample(
|
||||
inputDs3Sum[((frameCount-1)&(I2S_CHANS_PER_FRAME-1))+i],
|
||||
ds3Data.inputDelayLine[((frameCount-1)&(I2S_CHANS_PER_FRAME-1))+i][inDownsamplingCounter],
|
||||
src_ff3v_ds3_voice_coefs[inDownsamplingCounter],
|
||||
src_ff3v_fir_coefs[inDownsamplingCounter],
|
||||
samplesIn[readBuffNo][((frameCount-1)&(I2S_CHANS_PER_FRAME-1))+i]);
|
||||
}
|
||||
else
|
||||
@@ -858,7 +884,7 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
|
||||
src_ds3_voice_add_sample(
|
||||
inputDs3Sum[((frameCount-1)&(I2S_CHANS_PER_FRAME-1))+i],
|
||||
ds3Data.inputDelayLine[((frameCount-1)&(I2S_CHANS_PER_FRAME-1))+i][inDownsamplingCounter],
|
||||
src_ff3v_ds3_voice_coefs[inDownsamplingCounter],
|
||||
src_ff3v_fir_coefs[inDownsamplingCounter],
|
||||
samplesIn[readBuffNo][((frameCount-1)&(I2S_CHANS_PER_FRAME-1))+i]);
|
||||
}
|
||||
#endif // ((I2S_DOWNSAMPLE_FACTOR_IN > 1) && !I2S_DOWNSAMPLE_MONO_IN)
|
||||
@@ -886,6 +912,18 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
|
||||
#pragma loop unroll
|
||||
for(int i = 1; i < I2S_CHANS_DAC; i+=I2S_CHANS_PER_FRAME)
|
||||
{
|
||||
#if (I2S_UPSAMPLE_FACTOR_OUT > 1)
|
||||
if(outUpsamplingCounter == 0) {
|
||||
samplesOut[frameCount+i] = src_us3_voice_input_sample(us3OutputDelayLine[i],
|
||||
src_ff3v_fir_coefs[2],
|
||||
samplesOut[frameCount+i]);
|
||||
} else { /* outUpsamplingCounter is 1 or 2 */
|
||||
samplesOut[frameCount+i] = src_us3_voice_get_next_sample(us3OutputDelayLine[i],
|
||||
src_ff3v_fir_coefs[2-outUpsamplingCounter]);
|
||||
|
||||
}
|
||||
#endif /* (I2S_UPSAMPLE_FACTOR_OUT > 1) */
|
||||
|
||||
p_i2s_dac[index++] <: bitrev(samplesOut[frameCount + i]);
|
||||
}
|
||||
#endif
|
||||
@@ -976,6 +1014,15 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
|
||||
{
|
||||
++inDownsamplingCounter;
|
||||
}
|
||||
|
||||
if((I2S_UPSAMPLE_FACTOR_OUT - 1) == outUpsamplingCounter)
|
||||
{
|
||||
outUpsamplingCounter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
++outUpsamplingCounter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user