处理线性上采样音频阵列
Handling linear upsampling audio array
我有一个实时信号,一个样本接一个样本,我需要对它进行4次上采样。我从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;
}
}
第页。S.我很清楚线性插值是不好的,但它是我见过的最简单的。我对编码还很陌生,所以在这个阶段,"实现的容易性"胜过性能。
问候Andrew
您需要为process4提供一个缓冲区,该缓冲区可以容纳4个浮点值。其次,您需要实例化interpoler_linear才能使用它
interpolator_linear interp; // you'll want to make this a member of TD_OSclip.
float out[4];
for( int s = sampleFrames; s > 0; --s )
{
float input = *in;
interp.process4(input, out);
...
}
相关文章:
- OpenMP阵列性能较差
- 用c++阅读音频
- 如何将三维尺寸不固定的三维阵列展平为一维阵列
- 当我的阵列太大时出现分段错误
- 为什么这个音频包络不能通过开关的情况?
- 位阵列上的快速AND运算
- FFMpeg库:如何在音频文件中精确查找
- 阵列必须使用大括号封闭的初始器进行初始化
- 没有从阵列<float>到阵列<int>的可行转换
- 需要反转音频步进公式
- C++动态安全 2D 交错阵列
- 如何在音频处理中使用超能力时间拉伸类
- 将平面阵列重塑为复杂的特征类型
- 如何使用英特尔 PIN 捕获阵列的所有负载?
- 为什么我能够为阵列分配比计算机实际拥有的内存更多的内存
- 库特<<恩德尔;不适用于打印 2D 阵列
- 数组类 阵列的打印输出
- C++新手,想知道如何使用VS code 2019播放音频文件
- 在Java Android和JNI之间发送/接收音频阵列
- 处理线性上采样音频阵列