diff --git a/src/burn/snd/samples.cpp b/src/burn/snd/samples.cpp index a96a7c615..001c4fa09 100644 --- a/src/burn/snd/samples.cpp +++ b/src/burn/snd/samples.cpp @@ -262,7 +262,7 @@ void BurnSamplePlay(INT32 sample) if (sample_ptr->flags & SAMPLE_IGNORE) return; - if (sample_ptr->flags & SAMPLE_NOSTORE) { + if (sample_ptr->flags & SAMPLE_NOSTOREF) { BurnSampleInitOne(sample); } @@ -270,7 +270,7 @@ void BurnSamplePlay(INT32 sample) sample_ptr->position = 0; } -void BurnSampleChannelPlay(INT32 channel, INT32 sample, bool loop) +void BurnSampleChannelPlay(INT32 channel, INT32 sample, INT32 loop) { #if defined FBNEO_DEBUG if (!DebugSnd_SamplesInitted) bprintf(PRINT_ERROR, _T("BurnSampleChannelPlay called without init\n")); @@ -284,7 +284,9 @@ void BurnSampleChannelPlay(INT32 channel, INT32 sample, bool loop) sample_channels[channel] = sample; BurnSamplePlay(sample); - BurnSampleSetLoop(sample, loop); + if (loop != -1) { // -1, use config from sample struct + BurnSampleSetLoop(sample, loop); + } } void BurnSamplePause(INT32 sample) @@ -573,7 +575,18 @@ void BurnSampleInit(INT32 bAdd /*add samples to stream?*/) if (si.nFlags == 0) break; - if (si.nFlags & SAMPLE_NOSTORE) { + // set defaults before NOSTORE check! + sample_ptr->gain[BURN_SND_SAMPLE_ROUTE_1] = 1.00; + sample_ptr->gain_target[BURN_SND_SAMPLE_ROUTE_1] = 1.00; + + sample_ptr->gain[BURN_SND_SAMPLE_ROUTE_2] = 1.00; + sample_ptr->gain_target[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; + sample_ptr->playback_rate = 100; + + if (si.nFlags & SAMPLE_NOSTOREF) { sample_ptr->flags = si.nFlags; sample_ptr->data = NULL; continue; @@ -596,16 +609,6 @@ void BurnSampleInit(INT32 bAdd /*add samples to stream?*/) } else { sample_ptr->flags = SAMPLE_IGNORE; } - - sample_ptr->gain[BURN_SND_SAMPLE_ROUTE_1] = 1.00; - sample_ptr->gain_target[BURN_SND_SAMPLE_ROUTE_1] = 1.00; - - sample_ptr->gain[BURN_SND_SAMPLE_ROUTE_2] = 1.00; - sample_ptr->gain_target[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; - sample_ptr->playback_rate = 100; } } @@ -620,8 +623,7 @@ void BurnSampleInitOne(INT32 sample) int i = 0; while (i < nTotalSamples) { - - if (clr_ptr->data != NULL && i != sample && (clr_ptr->flags & SAMPLE_NOSTORE)) { + if (clr_ptr->data != NULL && i != sample && (clr_ptr->flags & SAMPLE_NOSTOREF)) { BurnFree(clr_ptr->data); clr_ptr->playing = 0; clr_ptr->playback_rate = 100; @@ -632,7 +634,7 @@ void BurnSampleInitOne(INT32 sample) } } - if ((sample_ptr->flags & SAMPLE_NOSTORE) == 0) { + if ((sample_ptr->flags & SAMPLE_NOSTOREF) == 0) { return; } diff --git a/src/burn/snd/samples.h b/src/burn/snd/samples.h index 0840cc27b..87f495926 100644 --- a/src/burn/snd/samples.h +++ b/src/burn/snd/samples.h @@ -5,6 +5,7 @@ // Change this to 0 to 1 if using samples in a low-ram environment. // May cause momentary stutter while sample loads. #define SAMPLE_NOSTORE (0<<3) // only keep in memory while playing +#define SAMPLE_NOSTOREF (1<<3) // only keep in memory while playing (forced) #define SAMPLE_NODUMP (1<<4) // dump not available #define SAMPLE_PLAYING (1<<0) // playing @@ -21,7 +22,7 @@ INT32 BurnSampleGetStatus(INT32 sample); INT32 BurnSampleGetPosition(INT32 sample); void BurnSampleSetPosition(INT32 sample, UINT32 position); -void BurnSampleChannelPlay(INT32 channel, INT32 sample, bool loop = false); +void BurnSampleChannelPlay(INT32 channel, INT32 sample, INT32 loop = 0); // loop: -1, use config from sample struct void BurnSampleChannelPause(INT32 channel, bool pause); void BurnSampleChannelStop(INT32 channel); INT32 BurnSampleGetChannelStatus(INT32 channel);