Anaconda豪华轿车:吉他零件

I'm part of a band that has an album out now. I know, right? (links: excuse-for-a-site, amazon, itunes).

我是现在有专辑的乐队的一部分。 我知道,对吧? (链接:网站的借口亚马逊iTunes )。

I wanted to put up all the songs on the site, but seems like there's a little dissonance in the band whether this is a good idea. Plan B: 30s samples. Like the bigwigs do on Amazon and iTunes.

我想把网站上的所有歌曲都放好,但是乐队里似乎有点不和谐,这是否是个好主意。 计划B:30秒样本。 就像亚马逊和iTunes上的大佬一样。

But while their samples are random, a band can do a better job in picking parts that are representative of the overall sound. I though - let me pick my solo stuff only as an exercise. So there: Anaconda Limousine: the guitar parts.

但是,尽管它们的样本是随机的,但是乐队可以在挑选代表整体声音的部分方面做得更好。 我虽然-让我只选择自己的东西作为练习。 在那里: Anaconda Limousine:吉他零件

I wanted to use command-line ffmpeg, of course, because all music software is like Photoshop to me, just can't figure out what's going on with so much UI. Turned out I needed sox too.

当然,我想使用命令行ffmpeg ,因为所有音乐软件对我来说都像Photoshop,只是无法弄清楚这么多UI的情况。 原来我也需要

And then I want to use HTML5 Audio to play the samples.

然后,我想使用HTML5 Audio播放示例。

I thought: an audio sprite would be a good idea, put all samples in one file, then JS can update the UI depending on which sample is playing. And I thought might be neat to have the JS turn the volume up and down to fade in/out the samples, like iTunes does. Turns out sox is doing this so nicely, that I let it do it.

我认为:音频精灵是个好主意,将所有示例放在一个文件中,然后JS可以根据正在播放的示例来更新UI。 而且我认为让JS像iTunes一样上下调音量以淡入/淡出样本可能是一件好事。 原来sox做得很好,我就让它做。

样品 (Samples)

I started by listening to the songs and taking notes with song #, start and end.

我先听歌曲,然后用歌曲#做笔记,然后开始和结束。

var slices = [
  {song: 1,  start:   8, end:  21},
  {song: 1,  start: 301, end: 323}, // from 3:01 to 3:23
  {song: 1,  start: 405, end:   0}, // 0 means till the end
  {song: 2,  start:   0, end:  30},
  {song: 2,  start: 305, end: 318},
  {song: 2,  start: 330, end:   0},
  {song: 3,  start:   0, end:  20},
  {song: 3,  start: 333, end:   0},
  {song: 4,  start: 303, end:   0},
  {song: 5,  start:   0, end:  20},
  {song: 5,  start: 300, end: 333},
  {song: 7,  start:   0, end:  20},
  {song: 7,  start: 340, end:   0},
  {song: 8,  start:   0, end:  25},
  {song: 8,  start: 313, end:   0},
  {song: 9,  start: 155, end: 239},
  {song: 9,  start: 350, end:   0}
];

Start 0 means start from the beginning of the song, end 0 means go to the end.

开头0表示从歌曲的开头开始,结尾0表示转到歌曲的结尾。

The time format is optimized for easy typing (I was walking, typing in Notes app on the iPhone). Turned out I need to convert the times to seconds:

时间格式经过了优化,易于键入(我在步行,在iPhone上的Notes应用中键入)。 原来我需要将时间转换为秒:

function secs(num) {
  if (num <= 60) {
    return 1 * num
  }
  num += '';
  return num[0] * 60 + num[1] * 10 + num[2] * 1;
}

And I need album meta data too, with name of the song, filename and duration:

我还需要专辑元数据,以及歌曲名称,文件名和时长:

 
var songs = [
  {name: "Virus",     fname: "01-virus",     duration: 436},
  {name: "Yesterday", fname: "02-yesterday", duration: 346},
  {name: "All for you", fname: "03-all4u",   duration: 404},
  {name: "Damage",    fname: "04-damage",    duration: 333},
  {name: "Everyday",  fname: "05-everyday",  duration: 444},
  {name: "Girl of mine", fname: "06-girlomine", duration: 338},
  {name: "Fool on the hill", fname: "07-fool",  duration: 413},
  {name: "Faultline", fname: "08-faultline", duration: 347},
  {name: "Parting is such sweet sorrow", 
                      fname: "09-parting",   duration: 420}
];

翻录专辑 (Ripping the album)

In the interest of quality I wanted to work with WAV and then encode in m4a, ogg and mp3.

为了提高质量,我想使用WAV,然后以m4a,ogg和mp3编码。

On TuneCore.com there's a nice step-by-step instruction how to rip a CD to WAV in iTunes, because it uses mp3 by default.

在TuneCore.com上,有一个很好的分步说明,说明如何在iTunes中将CD翻录为WAV,因为默认情况下它使用mp3。

So then I had the files:

所以我有了这些文件:

01-virus.wav
02-yesterday.wav
03-all4u.wav
04-damage.wav
05-everyday.wav
06-girl.wav
07-fool.wav
08-faultline.wav
09-parting.wav

切片和褪色 (Slicing and fading)

I used ffmpeg to do the slicing, like for example the first sample:

我使用ffmpeg进行切片,例如第一个示例:

$ ffmpeg -i 01-virus.wav -ss 5 -t 20 ff-0.wav

$ ffmpeg -i 01-virus.wav -ss 5 -t 20 ff-0.wav

-ss is start time and -t is duration. As you see instead of starting at 8 seconds (as described in the samples array) I start earlier. This is to give some more music for fade in/out.

-ss是开始时间, -t是持续时间。 如您所见,而不是从8秒开始(如示例数组中所述),我开始得更早。 这将为淡入/淡出提供更多音乐。

For fade in/out I used sox. I didn't know this awesome command line tool existed, but found out while searching how to combine wav files (I know for mp3 you can just `cat`)

为了淡入/淡出,我使用了sox 。 我不知道这个真棒命令行工具的存在,但是在搜索如何组合wav文件时发现了(我知道对于mp3,你可以只用`cat` )

I don't want to fade in when the sample starts at the beginning. Or fade out then the sample happens to end at the end of the song. sox takes fade-in duration (or 0 for no fade in), stop time (0 for till the end of the file/sample) and fade out duration (again 0 is no fade out)

我不想在样本开始时淡入淡出。 或者淡出,然后样本恰好在歌曲结尾处结束。 sox需要淡入时间(或0表示没有淡入),停止时间(0直到文件/样本结束)和淡出时间(再次0表示不淡出)。

I used 3 secods fade in, 4 fade out. The sox commands are one of:

我使用3秒渐强,4次渐弱。 sox命令是以下之一:

$ sox in.wav out.wav fade 3 0 0
$ sox in.wav out.wav fade 3 0 4
$ sox in.wav out.wav fade 0 0 4

And since I have all the configs in JS, JS makes perfect sense to generate the commands. Hope you can make sense of the comments:

而且由于我具有JS中的所有配置,因此JS生成命令非常有意义。 希望您能理解这些评论:

var fadein = 3;
var fadeout = 4;
var merge = ['sox'];
slices.forEach(function(s, index){
  var ff = ['ffmpeg -i'];
  ff.push(songs[s.song - 1].fname  + '.wav'); // in file
  ff.push('-ss');
  ff.push(s.start ? secs(s.start) - fadein : 0); // start of the slice
  ff.push('-t');
  ff.push(!s.end ? 
      1000 : 
      secs(s.end) - secs(s.start) + fadein + fadeout); // end slice
  ff.push('ff-' + index  + '.wav'); // out file
  
  var sox = ['sox'];
  sox.push('ff-' + index  + '.wav'); // in file
  sox.push('s-' + index  + '.wav'); // out file
  sox.push('fade');
  sox.push(s.start ? fadein : 0); // fade in, unless it;s the beginning of the song
  sox.push(0); // till the end of the slice
  sox.push(s.end ? fadeout : 0); // fade out unless it's The End
    
  console.log(ff.join(' '));
  console.log(sox.join(' '));
  
  merge.push('s-' + index  + '.wav');
});
 
merge.push('_.wav');
console.log(merge.join(' '));

Running this gives me a bunch of commands:

运行此命令可以给我很多命令:

ffmpeg -i 01-virus.wav -ss 5 -t 20 ff-0.wav
sox ff-0.wav s-0.wav fade 3 0 4
ffmpeg -i 01-virus.wav -ss 178 -t 29 ff-1.wav
sox ff-1.wav s-1.wav fade 3 0 4
[....]

sox s-0.wav s-1.wav s-2.wav s-3.wav [...] s-16.wav _.wav

2 for each sample (slice and fade) and one last one to merge all faded results. Nothing left to do but run the generated commands.

每个样本2个(切片和淡入淡出),最后一个合并所有淡入淡出的结果。 除了运行生成的命令,别无所要做。

保存为网络 (Save for Web)

Final step is to convert the result _.wav to a web-ready format: m4a, ogg or mp3:

最后一步是将结果_.wav转换为可用于Web的格式:m4a,ogg或mp3:

$ ffmpeg -i _.wav _.m4a
$ ffmpeg -i _.wav _.mp3
$ ffmpeg -i _.wav -acodec vorbis -aq 60 -strict experimental _.ogg

打开它! (Turn it up!)

Enjoy Anaconda Limousine: The Guitar Parts (ogg, m4a or mp3) with all samples in one file.

享受Anaconda Limousine:吉他零件( oggm4amp3 ),所有样本都放在一个文件中。

And come back later for the JS player part.

稍后再返回JS播放器部分。

See you!

再见!

Tell your friends about this post on Facebook and Twitter

FacebookTwitter上告诉您的朋友有关此帖子的信息

翻译自: https://www.phpied.com/anaconda-limousine-the-guitar-parts/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值