提取使用HTML5网页音频API一个mp3文件的歌曲频率 [英] Extracting the song frequency of an mp3 file using HTML5 web audio API

查看:1216
本文介绍了提取使用HTML5网页音频API一个mp3文件的歌曲频率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是HTML5网页音频API来分析一首歌曲,当平均声频率低于一定值创建标记。利用现有的基础设施AudioNode,我设法做到这一点,但仅仅当歌曲播放的声音进行了分析。

I am using the HTML5 web audio API to analyse a song and create markers when the average sound frequency drops below a certain value. Using the existing AudioNode infrastructure, I managed to do this but the sound is analyzed only and only when the song is played.

不过是什么我想,是分析歌曲提前,这样我就可以提取沉默标记,并将其转化为CUE按钮,用户可以用它来在歌曲中移动

What I want however, is to analyse the song in advance, so I can extract the silence markers, and turn them into CUE buttons, which the user can use to move throughout the song.

显然,这将是非常缓慢的依靠播放整首歌曲在第一,以分析它,尤其是,如果这首歌是像一个50分钟的播客。我试图加快playbackRate 10倍,但这并不能帮助。

Obviously, it will be very slow to rely on playing the whole song at first, in order to analyse it, especially, if the song is something like a 50 min podcast. I tried speeding up the playbackRate to 10x, but that doesn't help.

我认为,解决办法在于跳过网络音频API,并分析原始ArrayBuffer,但是,我真的不知道从哪里开始。

I suppose that the solution lies in skipping the Web audio API, and analyzing the raw ArrayBuffer, however, I don't really know where to start from.

建议?想法?

推荐答案

我已经能够在其中找到确切地描述这样的presentation幻灯片:<一href=\"http://html5-demos.appspot.com/static/whats-new-with-html5-media/template/index.html#45\">here

I have been able to find a slide in a presentation which describes exactly this: here

正常使用的API是处理实时音频。相反,我们可以pre-处理的声音通过整个系统,并得到结果是:

Normal use of the API is to process audio in real-time. Instead, we can pre-process the audio through the entire system and get result:

唯一的问题是,我的音频API的理解过于简单化,看看有什么绝招是从code样品:<​​/ P>

The only problem is that my understanding of the audio API is too simplistic to see what the 'trick' is from the code sample:

var sampleRate = 44100.0;
var length = 20; // seconds
var ctx = new webkitAudioContext(2, sampleRate * length, sampleRate);
ctx.oncomplete = function(e) {
  var resultAudioBuffer = e.renderedBuffer;
  ...
};

function convolveAudio(audioBuffer, audioBuffer2) {
  var source = ctx.createBufferSource();
  var convolver = ctx.createConvolver();
  source.buffer = audioBuffer;
  convolver.buffer = audioBuffer2;

  // source -> convolver -> destination.
  source.connect(convolver);
  convolver.connect(ctx.destination);

  source.noteOn(0);
  ctx.startRendering();
}

不过,我认为这将是更好的,至少分享这不是离开它完全,即使这不正是我希望能给出答案。

But I thought it would be better to at least share this than to leave it be entirely, even if this isn't exactly the answer I was hoping to give.

这篇关于提取使用HTML5网页音频API一个mp3文件的歌曲频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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