0

有人对自动相位和频率对齐有想法吗?

解释:假设,你有一个冲动

in = Impulse.ar(Rand(2, 5), Rand(0, 1));

现在我想操纵另一个 Impulse 的频率,使其调整其相位和频率以匹配输入。任何建议,即使是谷歌搜索,都非常感谢。

[代表同事提出的问题]

4

3 回答 3

1

我不同意这一点,因为框架是一个棘手的问题。脉冲很容易跟踪——这就是为什么,例如,旧的旋转拨号电话使用脉冲序列。

这是一些以随机频率生成脉冲的代码,然后以相同频率重新合成另一个脉冲。它还输出一个音高估计。

(
var left, right, master, slave, periodestimatebus, secretfrequency;
s = Server.default;
left = Bus.new(\audio, 0,1);
right = Bus.new(\audio, 1,1);
periodestimatebus = Bus.control(s,1);
//choose our secret frequency here for later comparison:
secretfrequency = rrand(2.0,5.0);

//generate impulse with secret frequency at some arbitrary phase
master = {Impulse.ar(secretfrequency, Rand(0, 1));}.play(s, left);

slave = {
    var masterin, clockcount, clockoffset, syncedclock, periodestimate, tracking;
    masterin = In.ar(left);
    //This 1 Hz LFSaw is the "clock" against which we measure stuff
    clockcount = LFSaw.ar(1, 0, 0.5, 0.5);
    clockoffset = Latch.ar(clockcount, Delay1.ar(masterin));
    syncedclock = (clockcount - clockoffset).frac;
    //syncedclock is a version of the clock hard-reset (one sample after) every impulse trigger
    periodestimate = Latch.ar(syncedclock, masterin);
    //sanity-check our f impulse
    Out.kr(periodestimatebus, periodestimate);
    //there is no phase estimate per se - what would we measure it against? -
    //but we can resynthesise a new impulse up to a 1 sample delay from the matched clock.
    tracking = (Slope.ar(syncedclock)>0);
}.play(master, right, 0, addAction: \addAfter);

//Let's see how we performed
{
    periodestimatebus.get({|periodestimate|
        ["actual/estimated frequency", secretfrequency, periodestimate.reciprocal].postln;
    });
}.defer(1);
)

这段代码的注释:

periodestimate是通过巧妙的使用生成的,以Delay1确保它在时钟复位之前对时钟的值进行采样。因此,它偏离了一个样本。

当前的实现将产生一个具有不同频率的良好周期估计,至少低至 1Hz。任何更低,您都需要更改clockcount时钟以具有不同的频率并调整算术。

许多改进是可能的。例如,如果您希望跟踪变化的频率,您可能需要稍微调整一下,以便重新合成的信号不会因为低估信号而过于频繁地单击。

于 2013-05-04T21:28:48.520 回答
0

这是一个棘手的问题,因为您正在处理低频噪声源。如果这是一个正弦波,我建议使用 FFT,但 FFT 在噪声源和低频方面表现不佳。它仍然值得一试。FFT 也可以匹配相位。我相信您可以使用 pitch.ar 来帮助找到频率。

您可以使用 Chrip-Z 算法来代替 FFT - http://www.embedded.com/design/configurable-systems/4006427/A-DSP-algorithm-for-frequency-analysis http://en。 wikipedia.org/wiki/Bluestein%27s_FFT_algorithm

您可以尝试的另一件事是使用神经网络来尝试猜测它是获取正确信息的方式。您可以使用主动训练来帮助它实现这一目标。SO上有一个非常笼统的讨论: Pitch detection using neural networks

一些人正在采用的一种方法是模拟耳蜗的神经元来检测音高。

于 2013-05-02T22:06:57.493 回答
0

您可能想阅读锁相环:http ://en.wikipedia.org/wiki/Phase-locked_loop

于 2013-05-24T03:07:31.570 回答