adjusting AUDIO_SAMPLE_RATE_EXACT

Status
Not open for further replies.

damo1976

Well-known member
I have 2 teensy boards that are using the same code. I am telling the compiler which code to run based on the level of a specific pin which I have tied to ground. This saves me from having one project per board.

I want to adjust the value if AUDIO_SAMPLE_RATE_EXACT in the file audiostream.h
to be different for each board.

It seems the compiler compiles the audiostream.h file before it compiles my .ino project file so I cant seem to define the AUDIO_SAMPLE_RATE_EXACT without it giving me an error that it is already defined.

The pin check is done in the maincode with a digital read.

Is there any way to have the AUDIO_SAMPLE_RATE_EXACT different for each board?
 
AUDIO_SAMPLE_RATE_EXACT is a compile time setting. You are looking for a run-time clock change, which has to be done differently.

Using Paul's recent discovery, should be something like:

if (pin) CCM_ANALOG_PLL_AUDIO_NUM *= (48000.0 / 48000.235);

It also needs a large denominator set in the clock code (see other thread for this).
 
ok so if I just leave the AUDIO_SAMPLE_RATE_EXACT as 48000 and then adjust CCM_ANALOG_PLL_AUDIO_NUM it will do the same thing?
 
I think so, but let us know.

I'm working on some code that will calculate the correction ratio to apply from any kind of periodic communication. But a fixed ratio is fine for some uses.
 
I tried it and while changes to CCM_ANALOG_PLL_AUDIO_NUM clearly changes the clock rate, it isn't a simple ratio. You could use trail and error to find the right value. Or use the c1 value from the nice spreadsheet that Frank posted.
 
Status
Not open for further replies.
Back
Top