任何人都有自動相位和頻率對齊的想法嗎?SuperCollider:振盪器的自動相位和頻率對齊
要解釋一下:假設你有一種衝動
in = Impulse.ar(Rand(2, 5), Rand(0, 1));
現在我想操縱另一個衝擊,使得它適應它的相位和頻率來匹配輸入的頻率。 任何建議,即使是谷歌搜索,高度讚賞。
[問題問代表同事]
任何人都有自動相位和頻率對齊的想法嗎?SuperCollider:振盪器的自動相位和頻率對齊
要解釋一下:假設你有一種衝動
in = Impulse.ar(Rand(2, 5), Rand(0, 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
時鐘有不同的頻率和調整算術。
許多改進都是可能的。例如,如果您希望跟蹤不同的頻率,您可能需要稍微調整一下,以避免重新合成的信號頻繁點擊,因爲它會低估信號。
下面是此代碼的一些典型輸出: '[實際/估計頻率,2.289421081543,2.294819330855]' 也就是說,精確度最高可達0.9999734213。 – 2013-05-05 07:47:22
這是一個棘手的問題,因爲你是在處理一個嘈雜的光源具有低頻率。如果這是一個正弦波,我會推薦使用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
你可以嘗試另一種就是用一個神經網絡,試圖猜測它的方法正確的信息。您可以使用主動培訓來幫助實現這一目標。對此有一個非常一般的討論: Pitch detection using neural networks
有些人正在開發的一種方法是模擬耳蝸的神經元來檢測音高。
您可能要在鎖相環讀了起來:http://en.wikipedia.org/wiki/Phase-locked_loop
我覺得好像應該有辦法做到這一點使用FFT部門收回兩個源之間的脈衝響應(儘管這主要是有用的相位對齊不是freq) - 看一看[PV_Div幫助文件](http://doc.sccode.org/Classes/PV_Div.html),它有一個例子可能有用。 – 2013-05-03 07:25:56
我認爲FFT在這裏是過度殺傷。脈衝幾乎是指示相位同步的標準方式(認爲是模擬觸發信號),裸相位/鋸齒幾乎是定義相位計數器。如果信號中存在某種噪聲,並且有一些不錯的頻譜表示和令人討厭的時域表示,我們可能想要使用頻譜技術,但這裏沒有給出。 OTOH PV_Div是一個甜蜜的黑客,我*會*愛藉口給它嘗試。 ;-) – 2013-05-06 10:01:27