次のオーディオ コードで CPU パイプラインを確実に利用する方法を知りたいです。
int sample_count = 100;
// volume array - value to multiply audio sample by
double volume[4][4];
// fill volume array with values here
// audio sample array - really this is 125 samples by 16 channels but smaller here for clarity
double samples[sample_count][4];
// fill samples array with audio samples here
double tmp[4];
for (x=0;x<sample_count;x++) {
tmp[0] = samples[x][0]*volume[0][0] + samples[x][1]*volume[1][0] + samples[x][2]*volume[2][0] + samples[x][3]*volume[3][0];
tmp[1] = samples[x][0]*volume[0][1] + samples[x][1]*volume[1][1] + samples[x][2]*volume[2][1] + samples[x][3]*volume[3][1];
tmp[2] = samples[x][0]*volume[0][2] + samples[x][1]*volume[1][2] + samples[x][2]*volume[2][2] + samples[x][3]*volume[3][2];
tmp[3] = samples[x][0]*volume[0][3] + samples[x][1]*volume[1][3] + samples[x][2]*volume[2][3] + samples[x][3]*volume[3][3];
samples[x][0] = tmp[0];
samples[x][1] = tmp[1];
samples[x][2] = tmp[2];
samples[x][3] = tmp[3];
}
// write sample array out to hardware here.
すぐに明確にならない場合は、4x4 のボリューム コントロール マトリックスを介して 4 つの入力チャンネルを 4 つの出力チャンネルにミックスします。
私は実際にこれを上記の例よりもかなり集中的に実行していますが、パイプライン処理を利用するようにコードを調整する方法がわかりません (これが適しているようです)。同じ値を複数回 (同じチャネルの連続したサンプルの場合) 操作できるように、一度にサンプル配列の 1 つの「チャネル」で作業する必要がありますか? ただし、その方法では x を > sample_count の 4 回チェックする必要があります。この方法で作業するとCPUパイプラインが効率的になる場合は、tmpを2次元にして、完全なバッファーを保持するのに十分な大きさにすることができます。または、上記のコードは効率的にパイプライン処理されますか? パイプライン処理が行われているかどうかを確認する簡単な方法はありますか? ティア。