Skip to content

Commit

Permalink
limit voices to working number
Browse files Browse the repository at this point in the history
  • Loading branch information
jackhumbert committed May 28, 2019
1 parent 2bac57e commit 6faa65b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions quantum/audio/audio_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,17 @@ static void end_cb1(DACDriver * dacp, dacsample_t * samples, size_t pos) {
//}

uint16_t sample_sum = 0;
for (int i = 0; i < voices; i++) {
int working_voices = voices;
if (working_voices > 3)
working_voices = 3;
for (int i = 0; i < working_voices; i++) {
dac_if[i] = dac_if[i] + ((frequencies[i]*(float)DAC_BUFFER_SIZE)/(float)DAC_SAMPLE_RATE*1.5);
while(dac_if[i] >= DAC_BUFFER_SIZE)
dac_if[i] = dac_if[i] - DAC_BUFFER_SIZE;
sample_sum += dac_buffer[(uint8_t)round(dac_if[i]) % DAC_BUFFER_SIZE] / voices;
sample_sum += dac_buffer[(uint8_t)round(dac_if[i]) % DAC_BUFFER_SIZE] / working_voices;
}

if (voices > 0) {
if (working_voices > 0) {
samples[0] = sample_sum;
} else {
samples[0] = DAC_SAMPLE_MAX;
Expand Down

0 comments on commit 6faa65b

Please sign in to comment.