![Expert Sleepers Disting mk4 Скачать руководство пользователя страница 121](http://html1.mh-extra.com/html/expert-sleepers/disting-mk4/disting-mk4_user-manual_2451908121.webp)
From these we can derive constants A, Br, D, Er so that conversion between codec codes and actual
voltages can be handled simply in the code as follows:
int vL = ( ( inL - A[0] ) * Br[0] ) >> 24;
int vR = ( ( inR - A[1] ) * Br[1] ) >> 24;
int cL = ( ( vOutL - D[0] ) * Er[0] ) >> 24;
int cR = ( ( vOutR - D[1] ) * Er[1] ) >> 24;
where inL/inR are the values read directly from the audio codec, cL/cR are the codes written
directly to the audio codec, and vL/vR/vOutL/vOutR are .19 format voltages.
The derivation of A, Br, D, Er is as follows:
Let the four input samples be zeroIn, zeroOut, halfOut, threeVolt.
A = zeroIn
B = ( threeVolt - zeroIn )/3
Br = 0x80000000000LL / B
D = ( zeroOut - zeroIn )/B
E = ( halfOut - zeroOut )/( B * 0x400000 )
Er = 0x80000000000LL / E
The above is pseudo-code - a real C implementation is left as an exercise for the reader.
Page 121