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

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

  ViewVC Help
Powered by ViewVC