利用使用SoX改变的范围内时的音量的音频文件 [英] Using SoX to change the volume level of a range of time in an audio file

查看:2784
本文介绍了利用使用SoX改变的范围内时的音量的音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用使用SoX更改音频文件中的特定时间段/片的音量。

I’d like to change the volume level of a particular time range/slice in an audio file using SoX.

现在,我不得不


  1. 修剪原始文件三次获得:音频效果变化之前的部分,在部分(这里我改变音量),以及之后的部分

  2. 执行效果来改变音量音频的提取中大块,在它自己的文件

  3. 通联一切重新走到一起,考虑到衰落/淡入淡出5ms的重叠是使用SoX建议

有没有更好的方式来做到这一点,这并不涉及编写一个脚本来完成上述?

Is there a better way to do this that doesn’t involve writing a script to do the above?

推荐答案

对于任何人谁碰到这个高度排线绊倒,寻找一种方式,以鸭子的音频文件的中间:

For anyone who stumbles across this highly ranked thread, searching for a way to duck the middle of an audio file:

我一直在玩Sox为年龄和我建立的方法使用管道来处理每一个部分的没有的创建所有的临时文件!

I've been playing with SoX for ages and the method I built uses pipes to process each part without creating all those temporary files!

结果是一个单一的在线解决方案,但你需要设定时间,因此,除非你的淡出时机将所有文件一样,它可能是有益的生成算法行了。

The result is a single line solution, though you will need to set timings and so, unless your fade timings will be the same for all files, it may be useful to generate the line with an algorithm.

我很高兴得到管道的工作,因为我知道这方面已经证明很难为别人着想。命令行选项可能很难得到正确。但我真的不喜欢杂乱的其他文件作为替代。

I was pleased to get piping working, as I know this aspect has proved difficult for others. The command line options can be difficult to get right. However I really didn't like the messy additional files as an alternative.

通过使用混合的功能和定位各部分使用垫,然后给每个部分修剪和放大器;淡出我们也可避免使用'拼接'在这里的。我真的不是一个球迷。

By using mix functionality and positioning each part using pad, then giving each section trim & fade we can also avoid use of 'splice' here. I really wasn't a fan.

一个正常工作的单线例如,在使用SoX 14.4.2测试的Windows:

A working single line example, tested in SoX 14.4.2 Windows:

它消失(鸭)由-6dB在2秒,5秒钟后将返回到0dB(使用0.4秒线性渐变):

It fades (ducks) by -6dB at 2 seconds, returning to 0dB at 5 seconds (using linear fades of 0.4 seconds):

sox -m -t wav "|sox -V1 inputfile.wav -t wav - fade t 0 2.2 0.4" -t wav "|sox -V1 inputfile.wav -t wav - trim 1.8 fade t 0.4 3.4 0.4 gain -6 pad 1.8" -t wav "|sox -V1 inputfile.wav -t wav - trim 4.8 fade t 0.4 0 0 pad 4.8" outputfile.wav gain 9.542

让我们做一个稍微更可读这里由它分解成几个部分:

Let's make that a little more readable here by breaking it down into sections:

第1节=全卷,第2 =躲开,第3节=全卷

Section 1 = full volume, Section 2 = ducked, Section 3 = full volume

sox -m
    -t wav "|sox -V1 inputfile.wav -t wav - fade t 0 2.2 0.4" 
    -t wav "|sox -V1 inputfile.wav -t wav - trim 1.8 fade t 0.4 3.4 0.4 gain -6 pad 1.8"
    -t wav "|sox -V1 inputfile.wav -t wav - trim 4.8 fade t 0.4 0 0 pad 4.8"
    outputfile.wav gain 9.542

现在,要打破它,非常彻底地

Now, to break it down, very thoroughly

-m '..说我们要混合(这自动降低增益,见最后参数)

'-m' .. says we're going to mix (this automatically reduces gain, see last parameter)

-t WAV '..说下面会返回一个WAV的管道命令(看来WAV头在管道中丢失)

'-t wav' .. says the piped command that follows will return a WAV (it seems the WAV header is being lost in the pipeline)

然后..第一管道部分(鸭前最大音量)

Then.. the FIRST piped part (full volume before duck)

-V1 '..说忽略警告 - 会有一个关于不知道输出文件的长度为这个特定的部分,因为它的管道出警告,但应该是从这个没有其他的警告操作

'-V1' .. says ignore warnings - there will be a warning about not knowing length of output file for this specific section as it's piping out, but there should be no other warning from this operation

然后输入文件名

-t WAV '..强制输出型

- '..是标准名称管道输出将返回SOX法案的命令行

'-' .. is the standard name for a piped output which will return to SoX command line

淡出T 0的2.2 0.4 '..淡出全卷部分。 T =线性。 0淡入,然后(我们想要的交叉淡入淡出的中间点是在2秒),我们淡出了2.2秒,0.4秒的淡入淡出(淡出参数是当褪色完!)

'fade t 0 2.2 0.4' .. fades out the full volume section. t = linear. 0 fade in. Then (as we want the crossfade's halfway point to be at 2 seconds) we fade out by 2.2 seconds, with a 0.4 second fade (the fadeout parameter is for when the fade ENDS!)

-t WAV '..劝下一部分的类型 - 如上

'-t wav' .. to advise type of next part - as above

然后..第二管道部分(躲开部分)

Then.. the SECOND piped part (the ducked section)

-V1 '..再次,忽略输出长度警告 - 见上
然后在相同的输入的文件名

'-V1' .. again, to ignore output length warning - see above then the same input filename

-t WAV '..力量输出类型,如上面

'-t wav' .. forces output type, as above

- '。对于管道输出,见上

'-' .. for piped output, see above

修剪1.8 '..因为这中间部分将达到过渡的中间以2秒左右(以0.4秒的淡入淡出)的躲开了音频文件将在此之前开始0.2秒

'trim 1.8' .. because this middle section will hit the middle of the transition at 2 seconds, so (with a 0.4 second crossfade) the ducked audio file will start 0.2 seconds before that

褪色牛逼0.4 3.4 0.4 '。在躲开节&放褪色;淡出退了出去一次。因此,一个0.4淡入,然后(最复杂的部分)作为下一个交叉淡入淡出将在5.2秒结束,我们必须采取这一数字减去修剪量本节,所以5.2-1.8 = 3.4(这同样是因为与淡出位置交易淡出的结束时间)

'fade t 0.4 3.4 0.4' .. to fade in the ducked section & fade back out again. So a 0.4 fade in. Then (the most complicated part) as the next crossfade will end at 5.2 seconds we must take that figure minus trimmed amount for this section, so 5.2-1.8=3.4 (again this is because fadeout position deals with the end timing of the fadeout)

获得-6 '..是的金额,以dB为单位,通过我们应该鸭

'gain -6' .. is the amount, in dB, by which we should duck

垫1.8 '..修剪上图中,这样的沉默这一数额被插入在开始使其同步时,部分混合必须匹配

'pad 1.8' .. must match the trim figure above, so that amount of silence is inserted at the start to make it synch when sections are mixed

-t WAV '..劝下一部分的类型 - 如上

'-t wav' .. to advise type of next part - as above

然后。第三部分管道(返回到满级)

Then.. the THIRD piped part (return to full level)

-V1 '..再 - 见上面

'-V1' .. again - see above

那么同一个输入文件名

-t WAV '..强制输出类型,如上面

-t wav' .. to force output type, as above

- '。对于管道输出,见上

-' .. for piped output, see above

修剪4.8 '..最后一节将在5秒内开机,但(有0.4秒的交叉淡入淡出),音频将之前开始0.2秒

trim 4.8' .. this final section will start at 5 seconds, but (with a 0.4 second crossfade) the audio will start 0.2 seconds before that

淡出牛逼0.4 0 0 '..只是淡入这个最大音量部分。没有淡出

'fade t 0.4 0 0' .. just fade in to this full volume section. No fade out

垫4.8 '..必须修剪上图中,匹配如上所述
然后输出文件名

'pad 4.8' .. must match the trim figure above, as explained above then output filename

获得9.542 '..看起来非常棘手,但基本上当你-m混合3个文件的体积缩小到1/3(三分之一)通过使用SoX给予空间。

'gain 9.542' .. looks tricky, but basically when you "-m" to mix 3 files the volume is reduced to 1/3 (one third) by SoX to give headroom.

而不是拆台,我们提高到300%。我们得到的9.542 dB的量与这个公式20 *日志(3)/日志(10)

Rather than defeating that, we boost to 300%. We get the dB amount of 9.542 with this formula 20*log(3)/log(10)

如果您复制和放大器;粘贴单行的地方,你可以很容易地都看到它,它比解释少了很多可怕的!

If you copy & paste the single line somewhere you can see it all easily, it's a lot less scary than the explanation!

最后,虽然 - 我最初关注的淡入淡出是否需要是对数而不是线性的,但在我的情况下,从听,结果线性肯定已经给我所期望的声音

Final though - I was initially concerned about whether the crossfades needed to be logarithmic rather than linear, but in my case from listening to the results linear has definitely given the sound I expected.

您可能会想尝试再淡入淡出,或者有过渡点以前或以后发生的事情,但我希望单行给希望任何人谁想到许多临时文件将需要!

You may like to try longer crossfades, or have the point of transition happening earlier or later but I hope that single line gives hope to anyone who thought many temporary files would be required!

让我知道,如果更多的澄清有助于!

Let me know if more clarification would help!

大胆波形

这篇关于利用使用SoX改变的范围内时的音量的音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆