添加“滴答声”到波形以进行起始检测调试

发布于 2024-08-08 05:31:26 字数 243 浏览 5 评论 0原文

我正在自己尝试一些起始/节拍检测算法。我的输入是 .wav 文件,输出是 .wav 文件;我可以访问 float[] 数组块中的整个波形。

我无法找到调试和评估算法的好方法。由于我的输入和输出都是听觉的,因此我认为如果我的调试工具也是听觉的,那将是最有意义的,例如。通过在 .wav 文件的起始点添加可听见的“滴答声”或“嘟嘟声”。

有人对如何做到这一点有任何想法吗?理想情况下,这将是一个简单的 for 循环,我可以运行数百或数千个样本。

I'm playing around with some onset/beat detection algorithms on my own. My input is a .wav file and my output is a .wav file; I have access to the entire waveform in chunks of float[] arrays.

I'm having trouble coming up with a good way to debug and evaluate my algorithms. Since my input and output are both auditory, I thought it'd make the most sense if my debugging facility was also auditory, eg. by means of adding audible "ticks" or "beeps" to the .wav file at onset points.

Does anyone have any ideas on how to do this? Ideally, it would be a simple for-loop that I'd run a couple hundred or couple thousand samples through.

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

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

发布评论

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

评论(3

网白 2024-08-15 05:31:26
float * sample = first sample where beep is to be mixed in
float const beep_duration = desired beep duration in seconds
float const sample_rate = sampling rate in samples per second
float const frequency = desired beep frequency, Hz
float const PI = 3.1415926..
float const volume = desired beep volume
for( int index = 0; index < (int)(beep_duration * sample_rate); index++ )
{
   sample[index] += 
      sin( float(index) * 2.f * PI * sample_rate / frequency ) * volume;
}
float * sample = first sample where beep is to be mixed in
float const beep_duration = desired beep duration in seconds
float const sample_rate = sampling rate in samples per second
float const frequency = desired beep frequency, Hz
float const PI = 3.1415926..
float const volume = desired beep volume
for( int index = 0; index < (int)(beep_duration * sample_rate); index++ )
{
   sample[index] += 
      sin( float(index) * 2.f * PI * sample_rate / frequency ) * volume;
}
烟燃烟灭 2024-08-15 05:31:26

穷人的答案:找到滴答声或嘟嘟声的录音,然后在每个所需时刻将其与原始波形混合。您只需对蜂鸣声持续时间内的蜂鸣声值和输入波形进行平均即可进行混音。

Poor man's answer: find a recording of a tick or beep, then mix it with the original waveform at each desired moment. You mix by simply averaging the values of the beep and the input waveform for the duration of the beep.

帅气称霸 2024-08-15 05:31:26

找出您想要在样本中插入刻度的位置(包括刻度的长度,因此这是一个范围,而不是点)。对波形的该部分进行FFT。将您想要的“滴答声”声音的任何频率分量添加到频域表示中(最简单的是单个频率音调)。对结果执行逆 FFT,瞧,您的音调已混合到原始信号中。我想(自从我这样做以来已经有一段时间了)。

Figure out where in your sample you want to insert your tick (include the length of the tick, so this is a range, not a point). Take the FFT of that section of the waveform. Add to the frequency domain representation whatever frequency components you desire for your "tick" sound (simplest would be just a single frequency tone). Perform the inverse FFT on the result and voila, you have your tone mixed into the original signal. I think (it's been a while since I've done this).

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