I'm working on a reverb algorithm, heavily based on Pio's plate reverb techniques plus a bunch of other Audio Blocks for filtering and other effects. I was having some troubles with the levels, the overall output signal becomes too low and I had to compensate (too much in my opinion) when mixing that with an analog signal. So started to go block by block and checking the input and output levels to see where the signal amplitude gets lost and found out that the reverb was one of the lowest. Made a simple test -> Input -> Reverb -> Amplifier block -> Output. If I set the gain of the amplifier block on 2 or more, the output sound stopped. Tried to adjust the input attenuation of the reverb, got better but got clipping. So started to print the signal and plot it and check the numeric values of it to see if I could see any issues there. The values where all negative, with a span of -10000 to -20000 approximately, so when I multiplied by 2 or more with the gain amplifier got out of range.
Got surprised by those numbers, because I thought that it will be something more like a 0 centered signal. I introduced an offset to see if that could be "compensated" and the overall situation got better, got a better range to amplify the signal and get the levels back to something more useful.
In Pio's code uses floating point on the calculations and then converts it back to int16_t for output, so on the input does this:
Where blockL is an audio_block_t pointer and input_blockL is a float32_t buffer with a size of 128 to accommodate the audio block. If I plot right after that conversion, at the beggining of the code I have an offset set there. On the output, to get back to the int16_t, does this:
Where outputLeft has the output signal and then make transmit(outblockL, 0) to get that output out of the effect block output 0.
Testing another block of effect, the signal is 0 centered, with positive and negative values and I get a decent output level that I can adjust at will.
So, the question is, "what's the correct numerical value that the signal should take?" a 0 centered signal?, is that offset correct or not?, has to be something to the conversion from int to float? how can I correct that?
Got surprised by those numbers, because I thought that it will be something more like a 0 centered signal. I introduced an offset to see if that could be "compensated" and the overall situation got better, got a better range to amplify the signal and get the levels back to something more useful.
In Pio's code uses floating point on the calculations and then converts it back to int16_t for output, so on the input does this:
Code:
arm_q15_to_float((q15_t *)blockL->data, input_blockL, AUDIO_BLOCK_SAMPLES);
Where blockL is an audio_block_t pointer and input_blockL is a float32_t buffer with a size of 128 to accommodate the audio block. If I plot right after that conversion, at the beggining of the code I have an offset set there. On the output, to get back to the int16_t, does this:
Code:
outblockL->data[i] = (int16_t) (outputLeft * 32767.0f);
Where outputLeft has the output signal and then make transmit(outblockL, 0) to get that output out of the effect block output 0.
Testing another block of effect, the signal is 0 centered, with positive and negative values and I get a decent output level that I can adjust at will.
So, the question is, "what's the correct numerical value that the signal should take?" a 0 centered signal?, is that offset correct or not?, has to be something to the conversion from int to float? how can I correct that?
Last edited: