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个样本延迟才能“随意”。我是一个怪胎白痴;-)感谢您的帮助! –