多重振幅淡入淡出在 ecasound 上如何工作?

发布于 2024-11-28 03:58:12 字数 2702 浏览 1 评论 0原文

我想在特定的时间代码淡入和淡出曲目。例如,我想要一个音频文件,并且:

Start it at 100% Volume 
Fade it to 20%  at 2 seconds
Fade it to 100% at 4 seconds
Fade it to 20%  at 6 seconds
Fade it to 100% at 8 seconds
Fade it to 20%  at 10 seconds
Fade it to 100% at 12 seconds
Fade it to 0 at 14 seconds

我一直在使用 ecasound 生成的恒定音调对此进行测试,以便我可以在 Audacity 中打开生成的文件并直观地查看结果。据我所知,增加振幅是相对的,而减少振幅则不是。似乎如果我将幅度淡入淡出,它会影响整个音轨的相对音量,而不仅仅是在我设置淡入淡出的特定时间,这就是我迷失的地方。

示例命令

# generate the tone
ecasound -i tone,sine,880,20 -o:tone.wav

# Just the test to see that i can fade start it at 100 and fade it to 20.
ecasound -a:1 -i tone.wav -ea:100 -kl2:1,100,20,2,1 -a:all -o:test_1.mp3

# Fade it out and in
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,100,20,2,1 \
         -ea:100 -kl2:1,20,100,4,1 \
         -a:all -o:test_2.mp3

# Fade it out and in with a peak of 500
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,100,20,2,1 \
         -ea:100 -kl2:1,20,500,4,1 \
         -a:all -o:test_3.mp3

# Fade it out from 500, out, and then back to 500
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,500,20,2,1 \
         -ea:100 -kl2:1,20,500,4,1 \
         -a:all -o:test_4.mp3

# Fade it out from 500, out to a low of 10, and then back to 500
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,500,10,2,1 \
         -ea:100 -kl2:1,10,500,4,1 \
         -a:all -o:test_5.mp3

# Fade it out from 1000, out to a low of 10, and then back to 1000
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,1000,10,2,1 \
         -ea:100 -kl2:1,10,1000,4,1 \
         -a:all -o:test_6.mp3

# The eventual result I'm looking for
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,500,20,2,1 \
         -ea:100 -kl2:1,20,500,4,1 \
         -ea:100 -kl2:1,500,20,6,1 \
         -ea:100 -kl2:1,20,500,8,1 \
         -ea:100 -kl2:1,500,20,10,1 \
         -ea:100 -kl2:1,20,500,12,1 \
         -ea:100 -kl2:1,500,0,14,4 \ 
         -a:all -o:test_7.mp3

结果

在此处输入图像描述

从这些结果中我能看出的最好信息是整个轨道的幅度是相对的所有褪色效果的低点和峰值之间的差异。我不确定这个结果是否符合预期,但它非常令人困惑。

此外,在最后一个结果(图像中倒数第二个)中,淡入淡出不再需要整整一秒。为了找出原因,我关闭了最后的淡入淡出到零,并且持续时间恢复正常。这似乎不像预期的行为。

# "Fixing" the fade durations
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,500,20,2,1 \
         -ea:100 -kl2:1,20,500,4,1 \
         -ea:100 -kl2:1,500,20,6,1 \
         -ea:100 -kl2:1,20,500,8,1 \
         -ea:100 -kl2:1,500,20,10,1 \
         -ea:100 -kl2:1,20,500,12,1 \
         -a:all -o:test_8.mp3

作为旁注,我还尝试将每行的 -ea 值更改为“当前”幅度。它没有任何区别(无论我将 -ea 设置为什么)

我从 git 安装了最新版本(2.8.1+dev)。我在 2.7.0 上也遇到了同样的问题,这就是我升级并最终发现自己在这里的原因。

我这样做错了吗?

I want to fade a track in and out at specific time codes. For example, I would like to take an audio file, and:

Start it at 100% Volume 
Fade it to 20%  at 2 seconds
Fade it to 100% at 4 seconds
Fade it to 20%  at 6 seconds
Fade it to 100% at 8 seconds
Fade it to 20%  at 10 seconds
Fade it to 100% at 12 seconds
Fade it to 0 at 14 seconds

I've been testing this with a constant tone generated by ecasound so that I can open the resulting file in Audacity and see the results visually. As far as I can tell, increasing the amplitude is relative, while decreasing it is not. It seems that if I fade the amplitude up, it affects the relative volume of the whole track and not just at the specific time I set the fade, which is where I'm getting lost.

Example commands

# generate the tone
ecasound -i tone,sine,880,20 -o:tone.wav

# Just the test to see that i can fade start it at 100 and fade it to 20.
ecasound -a:1 -i tone.wav -ea:100 -kl2:1,100,20,2,1 -a:all -o:test_1.mp3

# Fade it out and in
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,100,20,2,1 \
         -ea:100 -kl2:1,20,100,4,1 \
         -a:all -o:test_2.mp3

# Fade it out and in with a peak of 500
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,100,20,2,1 \
         -ea:100 -kl2:1,20,500,4,1 \
         -a:all -o:test_3.mp3

# Fade it out from 500, out, and then back to 500
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,500,20,2,1 \
         -ea:100 -kl2:1,20,500,4,1 \
         -a:all -o:test_4.mp3

# Fade it out from 500, out to a low of 10, and then back to 500
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,500,10,2,1 \
         -ea:100 -kl2:1,10,500,4,1 \
         -a:all -o:test_5.mp3

# Fade it out from 1000, out to a low of 10, and then back to 1000
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,1000,10,2,1 \
         -ea:100 -kl2:1,10,1000,4,1 \
         -a:all -o:test_6.mp3

# The eventual result I'm looking for
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,500,20,2,1 \
         -ea:100 -kl2:1,20,500,4,1 \
         -ea:100 -kl2:1,500,20,6,1 \
         -ea:100 -kl2:1,20,500,8,1 \
         -ea:100 -kl2:1,500,20,10,1 \
         -ea:100 -kl2:1,20,500,12,1 \
         -ea:100 -kl2:1,500,0,14,4 \ 
         -a:all -o:test_7.mp3

The Results

enter image description here

The best I can tell from these results is that the amplitude of the whole track is relative to the difference between the low and the peak of all the fading effects. I'm not sure if this result is expected, but it's very confusing.

Also, in the last result (second to last in the image), the fades are no longer taking a full second each. In order to figure out why that may be, I took the final fade-to-zero off and the durations were back to normal. This does not seem like expected behavior.

# "Fixing" the fade durations
ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,500,20,2,1 \
         -ea:100 -kl2:1,20,500,4,1 \
         -ea:100 -kl2:1,500,20,6,1 \
         -ea:100 -kl2:1,20,500,8,1 \
         -ea:100 -kl2:1,500,20,10,1 \
         -ea:100 -kl2:1,20,500,12,1 \
         -a:all -o:test_8.mp3

As a side note, I've also tried changing the -ea values to the "current" amplitude with every line. It didn't make any difference (no matter what I set -ea to)

I have the very latest installed from git (2.8.1+dev). I had these same issues with 2.7.0, which is why I upgraded and eventually found myself here.

Am I doing this wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听闻余生 2024-12-05 03:58:12

-kl2

经过几个小时的绞尽脑汁,我终于想通了。每个淡入淡出的“From”幅度需要为 100。如果要增加幅度,“To”幅度为最大/从 * 到

因此,如果您尝试从 20 增加到 100,则为 100 / 20 * 100500。如果您想达到 120:100 / 20 * 120600。我认为这对某人来说是完全有道理的,但我完全被难住了。

工作示例(中间有一个稍高的底部范围来演示):

ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,100,20,2,1 \
         -ea:100 -kl2:1,100,500,4,1 \
         -ea:100 -kl2:1,100,40,6,1 \
         -ea:100 -kl2:1,100,250,8,1 \
         -ea:100 -kl2:1,100,20,10,1 \
         -ea:100 -kl2:1,100,500,12,1 \
         -ea:100 -kl2:1,100,0,14,1 \
         -a:all -o:test_7.mp3

输出:
在此处输入图像描述

请记住,这些幅度仍然是相对的。如果您要从 45% 降至 90%:100 / 45 * 90 = 200,然后现在如果您降至当前幅度的 20%,则实际上是 18% (.20 * 90 ),所以回到 100 将是 100 / 18 * 100 = 555.56

-klg

正如我所想这篇文章出来了,来到这里发帖,我收到了来自 ecasound 邮件列表的回复。它不是对 kl2 问题的直接答案,而是提供了另一种更容易理解的答案,即 klg 参数。

-klg:fx-param,低值,高值,point_count,pos1,value1,...,posN,valueN
通用线性包络。该控制器源可用于映射
自定义信封到链操作符参数。信封数量
点在“point_count”中指定。每个包络点包括
位置和匹配值。对数必须匹配
'point_count'(即'N==point_count')。给出了“posX”参数
以秒为单位(从流开始算起)。包络点是
指定为“[0,1]”范围内的浮点值。在包络值之前
映射到操作员参数,它们被映射到的目标范围
'[低值,高值]'。例如,值“0”将设置运算符
参数设置为“low-value”,值为“1”时会将其设置为
“高价值”。对于初始段“[0,pos1]”,信封将
“value1”的输出值(例如“low-value”)。

以下是使用 klg 而不是 kl2 执行我需要的命令:

ecasound -a:1 -i:tone.wav -ea:100 \
-klg:1,0,100,14,2,1,3,0.20,4,0.20,5,1,6,1,7,0.40,8,0.40,9,1,10,1,11,0.20,12,0.20,13,1,14,1,15,0 \
-o:test.mp3

输出与图像上的第二条轨道完全相同。

由此产生的命令行肯定有点难以阅读和调试,但实际上可能更容易动态生成。无论如何,我现在有两个工作选择来解决这个问题。

最后,这是我如何计算出 klg 命令坐标的注释。星号是 klg 参数中列出的“点”,顶部的数字是秒:

     0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2
     1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
1.0  --*     *-*     *-*     *-*   
 ~      \   /   \._./   \   /   \
0.2      *-*             *-*     \
0.0                              *----------

我希望这可以帮助某人至少节省我因挠头而失去的头发量。

-kl2

After a few hours of head scratching, I finally think I have it figured out. The "From" amplitude on every fade needs to be 100. If you are increasing the amplitude, the "To" amplitude is maximum / from * to.

So if you're trying to go from 20 to 100, it's 100 / 20 * 100 or 500. If you're trying to get to 120: 100 / 20 * 120 or 600. I assume this all makes perfect sense to someone, but I was perfectly stumped.

The working example (with a slightly higher bottom range in the middle to demonstrate):

ecasound -a:1 -i tone.wav \
         -ea:100 -kl2:1,100,20,2,1 \
         -ea:100 -kl2:1,100,500,4,1 \
         -ea:100 -kl2:1,100,40,6,1 \
         -ea:100 -kl2:1,100,250,8,1 \
         -ea:100 -kl2:1,100,20,10,1 \
         -ea:100 -kl2:1,100,500,12,1 \
         -ea:100 -kl2:1,100,0,14,1 \
         -a:all -o:test_7.mp3

And the output:
enter image description here

Keep in mind that these amplitudes are still relative. If you're going from 45% to 90%: 100 / 45 * 90 = 200, and then now if you drop to 20% of the current amplitude, it's actually 18% (.20 * 90), so going back to 100 would be 100 / 18 * 100 = 555.56

-klg

Just as I figured this out, and came here to post, I received a response from the ecasound mailing list. It's not a direct answer to the kl2 issue, but offers an alternative, easier-on-the-brain answer, which is the klg parameter.

-klg:fx-param,low-value,high-value,point_count,pos1,value1,...,posN,valueN
Generic linear envelope. This controller source can be used to map
custom envelopes to chain operator parameters. Number of envelope
points is specified in 'point_count'. Each envelope point consists of
a position and a matching value. Number of pairs must match
'point_count' (i.e. 'N==point_count'). The 'posX' parameters are given
as seconds (from start of the stream). The envelope points are
specified as float values in range '[0,1]'. Before envelope values are
mapped to operator parameters, they are mapped to the target range of
'[low-value,high-value]'. E.g. a value of '0' will set operator
parameter to 'low-value' and a value of '1' will set it to
'high-value'. For the initial segment '[0,pos1]', the envelope will
output value of 'value1' (e.g. 'low-value').

Here's the command to do what I need using klg instead of kl2:

ecasound -a:1 -i:tone.wav -ea:100 \
-klg:1,0,100,14,2,1,3,0.20,4,0.20,5,1,6,1,7,0.40,8,0.40,9,1,10,1,11,0.20,12,0.20,13,1,14,1,15,0 \
-o:test.mp3

The output is exactly the same as the 2nd track on the image.

This resulting command line is definitely a bit harder to read and hence debug, but may actually be easier to generate dynamically. Regardless, I now have 2 working options to resolve this problem.

And finally, here are my notes for how I figured out the coordinates of the klg command. The asterisks are the "points" which are listed in the klg parameter, the numbers at the top are seconds:

     0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2
     1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
1.0  --*     *-*     *-*     *-*   
 ~      \   /   \._./   \   /   \
0.2      *-*             *-*     \
0.0                              *----------

I hope this helps someone save at least the amount of hair that i've lost scratching my head.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文