From 4c03d8c7043f32cec10f54e4cab08cac2724477b Mon Sep 17 00:00:00 2001 From: iq_132 <1191709+iq132@users.noreply.github.com> Date: Fri, 17 Aug 2012 04:27:51 +0000 Subject: [PATCH] Minor sound updates. Small speedup for dac. --- src/burn/snd/dac.cpp | 19 ++++++++++--------- src/burn/snd/samples.cpp | 8 ++++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/burn/snd/dac.cpp b/src/burn/snd/dac.cpp index 6416fcbf0..f3193802f 100644 --- a/src/burn/snd/dac.cpp +++ b/src/burn/snd/dac.cpp @@ -46,21 +46,22 @@ static void UpdateStream(INT32 chip, INT32 length) if (length <= 0) return; INT16 *lbuf = lBuffer + ptr->nCurrentPosition; - INT16 *rbuf = rBuffer + ptr->nCurrentPosition; + INT16 *rbuf = rBuffer + ptr->nCurrentPosition; - INT16 Out = ptr->Output; + INT16 lOut = ((ptr->OutputDir & BURN_SND_ROUTE_LEFT ) == BURN_SND_ROUTE_LEFT ) ? ptr->Output : 0; + INT16 rOut = ((ptr->OutputDir & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) ? ptr->Output : 0; ptr->nCurrentPosition += length; - if (Out) { + if (rOut && lOut) { while (length--) { - if ((ptr->OutputDir & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) { - *lbuf++ = *lbuf + Out; - } - if ((ptr->OutputDir & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) { - *rbuf++ = *rbuf + Out; - } + *lbuf++ = *lbuf + lOut; + *rbuf++ = *rbuf + rOut; } + } else if (lOut) { + while (length--) *lbuf++ = *lbuf + lOut; + } else if (rOut) { + while (length--) *rbuf++ = *rbuf + rOut; } } diff --git a/src/burn/snd/samples.cpp b/src/burn/snd/samples.cpp index 7a0e748ef..33f1c3e20 100644 --- a/src/burn/snd/samples.cpp +++ b/src/burn/snd/samples.cpp @@ -34,17 +34,17 @@ static void make_raw(UINT8 *src, UINT32 len) if (ptr[0] != 'R' || ptr[1] != 'I' || ptr[2] != 'F' || ptr[3] != 'F') return; ptr += 4; // skip RIFF - UINT32 length = get_long(); ptr += 4; // total length of file + UINT32 length = get_long(); ptr += 4; // total length of file if (len < length) length = len - 8; // first 8 bytes (RIFF + Len) /* "WAVEfmt " */ ptr += 8; // WAVEfmt + 1 space - UINT32 length2 = get_long(); ptr += 4; // Wavefmt length + UINT32 length2 = get_long(); ptr += 4; // Wavefmt length /* unsigned short format = get_short(); */ptr += 2; // format? - UINT16 channels = get_short(); ptr += 2; // channels + UINT16 channels = get_short(); ptr += 2; // channels UINT32 sample_rate = get_long(); ptr += 4; // sample rate /* unsigned int speed = get_long(); */ptr += 4; // speed - should equal (bits * channels * sample_rate) /* unsigned short align = get_short(); */ptr += 2; // block align should be ((bits / 8) * channels) - UINT16 bits = get_short() / 8; ptr += 2; // bits per sample (0010) + UINT16 bits = get_short() / 8; ptr += 2; // bits per sample (0010) ptr += length2 - 16; // get past the wave format chunk // are we in the 'data' chunk? if not, skip this chunk.