From aede7b6069cc6b7502d2f73f8969034df40206bc Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 10 Sep 2019 14:04:06 +0000 Subject: [PATCH] Restore the FREQUENCY constant Cave Story at 2000Hz is fun --- src/Backends/Audio/SDL2.cpp | 10 ++++++---- src/Sound.cpp | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Backends/Audio/SDL2.cpp b/src/Backends/Audio/SDL2.cpp index 6e27e9bb..dc415a9c 100644 --- a/src/Backends/Audio/SDL2.cpp +++ b/src/Backends/Audio/SDL2.cpp @@ -10,6 +10,8 @@ #include "../../Organya.h" #include "../../WindowsWrapper.h" +#define OUTPUT_FREQUENCY 44100 + #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define clamp(x, y, z) MIN(MAX((x), (y)), (z)) @@ -45,7 +47,7 @@ static double MillibelToScale(long volume) static void SetSoundFrequency(AudioBackend_Sound *sound, unsigned int frequency) { sound->frequency = frequency; - sound->advance_delta = frequency / 44100.0; + sound->advance_delta = (double)frequency / (double)OUTPUT_FREQUENCY; } static void SetSoundVolume(AudioBackend_Sound *sound, long volume) @@ -148,7 +150,7 @@ static void Callback(void *user_data, Uint8 *stream_uint8, int len) if (organya_countdown == 0) { - organya_countdown = (organya_timer * 44100) / 1000; // organya_timer is in milliseconds, so convert it to audio frames + organya_countdown = (organya_timer * OUTPUT_FREQUENCY) / 1000; // organya_timer is in milliseconds, so convert it to audio frames UpdateOrganya(); } @@ -168,10 +170,10 @@ BOOL AudioBackend_Init(void) return FALSE; SDL_AudioSpec specification; - specification.freq = 44100; + specification.freq = OUTPUT_FREQUENCY; specification.format = AUDIO_F32; specification.channels = 2; - specification.samples = 0x400; // Roughly 10 milliseconds + specification.samples = 0x400; // Roughly 10 milliseconds for 44100Hz specification.callback = Callback; specification.userdata = NULL; diff --git a/src/Sound.cpp b/src/Sound.cpp index 68a7d292..1865dfe7 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -24,8 +24,6 @@ equivalents. #include "PixTone.h" #include "Tags.h" -#define FREQUENCY 44100 - AudioBackend_Sound *lpSECONDARYBUFFER[SE_MAX]; // DirectSoundの開始 (Starting DirectSound)