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

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

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

revision 322 by senkov, Mon Dec 13 03:33:59 2004 UTC revision 323 by schoenebeck, Tue Dec 14 00:32:21 2004 UTC
# Line 695  namespace LinuxSampler { namespace gig { Line 695  namespace LinuxSampler { namespace gig {
695                          Pos -= int(Pos);                          Pos -= int(Pos);
696                      }                      }
697    
698                        const int sampleWordsLeftToRead = DiskStreamRef.pStream->GetReadSpace();
699    
700                      // add silence sample at the end if we reached the end of the stream (for the interpolator)                      // add silence sample at the end if we reached the end of the stream (for the interpolator)
701                      if (DiskStreamRef.State == Stream::state_end && DiskStreamRef.pStream->GetReadSpace() < (pEngine->MaxSamplesPerCycle << MAX_PITCH) / pSample->Channels) {                      if (DiskStreamRef.State == Stream::state_end) {
702                          DiskStreamRef.pStream->WriteSilence((pEngine->MaxSamplesPerCycle << MAX_PITCH) / pSample->Channels);                          const int maxSampleWordsPerCycle = (pEngine->MaxSamplesPerCycle << MAX_PITCH) * pSample->Channels + 6; // +6 for the interpolator algorithm
703                          this->PlaybackState = playback_state_end;                          if (sampleWordsLeftToRead <= maxSampleWordsPerCycle) {
704                                DiskStreamRef.pStream->WriteSilence(maxSampleWordsPerCycle - sampleWordsLeftToRead);
705                            }
706                      }                      }
707    
708                      sample_t* ptr = DiskStreamRef.pStream->GetReadPtr(); // get the current read_ptr within the ringbuffer where we read the samples from                      sample_t* ptr = DiskStreamRef.pStream->GetReadPtr(); // get the current read_ptr within the ringbuffer where we read the samples from
# Line 706  namespace LinuxSampler { namespace gig { Line 710  namespace LinuxSampler { namespace gig {
710                      // render current audio fragment                      // render current audio fragment
711                      Synthesize(Samples, ptr, Delay);                      Synthesize(Samples, ptr, Delay);
712    
713                      DiskStreamRef.pStream->IncrementReadPos(int(Pos) * pSample->Channels);                      const int iPos = (int) Pos;
714                      Pos -= int(Pos);                      const int readSampleWords = iPos * pSample->Channels; // amount of sample words actually been read
715                        DiskStreamRef.pStream->IncrementReadPos(readSampleWords);
716                        Pos -= iPos; // just keep fractional part of Pos
717    
718                        // change state of voice to 'end' if we really reached the end of the sample data
719                        if (DiskStreamRef.State == Stream::state_end && readSampleWords >= sampleWordsLeftToRead) this->PlaybackState = playback_state_end;
720                  }                  }
721                  break;                  break;
722    

Legend:
Removed from v.322  
changed lines
  Added in v.323

  ViewVC Help
Powered by ViewVC