首页 > 解决方案 > 带有 JSyn 包络的复音听起来不太好

问题描述

我使用了 JSyn 示例 PlayChords 和 PlaySegmentedEnvelope(这两个示例都很容易找到)来创建简单的复音。这段代码

        synth = JSyn.createSynthesizer();
        synth.add(osc1 = new SineOscillator());
        synth.add(osc2 = new SineOscillator());
        synth.add(envelopePlayer1 = new VariableRateMonoReader());
        synth.add(envelopePlayer2 = new VariableRateMonoReader());
        double[] pairs = {0.1, 1.0, 0.5, 1.0, 0.7, 0.3, 0.8, 0.0};
        envelope = new SegmentedEnvelope(pairs);
        synth.add(lineOut = new LineOut());
        envelopePlayer1.output.connect(osc1.amplitude);
        envelopePlayer2.output.connect(osc2.amplitude);
        osc1.output.connect(0, lineOut.input, 0);
        osc1.output.connect(0, lineOut.input, 1);
        osc2.output.connect(0, lineOut.input, 0);
        osc2.output.connect(0, lineOut.input, 1);
        synth.start();
        lineOut.start();
        osc1.frequency.set(440.0);
        envelopePlayer1.dataQueue.queue(envelope);
        osc2.frequency.set(660.0);
        envelopePlayer2.dataQueue.queue(envelope); // attack
        synth.sleepFor(2.0);
        synth.stop();

确实按预期播放了五分之一。但是,也播放了非常令人不安的噪音。怎么能改进到只玩第五个?

标签: synthesizerjsyn

解决方案


我也遇到过。我创建了一个扫弦器并与VariableRateMonoReader连接。然后幅度最多只能是0.5。否则会发出噪音。我试了很多次,我发现问题可能是两个 osc。删除一个 osc 再试一次。


推荐阅读