Skip to content

Commit

Permalink
#331 Play drum funcs to match sampling rate
Browse files Browse the repository at this point in the history
  • Loading branch information
AEFeinstein committed Dec 4, 2024
1 parent 3abae80 commit 8bbda77
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main/midi/midiPlayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,18 @@ static int32_t midiSumPercussion(midiPlayer_t* player)
playingVoices &= ~(1 << voiceIdx);

bool done = false;
sum += voices[voiceIdx].timbre->percussion.playFunc(voices[voiceIdx].note, voices[voiceIdx].sampleTick++, &done,
sum += voices[voiceIdx].timbre->percussion.playFunc(voices[voiceIdx].note, voices[voiceIdx].sampleTick, &done,
voices[voiceIdx].percScratch,
voices[voiceIdx].timbre->percussion.data)
* voices[voiceIdx].velocity / 127;

/* Note that defaultDrumkitFunc() and donutDrumkitFunc() define everything
* in terms of samples, and expect a sampling rate of 32768hz. Because our
* sampling rate is 16384hz, double the tick rate to match. This was easier
* than adjusting the drumkit functions to be defined by DAC_SAMPLE_RATE_HZ
*/
voices[voiceIdx].sampleTick += (32768 / DAC_SAMPLE_RATE_HZ);

if (done)
{
switch (voices[voiceIdx].note)
Expand Down

0 comments on commit 8bbda77

Please sign in to comment.