/[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 238 by schoenebeck, Thu Sep 9 18:44:18 2004 UTC revision 239 by schoenebeck, Sun Sep 12 14:48:19 2004 UTC
# Line 57  namespace LinuxSampler { namespace gig { Line 57  namespace LinuxSampler { namespace gig {
57          pLFO1  = NULL;          pLFO1  = NULL;
58          pLFO2  = NULL;          pLFO2  = NULL;
59          pLFO3  = NULL;          pLFO3  = NULL;
60            KeyGroup = 0;
61      }      }
62    
63      Voice::~Voice() {      Voice::~Voice() {
# Line 122  namespace LinuxSampler { namespace gig { Line 123  namespace LinuxSampler { namespace gig {
123          PlaybackState   = playback_state_ram; // we always start playback from RAM cache and switch then to disk if needed          PlaybackState   = playback_state_ram; // we always start playback from RAM cache and switch then to disk if needed
124          Delay           = pNoteOnEvent->FragmentPos();          Delay           = pNoteOnEvent->FragmentPos();
125          pTriggerEvent   = pNoteOnEvent;          pTriggerEvent   = pNoteOnEvent;
126            pKillEvent      = NULL;
127    
128          if (!pRegion) {          if (!pRegion) {
129              std::cerr << "gig::Voice: No Region defined for MIDI key " << MIDIKey << std::endl << std::flush;              std::cerr << "gig::Voice: No Region defined for MIDI key " << MIDIKey << std::endl << std::flush;
130              Kill();              KillImmediately();
131              return -1;              return -1;
132          }          }
133    
134            KeyGroup = pRegion->KeyGroup;
135    
136          // get current dimension values to select the right dimension region          // get current dimension values to select the right dimension region
137          //FIXME: controller values for selecting the dimension region here are currently not sample accurate          //FIXME: controller values for selecting the dimension region here are currently not sample accurate
138          uint DimValues[5] = {0,0,0,0,0};          uint DimValues[5] = {0,0,0,0,0};
# Line 270  namespace LinuxSampler { namespace gig { Line 274  namespace LinuxSampler { namespace gig {
274    
275              if (pDiskThread->OrderNewStream(&DiskStreamRef, pSample, MaxRAMPos, !RAMLoop) < 0) {              if (pDiskThread->OrderNewStream(&DiskStreamRef, pSample, MaxRAMPos, !RAMLoop) < 0) {
276                  dmsg(1,("Disk stream order failed!\n"));                  dmsg(1,("Disk stream order failed!\n"));
277                  Kill();                  KillImmediately();
278                  return -1;                  return -1;
279              }              }
280              dmsg(4,("Disk voice launched (cached samples: %d, total Samples: %d, MaxRAMPos: %d, RAMLooping: %s)\n", cachedsamples, pSample->SamplesTotal, MaxRAMPos, (RAMLoop) ? "yes" : "no"));              dmsg(4,("Disk voice launched (cached samples: %d, total Samples: %d, MaxRAMPos: %d, RAMLooping: %s)\n", cachedsamples, pSample->SamplesTotal, MaxRAMPos, (RAMLoop) ? "yes" : "no"));
# Line 601  namespace LinuxSampler { namespace gig { Line 605  namespace LinuxSampler { namespace gig {
605          }          }
606      #endif // ENABLE_FILTER      #endif // ENABLE_FILTER
607    
         // ************************************************  
         // TODO: ARTICULATION DATA HANDLING IS MISSING HERE  
         // ************************************************  
   
608          return 0; // success          return 0; // success
609      }      }
610    
# Line 635  namespace LinuxSampler { namespace gig { Line 635  namespace LinuxSampler { namespace gig {
635    
636    
637          // Let all modulators write their parameter changes to the synthesis parameter matrix for the current audio fragment          // Let all modulators write their parameter changes to the synthesis parameter matrix for the current audio fragment
638          pEG1->Process(Samples, pEngine->pMIDIKeyInfo[MIDIKey].pEvents, pTriggerEvent, this->Pos, this->PitchBase * this->PitchBend);          pEG1->Process(Samples, pEngine->pMIDIKeyInfo[MIDIKey].pEvents, pTriggerEvent, this->Pos, this->PitchBase * this->PitchBend, pKillEvent);
639      #if ENABLE_FILTER      #if ENABLE_FILTER
640          pEG2->Process(Samples, pEngine->pMIDIKeyInfo[MIDIKey].pEvents, pTriggerEvent, this->Pos, this->PitchBase * this->PitchBend);          pEG2->Process(Samples, pEngine->pMIDIKeyInfo[MIDIKey].pEvents, pTriggerEvent, this->Pos, this->PitchBase * this->PitchBend);
641      #endif // ENABLE_FILTER      #endif // ENABLE_FILTER
# Line 676  namespace LinuxSampler { namespace gig { Line 676  namespace LinuxSampler { namespace gig {
676                          DiskStreamRef.pStream = pDiskThread->AskForCreatedStream(DiskStreamRef.OrderID);                          DiskStreamRef.pStream = pDiskThread->AskForCreatedStream(DiskStreamRef.OrderID);
677                          if (!DiskStreamRef.pStream) {                          if (!DiskStreamRef.pStream) {
678                              std::cout << stderr << "Disk stream not available in time!" << std::endl << std::flush;                              std::cout << stderr << "Disk stream not available in time!" << std::endl << std::flush;
679                              Kill();                              KillImmediately();
680                              return;                              return;
681                          }                          }
682                          DiskStreamRef.pStream->IncrementReadPos(pSample->Channels * (RTMath::DoubleToInt(Pos) - MaxRAMPos));                          DiskStreamRef.pStream->IncrementReadPos(pSample->Channels * (RTMath::DoubleToInt(Pos) - MaxRAMPos));
# Line 697  namespace LinuxSampler { namespace gig { Line 697  namespace LinuxSampler { namespace gig {
697                  break;                  break;
698    
699              case playback_state_end:              case playback_state_end:
700                  Kill(); // free voice                  KillImmediately(); // free voice
701                  break;                  break;
702          }          }
703    
# Line 1062  namespace LinuxSampler { namespace gig { Line 1062  namespace LinuxSampler { namespace gig {
1062      }      }
1063    
1064      /**      /**
1065       *  Immediately kill the voice.       *  Immediately kill the voice. This method should not be used to kill
1066         *  a normal, active voice, because it doesn't take care of things like
1067         *  fading down the volume level to avoid clicks and regular processing
1068         *  until the kill event actually occured!
1069         *
1070         *  @see Kill()
1071       */       */
1072      void Voice::Kill() {      void Voice::KillImmediately() {
1073          if (DiskVoice && DiskStreamRef.State != Stream::state_unused) {          if (DiskVoice && DiskStreamRef.State != Stream::state_unused) {
1074              pDiskThread->OrderDeletionOfStream(&DiskStreamRef);              pDiskThread->OrderDeletionOfStream(&DiskStreamRef);
1075          }          }
1076          Reset();          Reset();
1077      }      }
1078    
1079        /**
1080         *  Kill the voice in regular sense. Let the voice render audio until
1081         *  the kill event actually occured and then fade down the volume level
1082         *  very quickly and let the voice die finally. Unlike a normal release
1083         *  of a voice, a kill process cannot be cancalled and is therefore
1084         *  usually used for voice stealing and key group conflicts.
1085         *
1086         *  @param pKillEvent - event which caused the voice to be killed
1087         */
1088        void Voice::Kill(Event* pKillEvent) {
1089            this->pKillEvent = pKillEvent;
1090        }
1091    
1092  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

Legend:
Removed from v.238  
changed lines
  Added in v.239

  ViewVC Help
Powered by ViewVC