Java 类com.sun.media.sound.SoftLowFrequencyOscillator 实例源码

项目:jdk8u-jdk    文件:TestProcessControlLogic.java   
private static void testLFO(boolean shared, int instance, float freq, float delay,
        float delay2) throws Exception {
    SoftLowFrequencyOscillator lfo =
        shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator();
    lfo.reset();
    double[] lfo_freq = lfo.get(instance, "freq");
    double[] lfo_delay = lfo.get(instance, "delay");
    double[] lfo_delay2 = lfo.get(instance, "delay2");
    double[] lfo_output = lfo.get(instance, null);
    lfo_freq[0] = freq;
    lfo_delay[0] = delay;
    lfo_delay2[0] = delay2;
    lfo.init(synth);

    // For delayCount amount time, the output LFO should be 0.5
    int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate));
    delayCount += (int) ((delay2 * control_rate) / 1000.0);
    for (int i = 0; i < delayCount; i++) {
        if (Math.abs(0.5 - lfo_output[0]) > 0.000001)
            throw new Exception("Incorrect LFO output ("
                    +"0.5 != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

    // After the delay the LFO should start oscillate
    // Let make sure output is accurate enough
    double p_step = (440.0 / control_rate)
    * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0));
    double p = 0;
    for (int i = 0; i < 30; i++) {
        p += p_step;
        double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5;
        if (Math.abs(predicted_output - lfo_output[0]) > 0.001)
            throw new Exception("Incorrect LFO output ("
                    +predicted_output+" != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

}
项目:openjdk-jdk10    文件:TestProcessControlLogic.java   
private static void testLFO(boolean shared, int instance, float freq, float delay,
        float delay2) throws Exception {
    SoftLowFrequencyOscillator lfo =
        shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator();
    lfo.reset();
    double[] lfo_freq = lfo.get(instance, "freq");
    double[] lfo_delay = lfo.get(instance, "delay");
    double[] lfo_delay2 = lfo.get(instance, "delay2");
    double[] lfo_output = lfo.get(instance, null);
    lfo_freq[0] = freq;
    lfo_delay[0] = delay;
    lfo_delay2[0] = delay2;
    lfo.init(synth);

    // For delayCount amount time, the output LFO should be 0.5
    int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate));
    delayCount += (int) ((delay2 * control_rate) / 1000.0);
    for (int i = 0; i < delayCount; i++) {
        if (Math.abs(0.5 - lfo_output[0]) > 0.000001)
            throw new Exception("Incorrect LFO output ("
                    +"0.5 != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

    // After the delay the LFO should start oscillate
    // Let make sure output is accurate enough
    double p_step = (440.0 / control_rate)
    * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0));
    double p = 0;
    for (int i = 0; i < 30; i++) {
        p += p_step;
        double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5;
        if (Math.abs(predicted_output - lfo_output[0]) > 0.001)
            throw new Exception("Incorrect LFO output ("
                    +predicted_output+" != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

}
项目:openjdk9    文件:TestProcessControlLogic.java   
private static void testLFO(boolean shared, int instance, float freq, float delay,
        float delay2) throws Exception {
    SoftLowFrequencyOscillator lfo =
        shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator();
    lfo.reset();
    double[] lfo_freq = lfo.get(instance, "freq");
    double[] lfo_delay = lfo.get(instance, "delay");
    double[] lfo_delay2 = lfo.get(instance, "delay2");
    double[] lfo_output = lfo.get(instance, null);
    lfo_freq[0] = freq;
    lfo_delay[0] = delay;
    lfo_delay2[0] = delay2;
    lfo.init(synth);

    // For delayCount amount time, the output LFO should be 0.5
    int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate));
    delayCount += (int) ((delay2 * control_rate) / 1000.0);
    for (int i = 0; i < delayCount; i++) {
        if (Math.abs(0.5 - lfo_output[0]) > 0.000001)
            throw new Exception("Incorrect LFO output ("
                    +"0.5 != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

    // After the delay the LFO should start oscillate
    // Let make sure output is accurate enough
    double p_step = (440.0 / control_rate)
    * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0));
    double p = 0;
    for (int i = 0; i < 30; i++) {
        p += p_step;
        double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5;
        if (Math.abs(predicted_output - lfo_output[0]) > 0.001)
            throw new Exception("Incorrect LFO output ("
                    +predicted_output+" != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

}
项目:jdk8u_jdk    文件:TestProcessControlLogic.java   
private static void testLFO(boolean shared, int instance, float freq, float delay,
        float delay2) throws Exception {
    SoftLowFrequencyOscillator lfo =
        shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator();
    lfo.reset();
    double[] lfo_freq = lfo.get(instance, "freq");
    double[] lfo_delay = lfo.get(instance, "delay");
    double[] lfo_delay2 = lfo.get(instance, "delay2");
    double[] lfo_output = lfo.get(instance, null);
    lfo_freq[0] = freq;
    lfo_delay[0] = delay;
    lfo_delay2[0] = delay2;
    lfo.init(synth);

    // For delayCount amount time, the output LFO should be 0.5
    int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate));
    delayCount += (int) ((delay2 * control_rate) / 1000.0);
    for (int i = 0; i < delayCount; i++) {
        if (Math.abs(0.5 - lfo_output[0]) > 0.000001)
            throw new Exception("Incorrect LFO output ("
                    +"0.5 != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

    // After the delay the LFO should start oscillate
    // Let make sure output is accurate enough
    double p_step = (440.0 / control_rate)
    * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0));
    double p = 0;
    for (int i = 0; i < 30; i++) {
        p += p_step;
        double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5;
        if (Math.abs(predicted_output - lfo_output[0]) > 0.001)
            throw new Exception("Incorrect LFO output ("
                    +predicted_output+" != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

}
项目:lookaside_java-1.8.0-openjdk    文件:TestProcessControlLogic.java   
private static void testLFO(boolean shared, int instance, float freq, float delay,
        float delay2) throws Exception {
    SoftLowFrequencyOscillator lfo =
        shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator();
    lfo.reset();
    double[] lfo_freq = lfo.get(instance, "freq");
    double[] lfo_delay = lfo.get(instance, "delay");
    double[] lfo_delay2 = lfo.get(instance, "delay2");
    double[] lfo_output = lfo.get(instance, null);
    lfo_freq[0] = freq;
    lfo_delay[0] = delay;
    lfo_delay2[0] = delay2;
    lfo.init(synth);

    // For delayCount amount time, the output LFO should be 0.5
    int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate));
    delayCount += (int) ((delay2 * control_rate) / 1000.0);
    for (int i = 0; i < delayCount; i++) {
        if (Math.abs(0.5 - lfo_output[0]) > 0.000001)
            throw new Exception("Incorrect LFO output ("
                    +"0.5 != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

    // After the delay the LFO should start oscillate
    // Let make sure output is accurate enough
    double p_step = (440.0 / control_rate)
    * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0));
    double p = 0;
    for (int i = 0; i < 30; i++) {
        p += p_step;
        double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5;
        if (Math.abs(predicted_output - lfo_output[0]) > 0.001)
            throw new Exception("Incorrect LFO output ("
                    +predicted_output+" != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

}
项目:infobip-open-jdk-8    文件:TestProcessControlLogic.java   
private static void testLFO(boolean shared, int instance, float freq, float delay,
        float delay2) throws Exception {
    SoftLowFrequencyOscillator lfo =
        shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator();
    lfo.reset();
    double[] lfo_freq = lfo.get(instance, "freq");
    double[] lfo_delay = lfo.get(instance, "delay");
    double[] lfo_delay2 = lfo.get(instance, "delay2");
    double[] lfo_output = lfo.get(instance, null);
    lfo_freq[0] = freq;
    lfo_delay[0] = delay;
    lfo_delay2[0] = delay2;
    lfo.init(synth);

    // For delayCount amount time, the output LFO should be 0.5
    int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate));
    delayCount += (int) ((delay2 * control_rate) / 1000.0);
    for (int i = 0; i < delayCount; i++) {
        if (Math.abs(0.5 - lfo_output[0]) > 0.000001)
            throw new Exception("Incorrect LFO output ("
                    +"0.5 != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

    // After the delay the LFO should start oscillate
    // Let make sure output is accurate enough
    double p_step = (440.0 / control_rate)
    * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0));
    double p = 0;
    for (int i = 0; i < 30; i++) {
        p += p_step;
        double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5;
        if (Math.abs(predicted_output - lfo_output[0]) > 0.001)
            throw new Exception("Incorrect LFO output ("
                    +predicted_output+" != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

}
项目:jdk8u-dev-jdk    文件:TestProcessControlLogic.java   
private static void testLFO(boolean shared, int instance, float freq, float delay,
        float delay2) throws Exception {
    SoftLowFrequencyOscillator lfo =
        shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator();
    lfo.reset();
    double[] lfo_freq = lfo.get(instance, "freq");
    double[] lfo_delay = lfo.get(instance, "delay");
    double[] lfo_delay2 = lfo.get(instance, "delay2");
    double[] lfo_output = lfo.get(instance, null);
    lfo_freq[0] = freq;
    lfo_delay[0] = delay;
    lfo_delay2[0] = delay2;
    lfo.init(synth);

    // For delayCount amount time, the output LFO should be 0.5
    int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate));
    delayCount += (int) ((delay2 * control_rate) / 1000.0);
    for (int i = 0; i < delayCount; i++) {
        if (Math.abs(0.5 - lfo_output[0]) > 0.000001)
            throw new Exception("Incorrect LFO output ("
                    +"0.5 != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

    // After the delay the LFO should start oscillate
    // Let make sure output is accurate enough
    double p_step = (440.0 / control_rate)
    * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0));
    double p = 0;
    for (int i = 0; i < 30; i++) {
        p += p_step;
        double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5;
        if (Math.abs(predicted_output - lfo_output[0]) > 0.001)
            throw new Exception("Incorrect LFO output ("
                    +predicted_output+" != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

}
项目:jdk7-jdk    文件:TestProcessControlLogic.java   
private static void testLFO(boolean shared, int instance, float freq, float delay,
        float delay2) throws Exception {
    SoftLowFrequencyOscillator lfo =
        shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator();
    lfo.reset();
    double[] lfo_freq = lfo.get(instance, "freq");
    double[] lfo_delay = lfo.get(instance, "delay");
    double[] lfo_delay2 = lfo.get(instance, "delay2");
    double[] lfo_output = lfo.get(instance, null);
    lfo_freq[0] = freq;
    lfo_delay[0] = delay;
    lfo_delay2[0] = delay2;
    lfo.init(synth);

    // For delayCount amount time, the output LFO should be 0.5
    int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate));
    delayCount += (int) ((delay2 * control_rate) / 1000.0);
    for (int i = 0; i < delayCount; i++) {
        if (Math.abs(0.5 - lfo_output[0]) > 0.000001)
            throw new Exception("Incorrect LFO output ("
                    +"0.5 != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

    // After the delay the LFO should start oscillate
    // Let make sure output is accurate enough
    double p_step = (440.0 / control_rate)
    * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0));
    double p = 0;
    for (int i = 0; i < 30; i++) {
        p += p_step;
        double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5;
        if (Math.abs(predicted_output - lfo_output[0]) > 0.001)
            throw new Exception("Incorrect LFO output ("
                    +predicted_output+" != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

}
项目:openjdk-source-code-learn    文件:TestProcessControlLogic.java   
private static void testLFO(boolean shared, int instance, float freq, float delay,
        float delay2) throws Exception {
    SoftLowFrequencyOscillator lfo =
        shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator();
    lfo.reset();
    double[] lfo_freq = lfo.get(instance, "freq");
    double[] lfo_delay = lfo.get(instance, "delay");
    double[] lfo_delay2 = lfo.get(instance, "delay2");
    double[] lfo_output = lfo.get(instance, null);
    lfo_freq[0] = freq;
    lfo_delay[0] = delay;
    lfo_delay2[0] = delay2;
    lfo.init(synth);

    // For delayCount amount time, the output LFO should be 0.5
    int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate));
    delayCount += (int) ((delay2 * control_rate) / 1000.0);
    for (int i = 0; i < delayCount; i++) {
        if (Math.abs(0.5 - lfo_output[0]) > 0.000001)
            throw new Exception("Incorrect LFO output ("
                    +"0.5 != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

    // After the delay the LFO should start oscillate
    // Let make sure output is accurate enough
    double p_step = (440.0 / control_rate)
    * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0));
    double p = 0;
    for (int i = 0; i < 30; i++) {
        p += p_step;
        double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5;
        if (Math.abs(predicted_output - lfo_output[0]) > 0.001)
            throw new Exception("Incorrect LFO output ("
                    +predicted_output+" != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

}
项目:OLD-OpenJDK8    文件:TestProcessControlLogic.java   
private static void testLFO(boolean shared, int instance, float freq, float delay,
        float delay2) throws Exception {
    SoftLowFrequencyOscillator lfo =
        shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator();
    lfo.reset();
    double[] lfo_freq = lfo.get(instance, "freq");
    double[] lfo_delay = lfo.get(instance, "delay");
    double[] lfo_delay2 = lfo.get(instance, "delay2");
    double[] lfo_output = lfo.get(instance, null);
    lfo_freq[0] = freq;
    lfo_delay[0] = delay;
    lfo_delay2[0] = delay2;
    lfo.init(synth);

    // For delayCount amount time, the output LFO should be 0.5
    int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate));
    delayCount += (int) ((delay2 * control_rate) / 1000.0);
    for (int i = 0; i < delayCount; i++) {
        if (Math.abs(0.5 - lfo_output[0]) > 0.000001)
            throw new Exception("Incorrect LFO output ("
                    +"0.5 != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

    // After the delay the LFO should start oscillate
    // Let make sure output is accurate enough
    double p_step = (440.0 / control_rate)
    * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0));
    double p = 0;
    for (int i = 0; i < 30; i++) {
        p += p_step;
        double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5;
        if (Math.abs(predicted_output - lfo_output[0]) > 0.001)
            throw new Exception("Incorrect LFO output ("
                    +predicted_output+" != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

}
项目:JAVA_UNIT    文件:TestProcessControlLogic.java   
private static void testLFO(boolean shared, int instance, float freq, float delay,
        float delay2) throws Exception {
    SoftLowFrequencyOscillator lfo =
        shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator();
    lfo.reset();
    double[] lfo_freq = lfo.get(instance, "freq");
    double[] lfo_delay = lfo.get(instance, "delay");
    double[] lfo_delay2 = lfo.get(instance, "delay2");
    double[] lfo_output = lfo.get(instance, null);
    lfo_freq[0] = freq;
    lfo_delay[0] = delay;
    lfo_delay2[0] = delay2;
    lfo.init(synth);

    // For delayCount amount time, the output LFO should be 0.5
    int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate));
    delayCount += (int) ((delay2 * control_rate) / 1000.0);
    for (int i = 0; i < delayCount; i++) {
        if (Math.abs(0.5 - lfo_output[0]) > 0.000001)
            throw new Exception("Incorrect LFO output ("
                    +"0.5 != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

    // After the delay the LFO should start oscillate
    // Let make sure output is accurate enough
    double p_step = (440.0 / control_rate)
    * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0));
    double p = 0;
    for (int i = 0; i < 30; i++) {
        p += p_step;
        double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5;
        if (Math.abs(predicted_output - lfo_output[0]) > 0.001)
            throw new Exception("Incorrect LFO output ("
                    +predicted_output+" != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

}
项目:openjdk-jdk7u-jdk    文件:TestProcessControlLogic.java   
private static void testLFO(boolean shared, int instance, float freq, float delay,
        float delay2) throws Exception {
    SoftLowFrequencyOscillator lfo =
        shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator();
    lfo.reset();
    double[] lfo_freq = lfo.get(instance, "freq");
    double[] lfo_delay = lfo.get(instance, "delay");
    double[] lfo_delay2 = lfo.get(instance, "delay2");
    double[] lfo_output = lfo.get(instance, null);
    lfo_freq[0] = freq;
    lfo_delay[0] = delay;
    lfo_delay2[0] = delay2;
    lfo.init(synth);

    // For delayCount amount time, the output LFO should be 0.5
    int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate));
    delayCount += (int) ((delay2 * control_rate) / 1000.0);
    for (int i = 0; i < delayCount; i++) {
        if (Math.abs(0.5 - lfo_output[0]) > 0.000001)
            throw new Exception("Incorrect LFO output ("
                    +"0.5 != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

    // After the delay the LFO should start oscillate
    // Let make sure output is accurate enough
    double p_step = (440.0 / control_rate)
    * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0));
    double p = 0;
    for (int i = 0; i < 30; i++) {
        p += p_step;
        double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5;
        if (Math.abs(predicted_output - lfo_output[0]) > 0.001)
            throw new Exception("Incorrect LFO output ("
                    +predicted_output+" != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

}
项目:openjdk-icedtea7    文件:TestProcessControlLogic.java   
private static void testLFO(boolean shared, int instance, float freq, float delay,
        float delay2) throws Exception {
    SoftLowFrequencyOscillator lfo =
        shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator();
    lfo.reset();
    double[] lfo_freq = lfo.get(instance, "freq");
    double[] lfo_delay = lfo.get(instance, "delay");
    double[] lfo_delay2 = lfo.get(instance, "delay2");
    double[] lfo_output = lfo.get(instance, null);
    lfo_freq[0] = freq;
    lfo_delay[0] = delay;
    lfo_delay2[0] = delay2;
    lfo.init(synth);

    // For delayCount amount time, the output LFO should be 0.5
    int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate));
    delayCount += (int) ((delay2 * control_rate) / 1000.0);
    for (int i = 0; i < delayCount; i++) {
        if (Math.abs(0.5 - lfo_output[0]) > 0.000001)
            throw new Exception("Incorrect LFO output ("
                    +"0.5 != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

    // After the delay the LFO should start oscillate
    // Let make sure output is accurate enough
    double p_step = (440.0 / control_rate)
    * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0));
    double p = 0;
    for (int i = 0; i < 30; i++) {
        p += p_step;
        double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5;
        if (Math.abs(predicted_output - lfo_output[0]) > 0.001)
            throw new Exception("Incorrect LFO output ("
                    +predicted_output+" != "+lfo_output[0]+")!");
        lfo.processControlLogic();
    }

}