瀏覽代碼

Optimize CPU Usage

In my testsketch with 2 x Chorus with n_chrous=4 & #define CHORUS_DELAY_LENGTH (24*AUDIO_BLOCK_SAMPLES),
Cpu-usage decreases from 13.8% to 9.8%
dds
Frank 8 年之前
父節點
當前提交
e5df3287eb
共有 1 個檔案被更改,包括 2 行新增1 行删除
  1. +2
    -1
      effect_chorus.cpp

+ 2
- 1
effect_chorus.cpp 查看文件

block = receiveWritable(0); block = receiveWritable(0);
if(block) { if(block) {
bp = block->data; bp = block->data;
uint32_t tmp = delay_length/(num_chorus - 1) - 1;
for(int i = 0;i < AUDIO_BLOCK_SAMPLES;i++) { for(int i = 0;i < AUDIO_BLOCK_SAMPLES;i++) {
l_circ_idx++; l_circ_idx++;
if(l_circ_idx >= delay_length) { if(l_circ_idx >= delay_length) {
c_idx = l_circ_idx; c_idx = l_circ_idx;
for(int k = 0; k < num_chorus; k++) { for(int k = 0; k < num_chorus; k++) {
sum += l_delayline[c_idx]; sum += l_delayline[c_idx];
if(num_chorus > 1)c_idx -= delay_length/(num_chorus - 1) - 1;
if(num_chorus > 1)c_idx -= tmp;
if(c_idx < 0) { if(c_idx < 0) {
c_idx += delay_length; c_idx += delay_length;
} }

Loading…
取消
儲存