我一直在尝试调频合成制作音频文件,并使用ADSR包络来塑造最终的声音。 FM 表示调频。ADSR 表示 Attack、Decay、Sustain 和 Release。 ADSR 描述了一条曲线,该曲线确定按下琴键时音符音量增加(起音)和减小(衰减)的速度、按住琴键时的持续音量以及松开琴键时音符音量的衰减方式。 ADSR 曲线的典型图片有四条直线:
A, D, R are time; S is a levelA, D, R are time; S is a levelA, D, R are time; S is a levelA, D, R are time; S is a levelA、D、R为时间; S是一个级别
下面的波形没有调制(所有的波峰和波谷都是等距的。)
如果您查看图表中第一个周期的顶部,您会看到一个小故障。 由于我正在编写代码,所以我认为我犯了一个错误;缩放它会使它看起来像是一个可能会稍微影响声音的重大错误。
Actually, two glitchesActually, two glitchesActually, two glitchesActually, two glitches其实有两个漏洞
攻击设置为 0.001 秒,衰减为 0.003;每秒 44,100 个样本时,攻击在样本 44 处结束,衰减在样本 176 附近结束。 我建立了一个数据表来制作一个简化版本,最终发现毛刺是由 ADSR 曲线中的尖角引起的。 为了修复它,我将样条拟合到 ADSR 曲线。 只要样条线的张力足够高,故障就非常微妙,不易察觉。 (这是简化的数据,不是您在上面和下面听到的数据。)
The orange spline-based curves are hiding behind the purple curves; at this zoom they are nearly identical.The orange spline-based curves are hiding behind the purple curves; at this zoom they are nearly identical.The orange spline-based curves are hiding behind the purple curves; at this zoom they are nearly identical.The orange spline-based curves are hiding behind the purple curves; at this zoom they are nearly identical.橙色样条曲线隐藏在紫色曲线后面;在此变焦下,它们几乎完全相同。
在衰减和维持曲线之间的拐角处放大一点:
The solid sine curve is rising, but slowing. The dotted purple decay curve is falling, but about to become flat (sustain.)The solid sine curve is rising, but slowing. The dotted purple decay curve is falling, but about to become flat (sustain.)The solid sine curve is rising, but slowing. The dotted purple decay curve is falling, but about to become flat (sustain.)The solid sine curve is rising, but slowing. The dotted purple decay curve is falling, but about to become flat (sustain.)实心正弦曲线正在上升,但正在放缓。 虚线紫色衰减曲线正在下降,但即将变平(持续)
橙色虚线是紫色虚线中各点的样条插值。 橙色实线是原始正弦波乘以橙色包络以按比例缩小。 紫色曲线的误差似乎约为千分之一;我不确定那是否会被听到。 在波形文件数据的 +/- 32767 范围内,大约是 32、2^5,可能在 16 位数的第 5 位,可能降低 60 dB。 我认为用好的设备和年轻的耳朵应该可以听到。
放大看,像很好地失真的正弦波。
The glitch is gone. The leading part of the sine wave is flattened by the rising gain of the attack.The glitch is gone. The leading part of the sine wave is flattened by the rising gain of the attack.The glitch is gone. The leading part of the sine wave is flattened by the rising gain of the attack.The glitch is gone. The leading part of the sine wave is flattened by the rising gain of the attack.故障消失了。 正弦波的前导部分因攻击增益的上升而变平。
附上文件。 在 Windows 上,它使用多媒体 DLL 中的 PlaySound。 顶部有几个开关。 它没有使用任何 FM 代码,我想得越多,它可能实现的是相位调制而不是频率调制。 除了这个演示,它还没有准备好。