Skip to content

Commit

Permalink
Enabled volume control for PDM and PWM
Browse files Browse the repository at this point in the history
  • Loading branch information
cgreening committed Oct 18, 2024
1 parent 94554ca commit d7394a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion player/src/AudioOutput/PDMTimerOuput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ void PDMTimerOutput::write(int8_t *samples, int count)
// make sure there's enough room for the samples
mSecondBuffer = (int8_t *)realloc(mSecondBuffer, count);
// copy them into the second buffer
memcpy(mSecondBuffer, samples, count);
for(int i = 0; i < count; i++) {
mSecondBuffer[i] = samples[i] * mVolume / 10;
}
// second buffer is now full of samples
mSecondBufferLength = count;
// unlock the mutext and return
Expand Down
4 changes: 3 additions & 1 deletion player/src/AudioOutput/PWMTimerOuput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ void PWMTimerOutput::write(int8_t *samples, int count)
// make sure there's enough room for the samples
mSecondBuffer = (int8_t *)realloc(mSecondBuffer, count);
// copy them into the second buffer
memcpy(mSecondBuffer, samples, count);
for(int i = 0; i < count; i++) {
mSecondBuffer[i] = samples[i] * mVolume / 10;
}
// second buffer is now full of samples
mSecondBufferLength = count;
// unlock the mutext and return
Expand Down

0 comments on commit d7394a5

Please sign in to comment.