/[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 330 by schoenebeck, Wed Dec 29 01:14:15 2004 UTC
# Line 61  namespace LinuxSampler { namespace gig { Line 61  namespace LinuxSampler { namespace gig {
61    
62          // select synthesis implementation (currently either pure C++ or MMX+SSE(1))          // select synthesis implementation (currently either pure C++ or MMX+SSE(1))
63          SYNTHESIS_MODE_SET_IMPLEMENTATION(SynthesisMode, Features::supportsMMX() && Features::supportsSSE());          SYNTHESIS_MODE_SET_IMPLEMENTATION(SynthesisMode, Features::supportsMMX() && Features::supportsSSE());
64            SYNTHESIS_MODE_SET_PROFILING(SynthesisMode, true);
65      }      }
66    
67      Voice::~Voice() {      Voice::~Voice() {
# Line 693  namespace LinuxSampler { namespace gig { Line 694  namespace LinuxSampler { namespace gig {
694                          }                          }
695                          DiskStreamRef.pStream->IncrementReadPos(pSample->Channels * (int(Pos) - MaxRAMPos));                          DiskStreamRef.pStream->IncrementReadPos(pSample->Channels * (int(Pos) - MaxRAMPos));
696                          Pos -= int(Pos);                          Pos -= int(Pos);
697                            RealSampleWordsLeftToRead = -1; // -1 means no silence has been added yet
698                      }                      }
699    
700                        const int sampleWordsLeftToRead = DiskStreamRef.pStream->GetReadSpace();
701    
702                      // 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)
703                      if (DiskStreamRef.State == Stream::state_end && DiskStreamRef.pStream->GetReadSpace() < (pEngine->MaxSamplesPerCycle << MAX_PITCH) / pSample->Channels) {                      if (DiskStreamRef.State == Stream::state_end) {
704                          DiskStreamRef.pStream->WriteSilence((pEngine->MaxSamplesPerCycle << MAX_PITCH) / pSample->Channels);                          const int maxSampleWordsPerCycle = (pEngine->MaxSamplesPerCycle << MAX_PITCH) * pSample->Channels + 6; // +6 for the interpolator algorithm
705                          this->PlaybackState = playback_state_end;                          if (sampleWordsLeftToRead <= maxSampleWordsPerCycle) {
706                                // remember how many sample words there are before any silence has been added
707                                if (RealSampleWordsLeftToRead < 0) RealSampleWordsLeftToRead = sampleWordsLeftToRead;
708                                DiskStreamRef.pStream->WriteSilence(maxSampleWordsPerCycle - sampleWordsLeftToRead);
709                            }
710                      }                      }
711    
712                      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 714  namespace LinuxSampler { namespace gig {
714                      // render current audio fragment                      // render current audio fragment
715                      Synthesize(Samples, ptr, Delay);                      Synthesize(Samples, ptr, Delay);
716    
717                      DiskStreamRef.pStream->IncrementReadPos(int(Pos) * pSample->Channels);                      const int iPos = (int) Pos;
718                      Pos -= int(Pos);                      const int readSampleWords = iPos * pSample->Channels; // amount of sample words actually been read
719                        DiskStreamRef.pStream->IncrementReadPos(readSampleWords);
720                        Pos -= iPos; // just keep fractional part of Pos
721    
722                        // change state of voice to 'end' if we really reached the end of the sample data
723                        if (RealSampleWordsLeftToRead >= 0) {
724                            RealSampleWordsLeftToRead -= readSampleWords;
725                            if (RealSampleWordsLeftToRead <= 0) this->PlaybackState = playback_state_end;
726                        }
727                  }                  }
728                  break;                  break;
729    
# Line 946  namespace LinuxSampler { namespace gig { Line 962  namespace LinuxSampler { namespace gig {
962    
963              //same as 'pEngine->pBasicFilterParameters[i] = bqbase;'              //same as 'pEngine->pBasicFilterParameters[i] = bqbase;'
964              bq    = (float*) &pEngine->pBasicFilterParameters[i];              bq    = (float*) &pEngine->pBasicFilterParameters[i];
965              bq[0] = bqbase.a1;              bq[0] = bqbase.b0;
966              bq[1] = bqbase.a2;              bq[1] = bqbase.b1;
967              bq[2] = bqbase.b0;              bq[2] = bqbase.b2;
968              bq[3] = bqbase.b1;              bq[3] = bqbase.a1;
969              bq[4] = bqbase.b2;              bq[4] = bqbase.a2;
970    
971              // same as 'pEngine->pMainFilterParameters[i] = bqmain;'              // same as 'pEngine->pMainFilterParameters[i] = bqmain;'
972              bq    = (float*) &pEngine->pMainFilterParameters[i];              bq    = (float*) &pEngine->pMainFilterParameters[i];
973              bq[0] = bqmain.a1;              bq[0] = bqmain.b0;
974              bq[1] = bqmain.a2;              bq[1] = bqmain.b1;
975              bq[2] = bqmain.b0;              bq[2] = bqmain.b2;
976              bq[3] = bqmain.b1;              bq[3] = bqmain.a1;
977              bq[4] = bqmain.b2;              bq[4] = bqmain.a2;
978          }          }
979      }      }
980    
# Line 970  namespace LinuxSampler { namespace gig { Line 986  namespace LinuxSampler { namespace gig {
986       *  @param pSrc    - pointer to input sample data       *  @param pSrc    - pointer to input sample data
987       *  @param Skip    - number of sample points to skip in output buffer       *  @param Skip    - number of sample points to skip in output buffer
988       */       */
989      void Voice::Synthesize(uint Samples, sample_t* pSrc, int Skip) {      void Voice::Synthesize(uint Samples, sample_t* pSrc, uint Skip) {
990          UpdateSynthesisMode();          RunSynthesisFunction(SynthesisMode, *this, Samples, pSrc, Skip);
         SynthesizeFragment_Fn* f = (SynthesizeFragment_Fn*) SynthesizeFragmentFnPtr;  
         f(*this, Samples, pSrc, Skip);  
     }  
   
     /**  
      *  Determine the respective synthesis function for the given synthesis  
      *  mode.  
      */  
     void Voice::UpdateSynthesisMode() {  
         SynthesizeFragmentFnPtr = GetSynthesisFunction(SynthesisMode);  
991      }      }
992    
993      /**      /**

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

  ViewVC Help
Powered by ViewVC