/[svn]/linuxsampler/trunk/src/engines/common/VoiceBase.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/common/VoiceBase.h

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

revision 2015 by iliev, Sun Oct 25 22:22:52 2009 UTC revision 2217 by iliev, Tue Jul 26 15:51:30 2011 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck    *   *   Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck    *
6   *   Copyright (C) 2005-2009 Christian Schoenebeck                         *   *   Copyright (C) 2005-2008 Christian Schoenebeck                         *
7   *   Copyright (C) 2009 Grigor Iliev                                       *   *   Copyright (C) 2009-2010 Christian Schoenebeck and Grigor Iliev        *
8   *                                                                         *   *                                                                         *
9   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
10   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 35  namespace LinuxSampler { Line 35  namespace LinuxSampler {
35              D*   pDiskThread;  ///< Pointer to the disk thread, to be able to order a disk stream and later to delete the stream again              D*   pDiskThread;  ///< Pointer to the disk thread, to be able to order a disk stream and later to delete the stream again
36              int  RealSampleWordsLeftToRead; ///< Number of samples left to read, not including the silence added for the interpolator              int  RealSampleWordsLeftToRead; ///< Number of samples left to read, not including the silence added for the interpolator
37    
38              VoiceBase() {              VoiceBase(SignalUnitRack* pRack = NULL): AbstractVoice(pRack) {
39                  pRegion      = NULL;                  pRegion      = NULL;
40                  pDiskThread  = NULL;                  pDiskThread  = NULL;
41              }              }
# Line 79  namespace LinuxSampler { Line 79  namespace LinuxSampler {
79    
80              virtual int OrderNewStream() {              virtual int OrderNewStream() {
81                  int res = pDiskThread->OrderNewStream (                  int res = pDiskThread->OrderNewStream (
82                      &DiskStreamRef, pRegion, MaxRAMPos, !RAMLoop                      &DiskStreamRef, pRegion, MaxRAMPos + GetRAMCacheOffset(), !RAMLoop
83                  );                  );
84    
85                  if (res < 0) {                  if (res < 0) {
# Line 90  namespace LinuxSampler { Line 90  namespace LinuxSampler {
90    
91                  return 0;                  return 0;
92              }              }
93                
94                /** The offset of the RAM cache from the sample start (in sample units). */
95                virtual int GetRAMCacheOffset() { return 0; }
96    
97              /**              /**
98               *  Renders the audio data for this voice for the current audio fragment.               *  Renders the audio data for this voice for the current audio fragment.
# Line 121  namespace LinuxSampler { Line 124  namespace LinuxSampler {
124                              if (DiskVoice) {                              if (DiskVoice) {
125                                  // check if we reached the allowed limit of the sample RAM cache                                  // check if we reached the allowed limit of the sample RAM cache
126                                  if (finalSynthesisParameters.dPos > MaxRAMPos) {                                  if (finalSynthesisParameters.dPos > MaxRAMPos) {
127                                      dmsg(5,("Voice: switching to disk playback (Pos=%f)\n", finalSynthesisParameters.dPos));                                      dmsg(5,("VoiceBase: switching to disk playback (Pos=%f)\n", finalSynthesisParameters.dPos));
128                                      this->PlaybackState = Voice::playback_state_disk;                                      this->PlaybackState = Voice::playback_state_disk;
129                                  }                                  }
130                              } else if (finalSynthesisParameters.dPos >= pSample->GetCache().Size / SmplInfo.FrameSize) {                              } else if (finalSynthesisParameters.dPos >= pSample->GetCache().Size / SmplInfo.FrameSize) {
# Line 175  namespace LinuxSampler { Line 178  namespace LinuxSampler {
178                          break;                          break;
179    
180                      case Voice::playback_state_end:                      case Voice::playback_state_end:
181                          std::cerr << "gig::Voice::Render(): entered with playback_state_end, this is a bug!\n" << std::flush;                          std::cerr << "VoiceBase::Render(): entered with playback_state_end, this is a bug!\n" << std::flush;
182                          break;                          break;
183                  }                  }
184    
# Line 185  namespace LinuxSampler { Line 188  namespace LinuxSampler {
188                  itTriggerEvent = Pool<Event>::Iterator();                  itTriggerEvent = Pool<Event>::Iterator();
189    
190                  // If sample stream or release stage finished, kill the voice                  // If sample stream or release stage finished, kill the voice
191                  if (                  if (PlaybackState == Voice::playback_state_end || EG1Finished()) {
192                      PlaybackState == Voice::playback_state_end ||                      KillImmediately();
193                      EG1.getSegmentType() == gig::EGADSR::segment_end                  }
                 ) KillImmediately();  
194              }              }
195    
196              /**              /**
# Line 227  namespace LinuxSampler { Line 229  namespace LinuxSampler {
229              S*  pSample;   ///< Pointer to the sample to be played back              S*  pSample;   ///< Pointer to the sample to be played back
230              R*  pRegion;   ///< Pointer to the articulation information of current region of this voice              R*  pRegion;   ///< Pointer to the articulation information of current region of this voice
231    
232                virtual MidiKeyBase* GetMidiKeyInfo(int MIDIKey) {
233                    EC* pChannel = static_cast<EC*>(pEngineChannel);
234                    return &pChannel->pMIDIKeyInfo[MIDIKey];
235                }
236    
237              virtual unsigned long GetNoteOnTime(int MIDIKey) {              virtual unsigned long GetNoteOnTime(int MIDIKey) {
238                  EC* pChannel = static_cast<EC*>(pEngineChannel);                  EC* pChannel = static_cast<EC*>(pEngineChannel);
239                  return pChannel->pMIDIKeyInfo[MIDIKey].NoteOnTime;                  return pChannel->pMIDIKeyInfo[MIDIKey].NoteOnTime;

Legend:
Removed from v.2015  
changed lines
  Added in v.2217

  ViewVC Help
Powered by ViewVC