带有 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();

确实如预期的那样打了第五个。然而,也播放了非常令人不安的声音。如何改进以只玩第五个?

正弦波由 LineOut 相加。

音频硬件只能处理 -1.0 到 +1.0 范围内的音频。任何超过 1.0 的内容都会削波且听起来很糟糕。如果混合两个振幅为 1.0 的正弦波,那么它们加起来可以达到 2.0。

尝试将包络的振幅设置为 0.4。

envelopePlayer1.amplitude.set(0.4);
envelopePlayer2.amplitude.set(0.4);

或者,您可以使用混音器来控制各个声音的音量。

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

最新更新