3
我正在綁定實現一個基本的音頻延遲 - 但我所得到的是垃圾,可能是非常明顯的 - 但我似乎無法發現它...如何讓音頻延遲起作用?
音頻處理通過緩衝區是在運行時確定。
我想我正在做一些可怕的指針錯誤,試着看看其他一些代碼 - 但他們都似乎「不完整」總是缺少一些基本的東西 - 可能是我的代碼中還有些什麼。
// Process audio
// 1
void Gain::subProcessSimpleDelay(int bufferOffset, int sampleFrames)
{
// Assign pointers to your in/output buffers.
// Each buffer is an array of float samples.
float* in1 = bufferOffset + pinInput1.getBuffer();
float* in2 = bufferOffset + pinInput2.getBuffer();
float* out1 = bufferOffset + pinOutput1.getBuffer();
// SampleFrames = how many samples to process (can vary).
// Repeat (loop) that many times
for(int s = sampleFrames; s > 0; --s)
{
// get the sample 'POINTED TO' by in1.
float input1 = *in1;
float feedback = *in2;
float output;
unsigned short int p, r;
unsigned short int len;
len = 600;
// check at delay length calculation
if (len > 65535)
len = 65535;
// otherwise, a length of 0 will output the input from
// 65536 samples ago
else if (len < 1)
len = 1;
r = p - len; // loop
output = buffer[r];
buffer[p] = input1 + output * feedback;
p++;
*out1 = output;
// store the result in the output buffer.
// increment the pointers (move to next sample in buffers).
in1++;
in2++;
out1++;
}
}
有人能告訴我什麼是錯?
部屋 - 忘了說了 - 問題是在for循環。該代碼是一個.dll - 在音頻流浮 - >飄出來 - 在pinInput1.getBuffer()的東西就是標準調用約定。緩衝區假定爲循環延遲緩衝區 - >在.h文件中作爲浮點緩衝區[65536]初始化。 –
你是對的! p沒有正確初始化 - 既不是r!他們需要單獨使用 - 因爲他們需要1個樣本延遲才能「隨意」。我是一個怪胎白癡;-)感謝您的幫助! –