Could use some help if anybody has good idea:
Sampling an audio signal with 8-bit ADC, and want to take the log, then scale/round it to an 8-bit result.
Log(ADC-sample)/Log(255) = Scaled-Value/255
Scaled-value = Log(ADC-sample)/Log(255)*255
Then rounded to closest integer.
So, as examples:
If ADC reads 256, I want to display 256
If ADC reads 128, I want to display 223
If ADC reads 40, I want to display 170
If ADC reads 10, I want to display 106
If ADC reads 1, I want to display 0
Also - I'm using the ATTiny26 in assembler, where there's no MUL instruction.
Have looked at a few piece-wise linear algo's but difficult to implement w/o MUL. Hate to use 256 bytes for a full lookup table as I'm short on code-space already.
Any thoughts would be greatly appreciated!