Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { /** * generate a CW signal with the given properties * @param frequency the frequency * @param length sample length * @param amplitude maximum amplitude * @param sampleRate sample rate to use * @return data as double[] */ public static double[] generateSignal(double frequency, int length, double amplitude, double sampleRate) { double[] signal = new double[length]; for (int i = 0; i < length; i++) { signal[i] = amplitude * Math.sin(frequency * 2.0 * Math.PI * (i / sampleRate)); } return signal; } }