/[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 832 by persson, Sun Feb 5 10:24:05 2006 UTC revision 865 by persson, Sun May 14 07:15:52 2006 UTC
# Line 153  namespace LinuxSampler { namespace gig { Line 153  namespace LinuxSampler { namespace gig {
153          long cachedsamples = pSample->GetCache().Size / pSample->FrameSize;          long cachedsamples = pSample->GetCache().Size / pSample->FrameSize;
154          DiskVoice          = cachedsamples < pSample->SamplesTotal;          DiskVoice          = cachedsamples < pSample->SamplesTotal;
155    
156            const DLS::sample_loop_t& loopinfo = pDimRgn->pSampleLoops[0];
157    
158          if (DiskVoice) { // voice to be streamed from disk          if (DiskVoice) { // voice to be streamed from disk
159              MaxRAMPos = cachedsamples - (pEngine->MaxSamplesPerCycle << CONFIG_MAX_PITCH) / pSample->Channels; //TODO: this calculation is too pessimistic and may better be moved to Render() method, so it calculates MaxRAMPos dependent to the current demand of sample points to be rendered (e.g. in case of JACK)              MaxRAMPos = cachedsamples - (pEngine->MaxSamplesPerCycle << CONFIG_MAX_PITCH) / pSample->Channels; //TODO: this calculation is too pessimistic and may better be moved to Render() method, so it calculates MaxRAMPos dependent to the current demand of sample points to be rendered (e.g. in case of JACK)
160    
161              // check if there's a loop defined which completely fits into the cached (RAM) part of the sample              // check if there's a loop defined which completely fits into the cached (RAM) part of the sample
162              RAMLoop = (pSample->Loops && pSample->LoopEnd <= MaxRAMPos);              RAMLoop = (pDimRgn->SampleLoops && (loopinfo.LoopStart + loopinfo.LoopLength) <= MaxRAMPos);
163    
164              if (pDiskThread->OrderNewStream(&DiskStreamRef, pSample, MaxRAMPos, !RAMLoop) < 0) {              if (pDiskThread->OrderNewStream(&DiskStreamRef, pDimRgn, MaxRAMPos, !RAMLoop) < 0) {
165                  dmsg(1,("Disk stream order failed!\n"));                  dmsg(1,("Disk stream order failed!\n"));
166                  KillImmediately();                  KillImmediately();
167                  return -1;                  return -1;
# Line 168  namespace LinuxSampler { namespace gig { Line 170  namespace LinuxSampler { namespace gig {
170          }          }
171          else { // RAM only voice          else { // RAM only voice
172              MaxRAMPos = cachedsamples;              MaxRAMPos = cachedsamples;
173              RAMLoop = (pSample->Loops != 0);              RAMLoop = (pDimRgn->SampleLoops != 0);
174              dmsg(4,("RAM only voice launched (Looping: %s)\n", (RAMLoop) ? "yes" : "no"));              dmsg(4,("RAM only voice launched (Looping: %s)\n", (RAMLoop) ? "yes" : "no"));
175          }          }
176          if (RAMLoop) {          if (RAMLoop) {
177              loop.uiTotalCycles = pSample->LoopPlayCount;              loop.uiTotalCycles = pSample->LoopPlayCount;
178              loop.uiCyclesLeft  = pSample->LoopPlayCount;              loop.uiCyclesLeft  = pSample->LoopPlayCount;
179              loop.uiStart       = pSample->LoopStart;              loop.uiStart       = loopinfo.LoopStart;
180              loop.uiEnd         = pSample->LoopEnd;              loop.uiEnd         = loopinfo.LoopStart + loopinfo.LoopLength;
181              loop.uiSize        = pSample->LoopSize;              loop.uiSize        = loopinfo.LoopLength;
182          }          }
183    
184          // calculate initial pitch value          // calculate initial pitch value
# Line 335  namespace LinuxSampler { namespace gig { Line 337  namespace LinuxSampler { namespace gig {
337                      pLFO1->ExtController = 0; // no external controller                      pLFO1->ExtController = 0; // no external controller
338                      bLFO1Enabled         = false;                      bLFO1Enabled         = false;
339              }              }
340              if (bLFO1Enabled) pLFO1->trigger(pDimRgn->LFO1Frequency,              if (bLFO1Enabled) {
341                                               start_level_max,                  pLFO1->trigger(pDimRgn->LFO1Frequency,
342                                               lfo1_internal_depth,                                 start_level_max,
343                                               pDimRgn->LFO1ControlDepth,                                 lfo1_internal_depth,
344                                               pDimRgn->LFO1FlipPhase,                                 pDimRgn->LFO1ControlDepth,
345                                               pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                                 pDimRgn->LFO1FlipPhase,
346                                   pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
347                    pLFO1->update(pLFO1->ExtController ? pEngineChannel->ControllerTable[pLFO1->ExtController] : 0);
348                }
349          }          }
350    
351    
# Line 378  namespace LinuxSampler { namespace gig { Line 383  namespace LinuxSampler { namespace gig {
383                      pLFO2->ExtController = 0; // no external controller                      pLFO2->ExtController = 0; // no external controller
384                      bLFO2Enabled         = false;                      bLFO2Enabled         = false;
385              }              }
386              if (bLFO2Enabled) pLFO2->trigger(pDimRgn->LFO2Frequency,              if (bLFO2Enabled) {
387                                               start_level_max,                  pLFO2->trigger(pDimRgn->LFO2Frequency,
388                                               lfo2_internal_depth,                                 start_level_max,
389                                               pDimRgn->LFO2ControlDepth,                                 lfo2_internal_depth,
390                                               pDimRgn->LFO2FlipPhase,                                 pDimRgn->LFO2ControlDepth,
391                                               pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                                 pDimRgn->LFO2FlipPhase,
392                                   pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
393                    pLFO2->update(pLFO2->ExtController ? pEngineChannel->ControllerTable[pLFO2->ExtController] : 0);
394                }
395          }          }
396    
397    
# Line 421  namespace LinuxSampler { namespace gig { Line 429  namespace LinuxSampler { namespace gig {
429                      pLFO3->ExtController = 0; // no external controller                      pLFO3->ExtController = 0; // no external controller
430                      bLFO3Enabled         = false;                      bLFO3Enabled         = false;
431              }              }
432              if (bLFO3Enabled) pLFO3->trigger(pDimRgn->LFO3Frequency,              if (bLFO3Enabled) {
433                                               start_level_mid,                  pLFO3->trigger(pDimRgn->LFO3Frequency,
434                                               lfo3_internal_depth,                                 start_level_mid,
435                                               pDimRgn->LFO3ControlDepth,                                 lfo3_internal_depth,
436                                               false,                                 pDimRgn->LFO3ControlDepth,
437                                               pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                                 false,
438                                   pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
439                    pLFO3->update(pLFO3->ExtController ? pEngineChannel->ControllerTable[pLFO3->ExtController] : 0);
440                }
441          }          }
442    
443    
# Line 871  namespace LinuxSampler { namespace gig { Line 882  namespace LinuxSampler { namespace gig {
882              if (EG1.active()) {              if (EG1.active()) {
883    
884                  // if sample has a loop and loop start has been reached in this subfragment, send a special event to EG1 to let it finish the attack hold stage                  // if sample has a loop and loop start has been reached in this subfragment, send a special event to EG1 to let it finish the attack hold stage
885                  if (pSample->Loops && Pos <= pSample->LoopStart && pSample->LoopStart < newPos) {                  if (pDimRgn->SampleLoops && Pos <= pDimRgn->pSampleLoops[0].LoopStart && pDimRgn->pSampleLoops[0].LoopStart < newPos) {
886                      EG1.update(EGADSR::event_hold_end, pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                      EG1.update(EGADSR::event_hold_end, pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
887                  }                  }
888    

Legend:
Removed from v.832  
changed lines
  Added in v.865

  ViewVC Help
Powered by ViewVC