In the i2s.init case there is the following code:
Code: Select all
case i2s.init(i2s_config_t &?i2s_config, tdm_config_t &?tdm_config):
// Receive the first free buffer and initial sample rate
unsafe
{
c_audio :> double_buffer;
p_in_frame = &double_buffer->buffer[double_buffer->active_buffer];
c_audio :> cur_sample_rate;
}
i2s_config.mode = I2S_MODE_I2S;
// I2S has 32 bits per sample. *2 as 2 channels
const unsigned num_bits = 64;
case i2s.init(i2s_config_t &?i2s_config, tdm_config_t &?tdm_config):
// Receive the first free buffer and initial sample rate
unsafe
{
c_audio :> double_buffer;
p_in_frame = &double_buffer->buffer[double_buffer->active_buffer];
c_audio :> cur_sample_rate;
}
i2s_config.mode = I2S_MODE_I2S;
// I2S has 32 bits per sample. *2 as 2 channels
const unsigned num_bits = 64;
const unsigned mclk = MASTER_TO_WORDCLOCK_RATIO * 48000;
// Calculate the MCLK to BCLK ratio using the current sample rate and bits per sample
i2s_config.mclk_bclk_ratio = mclk / ( cur_sample_rate * num_bits);
// Calculate the MCLK to BCLK ratio using the current sample rate and bits per sample
i2s_config.mclk_bclk_ratio = mclk / ( cur_sample_rate * num_bits);
const unsigned mclk = 512 * 48000;
to
const unsigned mclk = MASTER_TO_WORDCLOCK_RATIO * 48000;
so that I am using a define for the mclk to lrclk ratio which in my application needs to be 256
So that is all fine and good but I am wondering about the sample rate.
I was going to use a define for that as well but it seems the sample rate is determined by the audio buffering code in the line:
c_audio :> cur_sample_rate;
So I have two questions:
How is the current sample rate actually determined and/or set in the audio buffering routine?
And shouldn't the constant 48000 be replaced by the cur_sample_rate variable?
Cheers, Gerry