샘플로 샘플에 들어오는 실시간 신호가 있고, 4x 업 샘플링이 필요합니다. 나는이 수업을 musicdsp.org에서 가지고 있습니다 :리니어 업 샘플링 오디오 어레이 처리
#ifndef TD_INTERPOLATOR_H_INCLUDED
#define TD_INTERPOLATOR_H_INCLUDED
/************************************************************************
* Linear interpolator class *
************************************************************************/
class interpolator_linear
{
public:
interpolator_linear() {
reset_hist();
}
// reset history
void reset_hist() {
d1 = 0.f;
}
// 4x interpolator
// out: pointer to float[4]
inline void process4x(float const in, float *out) {
float y = in-d1;
out[0] = d1 + 0.25f*y; // interpolate
out[1] = d1 + 0.5f*y;
out[2] = d1 + 0.75f*y;
out[3] = in;
d1 = in; // store delay
}
}
private:
float d1; // previous input
};
#endif // TD_INTERPOLATOR_H_INCLUDED
나는 위의 내용이 맞다고 생각합니다. 이제는 배열 요소를 개별적으로 어떻게 반환해야합니까?
void TD_OSclip::subProcessClip4(int bufferOffset, int sampleFrames)
{
float* in = bufferOffset + pinInput.getBuffer();
float* outputt = bufferOffset + pinOutput.getBuffer();
for(int s = sampleFrames; s > 0; --s)
{
float input = *in;
//upsample 4x Linear --How should I call it here?
interpolator_linear::process4(input, what should be here??);
////I need all the seperate out arrays elements for the next stage
//do process
float clip = 0.5f;
float neg_clip = -0.5f;
float out0 = std::max(neg_clip, std::min(clip, out[0]));
float out1 = std::max(neg_clip, std::min(clip, out[1]));
float out2 = std::max(neg_clip, std::min(clip, out[2]));
float out3 = std::max(neg_clip, std::min(clip, out[3]));
//lowpass filter ommitted for briefness
float out0f = out0;
float out1f = out0;
float out2f = out0;
float out3f = out0;
//downsample
float output1 = (out0f + out1f + out2f + out3f)/4.f;
*outputt = output1;
++in;
++outputt;
}
}
P. 선형 보간법이 좋지 않다는 것을 잘 알고 있지만, 내가 본 것은 가장 간단합니다. 그리고 코딩의 새 기능이므로이 단계에서 '구현의 용이성'이 성능보다 우수합니다.
감사 앤드류
"배열 요소를 개별적으로 반환"하는 것이 명확하지 않습니다. –
나는 out [0], out [1], out [2], out [3]을 필요로합니다. 클래스는 단지 포인터라고 생각합니다. –