diff options
author | Carsten Weisse <[email protected]> | 2006-01-01 15:07:30 +0000 |
---|---|---|
committer | Carsten Weisse <[email protected]> | 2006-01-01 15:07:30 +0000 |
commit | 2688bf34bd12c7fe57c9d251cdff0797acda1046 (patch) | |
tree | 435665cb40b38fd4ccde2a4d9feaec0929f2f673 /src | |
parent | 0b6fa43cfccca0e20a14d517ddaba16046ff737a (diff) |
handles the 16bit sample byte order (Mac OSX)
Diffstat (limited to 'src')
-rw-r--r-- | src/jake2/sound/WaveLoader.java | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/jake2/sound/WaveLoader.java b/src/jake2/sound/WaveLoader.java index 73cba9c..a52f376 100644 --- a/src/jake2/sound/WaveLoader.java +++ b/src/jake2/sound/WaveLoader.java @@ -2,7 +2,7 @@ * SND_MEM.java * Copyright (C) 2004 * - * $Id: WaveLoader.java,v 1.6 2005-12-13 00:02:52 salomo Exp $ + * $Id: WaveLoader.java,v 1.7 2006-01-01 15:07:30 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -166,27 +166,26 @@ public class WaveLoader { samplefrac = 0; fracstep = (int) (stepscale * 256); - for (i=0 ; i<outcount ; i++) - { - srcsample = samplefrac >> 8; - samplefrac += fracstep; - - if (inwidth == 2) - { - sample = (int) ((data[offset + srcsample * 2] & 0xff) + (data[offset + srcsample * 2 + 1] << 8)); - } - else - { - sample = ((data[offset + srcsample] &0xff) - 128) << 8; - } - - if (sc.width == 2) - { - sc.data[i*2] = (byte) (sample & 0xff); - sc.data[i*2+1] = (byte) ((sample>>>8) & 0xff); - } - else - { + for (i = 0; i < outcount; i++) { + srcsample = samplefrac >> 8; + samplefrac += fracstep; + + if (inwidth == 2) { + sample = (data[offset + srcsample * 2] & 0xff) + + (data[offset + srcsample * 2 + 1] << 8); + } else { + sample = ((data[offset + srcsample] & 0xff) - 128) << 8; + } + + if (sc.width == 2) { + if (Defines.LITTLE_ENDIAN) { + sc.data[i * 2] = (byte) (sample & 0xff); + sc.data[i * 2 + 1] = (byte) ((sample >>> 8) & 0xff); + } else { + sc.data[i * 2] = (byte) ((sample >>> 8) & 0xff); + sc.data[i * 2 + 1] = (byte) (sample & 0xff); + } + } else { sc.data[i] = (byte) (sample >> 8); } } |