package net.heartshield.sensors;

import net.heartshield.signal.DVec;

/**
 * @author David Madl (git@abanbytes.eu)
 * @date 2017-04-10
 */
public class AudioTest {
    /**
     * sig must be normalized to [-1.0, 1.0]. fps belongs to sig.
     * frequency shift is specified as k0-th fraction of f_carrier.
     */
    private double[] modulateFm(double carrierFreq, double[] sig, double fps, double k0) {
        double[] t = DVec.mul(DVec.arange(0, sig.length), 1.0 / fps);
        double[] theta = DVec.mul(DVec.cumsum(sig), k0 / fps);
        double[] res = new double[theta.length];
        for(int i = 0; i < res.length; i++)
            res[i] = Math.cos(2*Math.PI*carrierFreq * (t[i] + theta[i]));
        return res;
    }
}
