本文整理汇总了Java中com.sun.media.sound.SoftLowFrequencyOscillator类的典型用法代码示例。如果您正苦于以下问题:Java SoftLowFrequencyOscillator类的具体用法?Java SoftLowFrequencyOscillator怎么用?Java SoftLowFrequencyOscillator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SoftLowFrequencyOscillator类属于com.sun.media.sound包,在下文中一共展示了SoftLowFrequencyOscillator类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLFO
import com.sun.media.sound.SoftLowFrequencyOscillator; //导入依赖的package包/类
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();
}
}