开发者

adding "audible ticks" to a waveform for onset detection debugging

开发者 https://www.devze.com 2022-12-08 23:19 出处:网络
I\'m playing around with some onset/beat detection algorithms on my own.开发者_JAVA百科 My input is a .wav file and my output is a .wav file; I have access to the entire waveform in chunks of float[]

I'm playing around with some onset/beat detection algorithms on my own.开发者_JAVA百科 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.


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;
}


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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消