ADAU1466 + ESP: Readback LevelRTA
Hi All,
I am working on a DSP solution where i use ESP32 to fully control the ADAU1466 @ SPI. I have many basic functions working and now i would like to provide input and output levels to the web interface running on ESP32, and i am currently quite unsure if what im doing is correct, im sure someone else have done this before me.
Lets say we have this LevelRTA in Sigma project;
<CellName>InputLevelDetector.LevelRTA_1</CellName>
<Algorithm>
<AlgoName>ALG0</AlgoName>
<DetailedName>SingleBandLevelLite3001</DetailedName>
<Description>SingleBandLite</Description>
<ModuleParameter>
<Name>SingleBandLevelLite3001</Name>
<Type>FixedPoint</Type>
<Address>56</Address>
<Value>0</Value>
<Size>4</Size>
<Data>0x00, 0x00, 0x00, 0x00, </Data>
</ModuleParameter>
<ModuleParameter>
<Name>SingleBandLevelLite3001mTCONST</Name>
<Type>FixedPoint</Type>
<Address>57</Address>
<Value>0.999000012874603</Value>
<Size>4</Size>
<Data>0x00, 0xFF, 0xBE, 0x77, </Data>
</ModuleParameter>
</Algorithm>
Which tells which address to use, ie 56 in this case. Now over to the ESP code. I guess the same would apply for Arduino and Teensy applications.
code for reading register byte (taken from analog`s teensy sample)
void adauClass::SIGMA_READ_REGISTER_BYTES(uint16_t address, int length, byte *pData, bool dbg) {
gPio.setWriteADAU(true);
SPI.beginTransaction(settingsA);
SPI.transfer(0x1);
SPI.transfer(address >> 8);
SPI.transfer(address & 0xff);
for (int i = 0; i < length; i++) {
pData[i] = SPI.transfer(0);
}
SPI.endTransaction();
gPio.setWriteADAU(false);
}
}
Converting to float
float adauClass::readBackLevel(uint16_t address){
uint8_t buf[4];
int32_t word32 = 0;
memset(buf, 0, 4);
SIGMA_READ_REGISTER_BYTES(address, 4, buf, false);
word32 = ((uint32_t)buf[0]<<24 | (uint32_t)buf[1]<<16 | (uint32_t)buf[2]<<8 | (uint32_t)buf[3]);
word32 = (word32 << 4)&0xFFFFFFF0;
if(word32==0) word32 = 1;
return ((float)word32/((uint32_t)1 << 27));
}
The actual reading command;
float value = readBackLevel(56);
value is 0.315242887 as an example.
Would it be correct to assume, that with the above method of reading level from DSP, and using this formula: 20*Math.log(value/1) should provide the correct output in dB?
Edit Notes
Adding formula for converting to db
[edited by: cod3gen at 3:56 PM (GMT -5) on 13 Feb 2022]
Audio Signal Processors
levelrta
esp32
SigmaDSP Audio Processors
adau146x
Teensy
adau1466
Show More
Hello cod3gen,
This post might shed some light on how to do this.
(+) Reading meters with a controller on the ADAU1452 - Q&A - SigmaDSP Processors and SigmaStudio Development Tool - EngineerZone (analog.com)
Dave T
Hi Dave,
Thanks for your reply. It does shed some light on how to do it, but it also brings two additional alternatives on the table of which both is more consuming in terms of instructions.
Stian
Hello Stian,
Yes, you do have a choice of having the DSP do more of the calculations or off loading that to the controller. That is your choice from a systems design standpoint and the processing load you already have on either the DSP or the controller. The only detail with the DSP is that the really low instruction versions are basically a readback. So if you read a sample every 10ms you are missing 10ms of samples! You usually do not want to read any faster but I suppose you can. It depends on how many channels and what else is happening for control of the DSP.
So this is why you use a meter that gets the RMS or Average values of the audio and uses time constants to hold the value for at least 10ms. This gives you time to read it. There are other strategies you can use. You can simply get the absolute value of the audio and then go to a peak hold cell. Read the value then reset it. Then you have to choose how you want to display this, either as simply a peak value or calculate an RMS value from the peak. Either way the heavy processing would be on the controller instead of the DSP. You could also just use an envelope generator but those use a fair amount of instructions but the peak one might be less than the meter. Something to experiment with in a test project and look at the MIPS usage.
There was someone who had to read many meters about a year or so ago and needed a low MIPS way to do it. I will try to search for his post.
Thanks,
Dave T
Please log in to reply.