public int detectCarrier(float[] samples, float minMagnitudeThreshold) {
        int fftLength = getCeilPow2(samples.length);
        double[] fftSamples = convertFloatsToDoubles(Arrays.copyOf(samples, fftLength));
        Complex[] fftResult = new FastFourierTransformer(DftNormalization.STANDARD).transform(fftSamples, TransformType.FORWARD);

        //Now looking for band of max magnitude within configured boundaries
        double magScalar = 1.0d / (samples.length / 2.0d);
        double maxMag = 0.0;
        int maxMagBand = -1;
        int i = 1;	/* start detection at the first non-DC band */
        int nbands = fftLength / 2 + 1;

        if (isFskAutodetectMinFreq()) {
            i = Math.round((getFskMinFreq() + getBandWidth() / 2) / getBandWidth());
        }

        if (isFskAutodetectMaxFreq()) {
            nbands = Math.round((getFskMaxFreq() + getBandWidth() / 2) / getBandWidth());
            if (nbands > getNBands()) {
                nbands = getNBands();
            }
        }

        for (; i < nbands; i++) {
            double mag = fftResult[i].abs() * magScalar;

            if (mag < minMagnitudeThreshold) {
                continue;
            }

            if (maxMag < mag) {
                maxMag = mag;
                maxMagBand = i;
            }
        }

        if (maxMagBand < 0) {
            return -1;
        }

        return maxMagBand;
    }