# [pskmail] PskR - 4 level quantizer

*From*: Stefano <stefano.banti@xxxxxxxx>
*To*: pskmail@xxxxxxxxxxxxx
*Date*: Tue, 31 Jan 2012 21:23:24 +0100

Hi all,

`I'm a sporadic user of pskmail, software developer and ham radio op as
``well; I'm looking at the source code of fldigi because I'm interested in
``the pskr software modem implementation.
``Can someone explain (shortly) the method used for the 4-level softbit
``quantizer ? Or give a reference to find mathematics involved ?
`
...
averageamp = decayavg(averageamp, sigamp, SQLDECAY);
if (sigamp > 0 && averageamp > 0) {
softamp = clamp( averageamp / sigamp, 1.0, 1e6);
} else {
softamp = 1; // arbritary number (50% impact)
}
// Compute values between -128 and +127 for phase value only
if (phase > M_PI) {

` softangle = (127 - (((2 * M_PI - phase) / M_PI) * (double)
``255));
` } else {
softangle = (127 - ((phase / M_PI) * (double) 255));
}
// Then apply impact of amplitude. Finally, re-centre on 127-128
// as the decoder needs values between 0-255
softbit = (unsigned char) ((softangle / (1 + softamp)) - 127);
...
many thanks in advance
Stefano ik2yxt.

### Other related posts: