synthesizer - 带有 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();
确实按预期播放了五分之一。但是,也播放了非常令人不安的噪音。怎么能改进到只玩第五个?
解决方案
我也遇到过。我创建了一个扫弦器并与VariableRateMonoReader连接。然后幅度最多只能是0.5。否则会发出噪音。我试了很多次,我发现问题可能是两个 osc。删除一个 osc 再试一次。
推荐阅读
- spring - 使用 2 个表 Spring Security 进行身份验证
- reactjs - 处理自定义 SWR 挂钩中的错误
- c# - 如何在 c# 中将字符串值从一种形式传递到另一种形式?
- flask - 如何创建与 flask_socketio 和 telebot 的聊天?
- python - Tensorflow 2D 矩阵乘法返回矩阵产品列表
- python - 我可以抓取网站以识别其下的标题和文本吗?
- c - 我应该缩写库中的变量和函数名称吗?
- typescript - `import type` 是否等同于 `import()`
- c# - 如何将编译器生成的代码转换为可编译的 C# 代码
- firebase - Flutter firebase 函数错误:响应不是有效的 JSON 对象