Skip to content

Commit 0523bce

Browse files
authored
Merge pull request #261 from vadosnaprimer/release_0_9_9
Mic sample fixes for 0.9.9
2 parents 3695f5b + 9967581 commit 0523bce

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

desmume/src/windows/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2776,7 +2776,7 @@ static void RefreshMicSettings()
27762776
{
27772777
MessageBox(NULL, "Unable to read the mic sample", "DeSmuME", (MB_OK | MB_ICONEXCLAMATION));
27782778
}
2779-
else
2779+
else if (osd)
27802780
{
27812781
osd->addLine("Mic sample %d selected", MicSampleSelection);
27822782
}

desmume/src/windows/mic.cpp

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ bool LoadSamples(const char *name)
231231
if (!name || !*name) return true;
232232

233233
//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
234-
//(and if not, it can still be loaded just fine)
234+
//series with just digits in filenames also work: "0.wav". in those \ would be a remainder from the path
235+
//(and if neither, it can still be loaded just fine)
235236
const char* ext = strrchr(name,'.');
236237

237238
//in case the filename had no extension... it's an error.
@@ -243,13 +244,13 @@ bool LoadSamples(const char *name)
243244
if(ext<name)
244245
return LoadSample(name);
245246

246-
//if it was not a _0, just load it
247-
if(strncmp(maybe_0,"_0",2))
247+
//if it was not a _0 or a \0, just load it
248+
if(strncmp(maybe_0,"_0",2) && strncmp(maybe_0,"\\0",2))
248249
return LoadSample(name);
249250

250251
//otherwise replace it with increasing numbers and load all those
251252
std::string prefix = name;
252-
prefix.resize(maybe_0-name+1); //take care to keep the _
253+
prefix.resize(maybe_0-name+1); //take care to keep the _ or \
253254
254255
//if found, it's a wildcard. load all those samples
255256
//this is limited to 254 entries in order to prevent some surprises, because I was stupid and used a byte for the MicSampleSelection.
@@ -394,27 +395,12 @@ u8 Mic_ReadSample()
394395
{
395396
if(micSamples.size() > 0)
396397
{
397-
//why is this reading every sample twice? I did this for some reason in 57dbe9128d0f8cbb4bd79154fb9cda3ab6fab386
398-
//maybe the game reads two samples in succession to check them or something. stuff definitely works better with the two-in-a-row
399-
if (micReadSamplePos == micSamples[MicSampleSelection].size()*2)
400-
{
401-
tmp = 0x80; //silence, with 8 bit signed values
402-
}
403-
else
398+
tmp = micSamples[MicSampleSelection][micReadSamplePos >> 1];
399+
micReadSamplePos++;
400+
if(micReadSamplePos == micSamples[MicSampleSelection].size()*2)
404401
{
405-
tmp = micSamples[MicSampleSelection][micReadSamplePos >> 1];
406-
407-
//nintendogs seems sensitive to clipped samples, at least.
408-
//by clamping these, we get better sounds on playback
409-
//I don't know how important it is, but I like nintendogs to sound good at least..
410-
if(tmp == 0) tmp = 1;
411-
if(tmp == 255) tmp = 254;
412-
413-
micReadSamplePos++;
414-
if(micReadSamplePos == micSamples[MicSampleSelection].size()*2)
415-
{
416-
printf("Ended mic sample MicSampleSelection\n");
417-
}
402+
micReadSamplePos=0;
403+
printf("Ended mic sample MicSampleSelection\n");
418404
}
419405
}
420406
else

0 commit comments

Comments
 (0)