如果我将一系列频率蜂鸣声记录到缓冲区中,例如:
15kHz 持续 50ms,17k 持续 50ms 并继续,有没有办法沿着时间“走”并解码这个频率(用 goertzel 或其他东西)?
嘿,这是一个更新,我添加了一个代码,显示如何在我检查的声音缓冲区中找到第一个分隔符。如果我记录 5 秒的缓冲区(我记录到流缓冲区而不是文件中)第一个片段需要大约 30 秒来分析起始分隔符开始的索引。我认为这是非常新手......必须找到更好的解决方案。谢谢(每个定界符的持续时间为 0.2 秒),就像这样 - 开始定界符 = 12KHz,1 的 = 13k,0 的 = 14k,结束定界符 = 15k
double max_power = 0;
int max_power_index = 0;
double DelimiterSamplesCount = SampleRate * DelimiterTime;
float[] samples32array = samples32.ToArray();
//Searching For Delimiter
for (int i = 0; i < (samples32array.Length); i++) //Delimiter Samples Length = SampleRate*DelimiterTimeLength,( i.e: 44100*0.2=8820 samples)
{
if ((i + (int)DelimiterSamplesCount - 1) > samples32array.Length) break;
double power = Goertzel.GoertzelFilter(samples32array, StartDelimiterFreq, i, i + (int)DelimiterSamplesCount - 1);
if(power > max_power)
{
max_power = power;
max_power_index = i;
}
}
我的 Goertzel 是这样的:
public static double GoertzelFilter(float[] samples, double freq, int start, int end)
{
double sPrev = 0.0;
double sPrev2 = 0.0;
int i;
double normalizedfreq = freq / 44100;
double coeff = 2 * Math.Cos(2 * Math.PI * normalizedfreq);
for (i = start; i < end; i++)
{
double s = samples[i] + coeff * sPrev - sPrev2;
sPrev2 = sPrev;
sPrev = s;
}
double power = sPrev2 * sPrev2 + sPrev * sPrev - coeff * sPrev * sPrev2;
return power;
}