void BurnSampleInitOne(INT32 sample) { if (sample >= nTotalSamples) { return; } { struct sample_format *clr_ptr = &samples[0]; int i = 0; while (i < nTotalSamples) { if (clr_ptr->data != NULL && i != sample && (clr_ptr->flags & SAMPLE_NOSTORE)) { free(clr_ptr->data); clr_ptr->playing = 0; clr_ptr->data = NULL; } clr_ptr++, i++; } } if ((sample_ptr->flags & SAMPLE_NOSTORE) == 0) { return; } INT32 length; char path[256]; char setname[128]; void *destination = NULL; char szTempPath[MAX_PATH]; sprintf(szTempPath, _TtoA(SAMPLE_DIRECTORY)); strcpy(setname, BurnDrvGetTextA(DRV_SAMPLENAME)); sprintf(path, "%s%s.zip", szTempPath, setname); struct BurnSampleInfo si; BurnDrvGetSampleInfo(&si, sample); char *szSampleName = NULL; BurnDrvGetSampleName(&szSampleName, sample, 0); sample_ptr = &samples[sample]; // append .wav to filename szSampleName[strlen(szSampleName)] = '.'; szSampleName[strlen(szSampleName)] = 'w'; szSampleName[strlen(szSampleName)] = 'a'; szSampleName[strlen(szSampleName)] = 'v'; if (sample_ptr->playing || sample_ptr->data != NULL || sample_ptr->flags == SAMPLE_IGNORE) { return; } sprintf (path, "%s%s", szTempPath, setname); destination = NULL; length = 0; ZipLoadOneFile((char*)path, (const char*)szSampleName, &destination, &length); if (length) { make_raw((UINT8*)destination, length); } if (destination) { free (destination); destination = NULL; } }
void BurnSampleInit(INT32 bAdd /*add sample to stream?*/) { DebugSnd_SamplesInitted = 1; if (nBurnSoundRate == 0) { nTotalSamples = 0; return; } INT32 length; char path[256]; char setname[128]; void *destination = NULL; char szTempPath[MAX_PATH]; #ifdef __LIBRETRO__ #if defined(_XBOX) || defined(_WIN32) char slash = '\\'; #else char slash = '/'; #endif snprintf(szTempPath, sizeof(szTempPath), "%s%cfba2012%csamples%c", g_system_dir, slash, slash, slash); #else snprintf(szTempPath, sizeof(szTempPath), _TtoA(SAMPLE_DIRECTORY)); #endif // test to see if file exists INT32 nEnableSamples = 0; if (BurnDrvGetTextA(DRV_SAMPLENAME) == NULL) { // called with no samples nTotalSamples = 0; return; } strcpy(setname, BurnDrvGetTextA(DRV_SAMPLENAME)); snprintf(path, sizeof(path), "%s%s.zip", szTempPath, setname); FILE *test = fopen(path, "rb"); if (test) { nEnableSamples = 1; fclose(test); } #ifdef INCLUDE_7Z_SUPPORT snprintf(path, sizeof(path), "%s%s.7z", szTempPath, setname); test = fopen(path, "rb"); if (test) { nEnableSamples = 1; fclose(test); } #endif if (!nEnableSamples) return; bAddToStream = bAdd; nTotalSamples = 0; struct BurnSampleInfo si; INT32 nSampleOffset = -1; do { BurnDrvGetSampleInfo(&si, ++nSampleOffset); if (si.nFlags) nTotalSamples++; } while (si.nFlags); samples = (sample_format*)malloc(sizeof(sample_format) * nTotalSamples); memset (samples, 0, sizeof(sample_format) * nTotalSamples); for (INT32 i = 0; i < nTotalSamples; i++) { BurnDrvGetSampleInfo(&si, i); char *szSampleName = NULL; BurnDrvGetSampleName(&szSampleName, i, 0); sample_ptr = &samples[i]; if (si.nFlags == 0) break; sprintf (path, "%s%s", szTempPath, setname); destination = NULL; length = 0; ZipLoadOneFile((char*)path, (const char*)szSampleName, &destination, &length); if (length) { make_raw((UINT8*)destination, length); sample_ptr->flags = si.nFlags; } else { sample_ptr->flags = SAMPLE_IGNORE; } sample_ptr->gain[BURN_SND_SAMPLE_ROUTE_1] = 1.00; sample_ptr->gain[BURN_SND_SAMPLE_ROUTE_2] = 1.00; sample_ptr->output_dir[BURN_SND_SAMPLE_ROUTE_1] = BURN_SND_ROUTE_BOTH; sample_ptr->output_dir[BURN_SND_SAMPLE_ROUTE_2] = BURN_SND_ROUTE_BOTH; if (destination) { free (destination); destination = NULL; } } }
void BurnSampleInit(INT32 bAdd /*add sample to stream?*/) { DebugSnd_SamplesInitted = 1; if (nBurnSoundRate == 0) { nTotalSamples = 0; return; } INT32 length; char path[256]; char setname[128]; void *destination = NULL; char szTempPath[MAX_PATH]; sprintf(szTempPath, _TtoA(SAMPLE_DIRECTORY)); // test to see if file exists INT32 nEnableSamples = 0; if (BurnDrvGetTextA(DRV_SAMPLENAME) == NULL) { // called with no samples nTotalSamples = 0; return; } strcpy(setname, BurnDrvGetTextA(DRV_SAMPLENAME)); sprintf(path, "%s%s.zip", szTempPath, setname); FILE *test = fopen(path, "rb"); if (test) { nEnableSamples = 1; fclose(test); } #ifdef INCLUDE_7Z_SUPPORT sprintf(path, "%s%s.7z", szTempPath, setname); test = fopen(path, "rb"); if (test) { nEnableSamples = 1; fclose(test); } #endif bAddToStream = bAdd; nTotalSamples = 0; if (!nEnableSamples) return; struct BurnSampleInfo si; INT32 nSampleOffset = -1; do { BurnDrvGetSampleInfo(&si, ++nSampleOffset); if (si.nFlags) nTotalSamples++; } while (si.nFlags); samples = (sample_format*)malloc(sizeof(sample_format) * nTotalSamples); memset (samples, 0, sizeof(sample_format) * nTotalSamples); for (INT32 i = 0; i < nTotalSamples; i++) { BurnDrvGetSampleInfo(&si, i); char *szSampleName = NULL; BurnDrvGetSampleName(&szSampleName, i, 0); sample_ptr = &samples[i]; // append .wav to filename szSampleName[strlen(szSampleName)] = '.'; szSampleName[strlen(szSampleName)] = 'w'; szSampleName[strlen(szSampleName)] = 'a'; szSampleName[strlen(szSampleName)] = 'v'; if (si.nFlags == 0) break; if (si.nFlags & SAMPLE_NOSTORE) { sample_ptr->flags = si.nFlags; sample_ptr->data = NULL; continue; } sprintf (path, "%s%s", szTempPath, setname); destination = NULL; length = 0; ZipLoadOneFile((char*)path, (const char*)szSampleName, &destination, &length); if (length) { sample_ptr->flags = si.nFlags; make_raw((UINT8*)destination, length); } else { sample_ptr->flags = SAMPLE_IGNORE; } sample_ptr->gain[BURN_SND_SAMPLE_ROUTE_1] = 1.00; sample_ptr->gain[BURN_SND_SAMPLE_ROUTE_2] = 1.00; sample_ptr->output_dir[BURN_SND_SAMPLE_ROUTE_1] = BURN_SND_ROUTE_BOTH; sample_ptr->output_dir[BURN_SND_SAMPLE_ROUTE_2] = BURN_SND_ROUTE_BOTH; if (destination) { free (destination); destination = NULL; } BurnSetProgressRange(1.0 / nTotalSamples); BurnUpdateProgress((double)1.0 / i * nTotalSamples, _T("Loading samples..."), 0); } }
void BurnSampleInit(INT32 nGain /*volume percentage!*/, INT32 bAdd /*add sample to stream?*/) { DebugSnd_SamplesInitted = 1; if (nBurnSoundRate == 0) { nTotalSamples = 0; return; } INT32 length; char path[256]; char setname[128]; void *destination = NULL; char szTempPath[MAX_PATH]; sprintf(szTempPath, _TtoA(SAMPLE_DIRECTORY)); // test to see if file exists INT32 nEnableSamples = 0; if (BurnDrvGetTextA(DRV_SAMPLENAME) == NULL) { // called with no samples nTotalSamples = 0; return; } strcpy(setname, BurnDrvGetTextA(DRV_SAMPLENAME)); sprintf(path, "%s%s.zip", szTempPath, setname); FILE *test = fopen(path, "rb"); if (test) { nEnableSamples = 1; fclose(test); } #ifdef INCLUDE_7Z_SUPPORT sprintf(path, "%s%s.7z", szTempPath, setname); test = fopen(path, "rb"); if (test) { nEnableSamples = 1; fclose(test); } #endif if (!nEnableSamples) return; bAddToStream = bAdd; nSampleSetGain = nGain; nTotalSamples = 0; struct BurnSampleInfo si; INT32 nSampleOffset = -1; do { BurnDrvGetSampleInfo(&si, ++nSampleOffset); if (si.nFlags) nTotalSamples++; } while (si.nFlags); samples = (sample_format*)malloc(sizeof(sample_format) * nTotalSamples); memset (samples, 0, sizeof(sample_format) * nTotalSamples); for (INT32 i = 0; i < nTotalSamples; i++) { BurnDrvGetSampleInfo(&si, i); char *szSampleName = NULL; BurnDrvGetSampleName(&szSampleName, i, 0); sample_ptr = &samples[i]; if (si.nFlags == 0) break; sprintf (path, "%s%s", szTempPath, setname); destination = NULL; length = 0; ZipLoadOneFile((char*)path, (const char*)szSampleName, &destination, &length); if (length) { make_raw((UINT8*)destination, length); sample_ptr->flags = si.nFlags; } else { sample_ptr->flags = SAMPLE_IGNORE; } if (destination) { free (destination); destination = NULL; } } }