/[svn]/linuxsampler/trunk/src/engines/common/SampleFile.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/common/SampleFile.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2058 by persson, Sun Feb 14 11:40:49 2010 UTC revision 2119 by persson, Fri Aug 27 16:27:16 2010 UTC
# Line 22  Line 22 
22   ***************************************************************************/   ***************************************************************************/
23    
24  #include "SampleFile.h"  #include "SampleFile.h"
25    #include "../../common/global_private.h"
26  #include "../../common/Exception.h"  #include "../../common/Exception.h"
27    
28  #include <cstring>  #include <cstring>
# Line 46  namespace LinuxSampler { Line 47  namespace LinuxSampler {
47          ChannelCount = sfInfo.channels;          ChannelCount = sfInfo.channels;
48          Format = sfInfo.format;          Format = sfInfo.format;
49    
50          switch(Format & 0xF) {          switch(Format & SF_FORMAT_SUBMASK) {
51              case SF_FORMAT_PCM_S8:              case SF_FORMAT_PCM_S8:
52              case SF_FORMAT_PCM_U8:              case SF_FORMAT_PCM_U8:
53              case SF_FORMAT_DPCM_8:              case SF_FORMAT_DPCM_8:
# Line 145  namespace LinuxSampler { Line 146  namespace LinuxSampler {
146    
147      long SampleFile::Read(void* pBuffer, unsigned long FrameCount) {      long SampleFile::Read(void* pBuffer, unsigned long FrameCount) {
148          Open();          Open();
149          int bytes = sf_read_raw(pSndFile, pBuffer, FrameCount * GetFrameSize());  
150          return bytes / GetFrameSize();          // ogg files must be read with sf_readf, not sf_read_raw. On
151            // big endian machines, sf_readf_short is also used for 16 bit
152            // wav files, to get automatic endian conversion (for 24 bit
153            // samples this is handled in Synthesize::GetSample instead).
154    
155    #if WORDS_BIGENDIAN || HAVE_DECL_SF_FORMAT_VORBIS
156            if (
157    #if WORDS_BIGENDIAN
158                FrameSize == 2 * ChannelCount
159    #else
160                (Format & SF_FORMAT_SUBMASK) == SF_FORMAT_VORBIS
161    #endif
162                ) {
163                return sf_readf_short(pSndFile, static_cast<short*>(pBuffer), FrameCount);
164            } else
165    #endif
166            {
167                int bytes = sf_read_raw(pSndFile, pBuffer, FrameCount * GetFrameSize());
168                return bytes / GetFrameSize();
169            }
170      }      }
171    
172      unsigned long SampleFile::ReadAndLoop (      unsigned long SampleFile::ReadAndLoop (

Legend:
Removed from v.2058  
changed lines
  Added in v.2119

  ViewVC Help
Powered by ViewVC