From 6759ecc06ef4b867b7ab06fbc0adeb3c6e85c318 Mon Sep 17 00:00:00 2001 From: Sean Maas Date: Wed, 3 Mar 2021 23:13:42 -0500 Subject: [PATCH] Fix a couple issues with frequency calculation --- src/nds/arm7/nds_audio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nds/arm7/nds_audio.c b/src/nds/arm7/nds_audio.c index abefe004..f709a0bb 100644 --- a/src/nds/arm7/nds_audio.c +++ b/src/nds/arm7/nds_audio.c @@ -2,10 +2,14 @@ #include "nds_audio.h" +// Better frequency calculation +#undef SOUND_FREQ +#define SOUND_FREQ(n) (-(BUS_CLOCK >> 1) / (n)) + static u16 calculate_freq(const struct Note *note) { // Calculate the DS frequency for a note // Some frequencies are too high, but clipping at least lets them get as close as possible - u32 freq = note->frequency * 32768; + u32 freq = note->frequency * 32000; if (freq > 0xFFFF) freq = 0xFFFF; return SOUND_FREQ((u16)freq); }