/[svn]/linuxsampler/trunk/src/engines/gig/Stream.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/gig/Stream.cpp

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

revision 902 by persson, Sun May 14 07:15:52 2006 UTC revision 903 by persson, Sat Jul 22 14:22:53 2006 UTC
# Line 38  namespace LinuxSampler { namespace gig { Line 38  namespace LinuxSampler { namespace gig {
38          ::gig::Sample* pSample = pDimRgn->pSample;          ::gig::Sample* pSample = pDimRgn->pSample;
39          long total_readsamples = 0, readsamples = 0;          long total_readsamples = 0, readsamples = 0;
40          long samplestoread = SampleCount / pSample->Channels;          long samplestoread = SampleCount / pSample->Channels;
41          sample_t* pBuf = pRingBuffer->get_write_ptr();          uint8_t* pBuf = pRingBuffer->get_write_ptr();
42          bool endofsamplereached;          bool endofsamplereached;
43    
44          // refill the disk stream buffer          // refill the disk stream buffer
# Line 52  namespace LinuxSampler { namespace gig { Line 52  namespace LinuxSampler { namespace gig {
52              pSample->SetPos(this->SampleOffset); // recover old position              pSample->SetPos(this->SampleOffset); // recover old position
53    
54              do {              do {
55                  readsamples        = pSample->Read(&pBuf[total_readsamples * pSample->Channels], samplestoread, pDecompressionBuffer);                  readsamples        = pSample->Read(&pBuf[total_readsamples * pSample->FrameSize], samplestoread, pDecompressionBuffer);
56                  samplestoread     -= readsamples;                  samplestoread     -= readsamples;
57                  total_readsamples += readsamples;                  total_readsamples += readsamples;
58              } while (samplestoread && readsamples > 0);              } while (samplestoread && readsamples > 0);
# Line 66  namespace LinuxSampler { namespace gig { Line 66  namespace LinuxSampler { namespace gig {
66    
67          // we must delay the increment_write_ptr_with_wrap() after the while() loop because we need to          // we must delay the increment_write_ptr_with_wrap() after the while() loop because we need to
68          // ensure that we read exactly SampleCount sample, otherwise the buffer wrapping code will fail          // ensure that we read exactly SampleCount sample, otherwise the buffer wrapping code will fail
69          pRingBuffer->increment_write_ptr_with_wrap(total_readsamples * pSample->Channels);          pRingBuffer->increment_write_ptr_with_wrap(total_readsamples * pSample->FrameSize);
70    
71          // update stream state          // update stream state
72          if (endofsamplereached) SetState(state_end);          if (endofsamplereached) SetState(state_end);
# Line 76  namespace LinuxSampler { namespace gig { Line 76  namespace LinuxSampler { namespace gig {
76      }      }
77    
78      void Stream::WriteSilence(unsigned long SilenceSampleWords) {      void Stream::WriteSilence(unsigned long SilenceSampleWords) {
79          memset(pRingBuffer->get_write_ptr(), 0, SilenceSampleWords * 2);          memset(pRingBuffer->get_write_ptr(), 0, SilenceSampleWords * BytesPerSample);
80          pRingBuffer->increment_write_ptr_with_wrap(SilenceSampleWords);          pRingBuffer->increment_write_ptr_with_wrap(SilenceSampleWords * BytesPerSample);
81      }      }
82    
83      Stream::Stream( ::gig::buffer_t* pDecompressionBuffer, uint BufferSize, uint BufferWrapElements) {      Stream::Stream( ::gig::buffer_t* pDecompressionBuffer, uint BufferSize, uint BufferWrapElements) {
# Line 88  namespace LinuxSampler { namespace gig { Line 88  namespace LinuxSampler { namespace gig {
88          this->SampleOffset           = 0;          this->SampleOffset           = 0;
89          this->PlaybackState.position = 0;          this->PlaybackState.position = 0;
90          this->PlaybackState.reverse  = false;          this->PlaybackState.reverse  = false;
91          this->pRingBuffer            = new RingBuffer<sample_t>(BufferSize, BufferWrapElements);          this->pRingBuffer            = new RingBuffer<uint8_t>(BufferSize * 3, BufferWrapElements * 3);
92          this->pDecompressionBuffer   = pDecompressionBuffer;          this->pDecompressionBuffer   = pDecompressionBuffer;
93          UnusedStreams++;          UnusedStreams++;
94          TotalStreams++;          TotalStreams++;
# Line 112  namespace LinuxSampler { namespace gig { Line 112  namespace LinuxSampler { namespace gig {
112          this->PlaybackState.reverse          = false;          this->PlaybackState.reverse          = false;
113          this->PlaybackState.loop_cycles_left = pDimRgn->pSample->LoopPlayCount;          this->PlaybackState.loop_cycles_left = pDimRgn->pSample->LoopPlayCount;
114          this->DoLoop                         = DoLoop;          this->DoLoop                         = DoLoop;
115            BytesPerSample                       = pDimRgn->pSample->BitDepth / 8;
116          SetState(state_active);          SetState(state_active);
117      }      }
118    

Legend:
Removed from v.902  
changed lines
  Added in v.903

  ViewVC Help
Powered by ViewVC