I'm working on reading peek audio values from ADAU1467 audio inputs over I2C from readback block addresses in sigmaStudio.
I'm reading in 4bytes of data from each block ( incrementing readback block address by 1 for each channel )
i'm trying to make a value from the 4 bytes then cast to uint8_t peek audio values for simple meters in an application.
// uint32_t value from 4 bytes received uint32_t temp = (meterDataRX << 24) | (meterDataRX << 16) | (meterDataRX << 8) | meterDataRX;
// cast uint32_t meter value to uint8_t , +3 into array to avoid header gainMeterValues[loop+3] = (uint8_t)temp;
I have tried hex and DbI settings on readback but don't seam to get values that correspond with peek audio values on the inputs.
Am I approaching this in the wrong way for AUAU1467? am i assembling the 4 bytes incorrectly ? should i be ignoring bits 24 -> 32 in that case?
can anyone explain what HEX switch does. Also can I just set the readback to 8bits and read one byte per channel at a time?
if I set to 8.24 format , am i just reading the sample value in 8.24 format every 100ms ?
i set continuous mode 100ms on each of the 8 channels
I also tried 32.30 format in readback block and not really getting values that look like peek audio. So I can only assume the readback does not translate the values for you , you just have to use the native format of 8.24 for ADAU1467. In that case how would I bit shift the 4 bytes I read into a single uint32_t value ?
ok this worked. I set the format in the readback to 32.0
// signed 4 byte 32.0 samples values ? int32_t tempA;
// unsigneduint32_t tempB;
// build the number value from 4 bytes recieved tempA = (meterDataRX << 24) | (meterDataRX << 16) | (meterDataRX << 8) | meterDataRX; // cast tempB = (uint32_t)tempA; /// // cast uint32_t meter value to uint8_t , gainMeterValues[loop+3] = (uint8_t)tempB;
The hex and data format switch on the readback cells are only for the display on the screen in SigmaStudio. The data in the memory of the DSP is just the number stored in binary. The switches on the readback help you "see" it in different formats but in the end the number is the number.
Look at the params window and you will see the value of the readback when you click the refresh button on the params window. It shows you the value in all three formats. There is only one number stored.
I think part of the problem is that you need to set the hold value in the peak envelop generator to at least the timing of the I2C reads. If you are reading every 10mS then set the hold time to 10mS. If it is set to less than the polling then the peak will come in and start to decay before you have a chance to read it.
You may also want to adjust your decay time so something that works well for you.
Ok I see now I need to know the maximum possible number the readback can give me from the audio inputs and then scale that to my meters. In my application I need to scale the value between 0 and 256
I was first thinking it would be the max input volume would be the max possible unsigned 32bit number. but that would be more resolution than available?
Can you tell me what that max number can be from an input on the adau146x ?
Is it 16,777,215 ? max possible 24bit number ? or 8,388,607 ?
Its tricky to get my inputs running with the Analouge Devices USBi programmer / sigma studio since I need the micro running on the same bus.
I have this working now , the solution was to just scale the numbers to required range.
scaledMeter = (meterVal * (uint32_t)256) / 4194304;
I understand the largest number would be dependent on the window before the readback peek average etc.