/[svn]/linuxsampler/trunk/src/engines/common/AbstractVoice.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/common/AbstractVoice.cpp

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

revision 2219 by iliev, Thu Jul 28 12:35:49 2011 UTC revision 2297 by iliev, Fri Dec 9 15:04:55 2011 UTC
# Line 312  namespace LinuxSampler { Line 312  namespace LinuxSampler {
312       *  @param Skip    - number of sample points to skip in output buffer       *  @param Skip    - number of sample points to skip in output buffer
313       */       */
314      void AbstractVoice::Synthesize(uint Samples, sample_t* pSrc, uint Skip) {      void AbstractVoice::Synthesize(uint Samples, sample_t* pSrc, uint Skip) {
315            bool delay = false; // Whether the voice playback should be delayed for this call
316            
317            if (pSignalUnitRack != NULL) {
318                uint delaySteps = pSignalUnitRack->GetEndpointUnit()->DelayTrigger();
319                if (delaySteps > 0) { // delay on the endpoint unit means delay of the voice playback
320                    if (delaySteps >= Samples) {
321                        pSignalUnitRack->GetEndpointUnit()->DecreaseDelay(Samples);
322                        delay = true;
323                    } else {
324                        pSignalUnitRack->GetEndpointUnit()->DecreaseDelay(delaySteps);
325                        Samples -= delaySteps;
326                        Skip += delaySteps;
327                    }
328                }
329            }
330            
331          AbstractEngineChannel* pChannel = pEngineChannel;          AbstractEngineChannel* pChannel = pEngineChannel;
332          MidiKeyBase* pMidiKeyInfo = GetMidiKeyInfo(MIDIKey);          MidiKeyBase* pMidiKeyInfo = GetMidiKeyInfo(MIDIKey);
333    
334          const bool bVoiceRequiresDedicatedRouting =          const bool bVoiceRequiresDedicatedRouting =
335              pEngineChannel->GetFxSendCount() > 0 &&              pEngineChannel->GetFxSendCount() > 0 &&
336              (pMidiKeyInfo->ReverbSend || pMidiKeyInfo->ChorusSend);              (pMidiKeyInfo->ReverbSend || pMidiKeyInfo->ChorusSend);
337            
338          if (bVoiceRequiresDedicatedRouting) {          const bool bEq =
339                pSignalUnitRack != NULL && pSignalUnitRack->HasEq() && GetEngine()->pEq->HasSupport();
340    
341            if (bEq) {
342                GetEngine()->pEq->GetInChannelLeft()->Clear();
343                GetEngine()->pEq->GetInChannelRight()->Clear();
344                finalSynthesisParameters.pOutLeft  = &GetEngine()->pEq->GetInChannelLeft()->Buffer()[Skip];
345                finalSynthesisParameters.pOutRight = &GetEngine()->pEq->GetInChannelRight()->Buffer()[Skip];
346                pSignalUnitRack->UpdateEqSettings(GetEngine()->pEq);
347            } else if (bVoiceRequiresDedicatedRouting) {
348              finalSynthesisParameters.pOutLeft  = &GetEngine()->pDedicatedVoiceChannelLeft->Buffer()[Skip];              finalSynthesisParameters.pOutLeft  = &GetEngine()->pDedicatedVoiceChannelLeft->Buffer()[Skip];
349              finalSynthesisParameters.pOutRight = &GetEngine()->pDedicatedVoiceChannelRight->Buffer()[Skip];              finalSynthesisParameters.pOutRight = &GetEngine()->pDedicatedVoiceChannelRight->Buffer()[Skip];
350          } else {          } else {
# Line 395  namespace LinuxSampler { Line 420  namespace LinuxSampler {
420              // process transition events (note on, note off & sustain pedal)              // process transition events (note on, note off & sustain pedal)
421              processTransitionEvents(itNoteEvent, iSubFragmentEnd);              processTransitionEvents(itNoteEvent, iSubFragmentEnd);
422              processGroupEvents(itGroupEvent, iSubFragmentEnd);              processGroupEvents(itGroupEvent, iSubFragmentEnd);
423                
424              if (pSignalUnitRack == NULL) {              if (pSignalUnitRack == NULL) {
425                  // if the voice was killed in this subfragment, or if the                  // if the voice was killed in this subfragment, or if the
426                  // filter EG is finished, switch EG1 to fade out stage                  // filter EG is finished, switch EG1 to fade out stage
# Line 493  namespace LinuxSampler { Line 518  namespace LinuxSampler {
518                  fFinalVolume * VolumeRight * PanRightSmoother.render();                  fFinalVolume * VolumeRight * PanRightSmoother.render();
519  #endif  #endif
520              // render audio for one subfragment              // render audio for one subfragment
521              RunSynthesisFunction(SynthesisMode, &finalSynthesisParameters, &loop);              if (!delay) RunSynthesisFunction(SynthesisMode, &finalSynthesisParameters, &loop);
522    
523              if (pSignalUnitRack == NULL) {              if (pSignalUnitRack == NULL) {
524                  // stop the rendering if volume EG is finished                  // stop the rendering if volume EG is finished
# Line 530  namespace LinuxSampler { Line 555  namespace LinuxSampler {
555                      }*/                      }*/
556                  // TODO: ^^^                  // TODO: ^^^
557                                    
558                  pSignalUnitRack->Increment();                  if (!delay) pSignalUnitRack->Increment();
559              }              }
560    
561              Pos = newPos;              Pos = newPos;
562              i = iSubFragmentEnd;              i = iSubFragmentEnd;
563          }          }
564            
565            if (delay) return;
566    
567          if (bVoiceRequiresDedicatedRouting) {          if (bVoiceRequiresDedicatedRouting) {
568                if (bEq) {
569                    GetEngine()->pEq->RenderAudio(Samples);
570                    GetEngine()->pEq->GetOutChannelLeft()->CopyTo(GetEngine()->pDedicatedVoiceChannelLeft, Samples);
571                    GetEngine()->pEq->GetOutChannelRight()->CopyTo(GetEngine()->pDedicatedVoiceChannelRight, Samples);
572                }
573              optional<float> effectSendLevels[2] = {              optional<float> effectSendLevels[2] = {
574                  pMidiKeyInfo->ReverbSend,                  pMidiKeyInfo->ReverbSend,
575                  pMidiKeyInfo->ChorusSend                  pMidiKeyInfo->ChorusSend
576              };              };
577              GetEngine()->RouteDedicatedVoiceChannels(pEngineChannel, effectSendLevels, Samples);              GetEngine()->RouteDedicatedVoiceChannels(pEngineChannel, effectSendLevels, Samples);
578            } else if (bEq) {
579                GetEngine()->pEq->RenderAudio(Samples);
580                GetEngine()->pEq->GetOutChannelLeft()->CopyTo(pChannel->pChannelLeft, Samples);
581                GetEngine()->pEq->GetOutChannelRight()->CopyTo(pChannel->pChannelRight, Samples);
582          }          }
583      }      }
584    

Legend:
Removed from v.2219  
changed lines
  Added in v.2297

  ViewVC Help
Powered by ViewVC