/[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 2012 by iliev, Fri Oct 23 17:53:17 2009 UTC revision 2058 by persson, Sun Feb 14 11:40:49 2010 UTC
# Line 49  namespace LinuxSampler { Line 49  namespace LinuxSampler {
49          switch(Format & 0xF) {          switch(Format & 0xF) {
50              case SF_FORMAT_PCM_S8:              case SF_FORMAT_PCM_S8:
51              case SF_FORMAT_PCM_U8:              case SF_FORMAT_PCM_U8:
             case SF_FORMAT_PCM_16:  
52              case SF_FORMAT_DPCM_8:              case SF_FORMAT_DPCM_8:
53                    FrameSize = ChannelCount;
54                    break;
55                case SF_FORMAT_PCM_16:
56              case SF_FORMAT_DPCM_16:              case SF_FORMAT_DPCM_16:
57                  FrameSize = sizeof(short) * ChannelCount;                  FrameSize = 2 * ChannelCount;
58                    break;
59                case SF_FORMAT_PCM_24:
60                case SF_FORMAT_DWVW_24:
61                    FrameSize = 3 * ChannelCount;
62                  break;                  break;
63              default:              default:
64                  FrameSize = sizeof(int) * ChannelCount;                  FrameSize = 2 * ChannelCount;
65          }          }
66          TotalFrameCount = sfInfo.frames;          TotalFrameCount = sfInfo.frames;
67    
# Line 64  namespace LinuxSampler { Line 70  namespace LinuxSampler {
70    
71      SampleFile::~SampleFile() {      SampleFile::~SampleFile() {
72          Close();          Close();
73            ReleaseSampleData();
74      }      }
75    
76      void SampleFile::Open() {      void SampleFile::Open() {
# Line 138  namespace LinuxSampler { Line 145  namespace LinuxSampler {
145    
146      long SampleFile::Read(void* pBuffer, unsigned long FrameCount) {      long SampleFile::Read(void* pBuffer, unsigned long FrameCount) {
147          Open();          Open();
148          if(FrameSize == sizeof(short) * ChannelCount) {          int bytes = sf_read_raw(pSndFile, pBuffer, FrameCount * GetFrameSize());
149              return sf_readf_short(pSndFile, (short*)pBuffer, FrameCount);          return bytes / GetFrameSize();
         } else {  
             return sf_readf_int(pSndFile, (int*)pBuffer, FrameCount);  
         }  
150      }      }
151    
152      unsigned long SampleFile::ReadAndLoop (      unsigned long SampleFile::ReadAndLoop (
# Line 152  namespace LinuxSampler { Line 156  namespace LinuxSampler {
156      ) {      ) {
157          // TODO:          // TODO:
158          SetPos(pPlaybackState->position);          SetPos(pPlaybackState->position);
159          Read(pBuffer, FrameCount);          unsigned long count = Read(pBuffer, FrameCount);
160          pPlaybackState->position = GetPos();          pPlaybackState->position = GetPos();
161            return count;
162      }      }
163    
164      void SampleFile::ReleaseSampleData() {      void SampleFile::ReleaseSampleData() {

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

  ViewVC Help
Powered by ViewVC