From 40bf609a2c67828984dde2ba0fe03844f410367a Mon Sep 17 00:00:00 2001 From: feos Date: Sun, 24 Mar 2019 01:02:43 +0300 Subject: [PATCH 1/3] use the old logic for sample playback this branch is meant to remain compatible with 0.9.9 release, and the goal is making movies sync with and without the patch, provided the movie format is converted accordingly (which is easy). since new sample replay logic introduced in master breaks sync with 0.9.9, it's a good idea to leave the new logic for a potential new release while remaining sync-compatible in this branch. --- desmume/src/windows/mic.cpp | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/desmume/src/windows/mic.cpp b/desmume/src/windows/mic.cpp index 2a7acbcac..bb6149284 100644 --- a/desmume/src/windows/mic.cpp +++ b/desmume/src/windows/mic.cpp @@ -394,27 +394,12 @@ u8 Mic_ReadSample() { if(micSamples.size() > 0) { - //why is this reading every sample twice? I did this for some reason in 57dbe9128d0f8cbb4bd79154fb9cda3ab6fab386 - //maybe the game reads two samples in succession to check them or something. stuff definitely works better with the two-in-a-row - if (micReadSamplePos == micSamples[MicSampleSelection].size()*2) + tmp = micSamples[MicSampleSelection][micReadSamplePos >> 1]; + micReadSamplePos++; + if(micReadSamplePos == micSamples[MicSampleSelection].size()*2) { - tmp = 0x80; //silence, with 8 bit signed values - } - else - { - tmp = micSamples[MicSampleSelection][micReadSamplePos >> 1]; - - //nintendogs seems sensitive to clipped samples, at least. - //by clamping these, we get better sounds on playback - //I don't know how important it is, but I like nintendogs to sound good at least.. - if(tmp == 0) tmp = 1; - if(tmp == 255) tmp = 254; - - micReadSamplePos++; - if(micReadSamplePos == micSamples[MicSampleSelection].size()*2) - { - printf("Ended mic sample MicSampleSelection\n"); - } + micReadSamplePos=0; + printf("Ended mic sample MicSampleSelection\n"); } } else From 042afbaec5141f7735007b59135f426312a4ad13 Mon Sep 17 00:00:00 2001 From: vadosnaprimer Date: Mon, 25 Mar 2019 18:34:29 +0300 Subject: [PATCH 2/3] fix crash when printing to non-existent osd --- desmume/src/windows/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 08af507b1..6edfa2f47 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -2776,7 +2776,7 @@ static void RefreshMicSettings() { MessageBox(NULL, "Unable to read the mic sample", "DeSmuME", (MB_OK | MB_ICONEXCLAMATION)); } - else + else if (osd) { osd->addLine("Mic sample %d selected", MicSampleSelection); } From 9967581aa8a94dd44afebe5e082304e9aa95b6c2 Mon Sep 17 00:00:00 2001 From: vadosnaprimer Date: Mon, 25 Mar 2019 19:23:38 +0300 Subject: [PATCH 3/3] support sample series having just digits in filenames: "0.wav" --- desmume/src/windows/mic.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/desmume/src/windows/mic.cpp b/desmume/src/windows/mic.cpp index bb6149284..da27c20ef 100644 --- a/desmume/src/windows/mic.cpp +++ b/desmume/src/windows/mic.cpp @@ -231,7 +231,8 @@ bool LoadSamples(const char *name) if (!name || !*name) return true; //analyze the filename for _0 at the end. anything with _0 at the end is assumed to be the beginning of a series of files - //(and if not, it can still be loaded just fine) + //series with just digits in filenames also work: "0.wav". in those \ would be a remainder from the path + //(and if neither, it can still be loaded just fine) const char* ext = strrchr(name,'.'); //in case the filename had no extension... it's an error. @@ -243,13 +244,13 @@ bool LoadSamples(const char *name) if(ext