aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorNebuleon Fumika2013-02-06 05:59:22 -0500
committerNebuleon Fumika2013-02-06 05:59:22 -0500
commit3dc666810732dcabb95a3bd1d02d4fcee0befd3f (patch)
tree914b83dfa8fc31b2bda76219f110c80ba6aee9c7 /source
parent3c3a97219dbe3a2e7555e6f65eb093d4f3435e49 (diff)
downloadsnesemu-3dc666810732dcabb95a3bd1d02d4fcee0befd3f.tar.gz
snesemu-3dc666810732dcabb95a3bd1d02d4fcee0befd3f.tar.bz2
snesemu-3dc666810732dcabb95a3bd1d02d4fcee0befd3f.zip
Raise the sound frequency from 22050 Hz to 32000 Hz, which is like the SNES. Use sound interpolation to make it sound even more like the SNES.
Diffstat (limited to 'source')
-rw-r--r--source/nds/ds2sound.h21
-rw-r--r--source/nds/entry.cpp4
2 files changed, 14 insertions, 11 deletions
diff --git a/source/nds/ds2sound.h b/source/nds/ds2sound.h
index f51a6e1..8c0e2bf 100644
--- a/source/nds/ds2sound.h
+++ b/source/nds/ds2sound.h
@@ -1,21 +1,24 @@
// The sound buffer sizes used on the DS2's side, for each value of
// Settings.SoundPlaybackRate.
+// * Don't buffer too much, otherwise audio is delayed from video.
+// * Don't go below one frame (20 milliseconds).
+// * Buffer sizes must be multiples of 128.
#define DS2_BUFFER_SIZE_4 512 /* tested working */
-#define DS2_BUFFER_SIZE_5 1024 /* like the SNES! tested working, but slow */
-#define DS2_BUFFER_SIZE_6 1024 /* tested working, slow because of upsampling */
-#define DS2_BUFFER_SIZE_7 1024 /* tested working, slow because of upsampling */
+#define DS2_BUFFER_SIZE_5 640 /* like the SNES! tested working */
+#define DS2_BUFFER_SIZE_6 896 /* tested working */
+#define DS2_BUFFER_SIZE_7 1024 /* tested working */
// The sampling rate for the sound, in Hz, for each value of
// Settings.SoundPlaybackRate.
#define SND_SAMPLE_RATE_1 8000
#define SND_SAMPLE_RATE_2 11025
#define SND_SAMPLE_RATE_3 16000
-#define SND_SAMPLE_RATE_4 22050
-#define SND_SAMPLE_RATE_5 32000
+#define SND_SAMPLE_RATE_4 22050 /* NDSSFC 1.06 - CATSFC 1.28 used this one */
+#define SND_SAMPLE_RATE_5 32000 /* like the SNES! */
#define SND_SAMPLE_RATE_6 44100
-#define SND_SAMPLE_RATE_7 48000
+#define SND_SAMPLE_RATE_7 48000 /* CATSFC 1.25 made using this one possible */
// Settings in use. The number should match in all three settings.
-#define DS2_BUFFER_SIZE DS2_BUFFER_SIZE_4
-#define SND_SAMPLE_RATE SND_SAMPLE_RATE_4
-#define SNES9X_SRATE_ID 4
+#define DS2_BUFFER_SIZE DS2_BUFFER_SIZE_5
+#define SND_SAMPLE_RATE SND_SAMPLE_RATE_5
+#define SNES9X_SRATE_ID 5
diff --git a/source/nds/entry.cpp b/source/nds/entry.cpp
index ca27249..723374c 100644
--- a/source/nds/entry.cpp
+++ b/source/nds/entry.cpp
@@ -425,7 +425,7 @@ void init_sfc_setting(void)
//sound settings
Settings.APUEnabled = Settings.NextAPUEnabled = TRUE;
Settings.FixFrequency = 1;
-
+ Settings.InterpolatedSound = TRUE;
Settings.H_Max = SNES_CYCLES_PER_SCANLINE;
Settings.SkipFrames = AUTO_FRAMERATE;
@@ -1042,7 +1042,7 @@ void S9xGenerateSound ()
}
}
-#define SOUND_EMISSION_INTERVAL ((unsigned int) ((((unsigned long long) DS2_BUFFER_SIZE * 1000000) / SND_SAMPLE_RATE) * 3 / 128))
+#define SOUND_EMISSION_INTERVAL ((unsigned int) ((((unsigned long long) DS2_BUFFER_SIZE * 1000000) / SND_SAMPLE_RATE) * 3 / 128) - 1) /* -1 is for roundoff errors */
unsigned int LastSoundEmissionTime = 0;
void S9xProcessSound (unsigned int)