/[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 3054 by schoenebeck, Thu Dec 15 12:47:45 2016 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-2011 Christian Schoenebeck and Grigor Iliev        *
8     *   Copyright (C) 2012-2016 Christian Schoenebeck                         *
9   *                                                                         *   *                                                                         *
10   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
11   *   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 36  namespace LinuxSampler {
36              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
37              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
38    
39              VoiceBase() {              VoiceBase(SignalUnitRack* pRack = NULL): AbstractVoice(pRack) {
40                  pRegion      = NULL;                  pRegion      = NULL;
41                  pDiskThread  = NULL;                  pDiskThread  = NULL;
42              }              }
# Line 79  namespace LinuxSampler { Line 80  namespace LinuxSampler {
80    
81              virtual int OrderNewStream() {              virtual int OrderNewStream() {
82                  int res = pDiskThread->OrderNewStream (                  int res = pDiskThread->OrderNewStream (
83                      &DiskStreamRef, pRegion, MaxRAMPos, !RAMLoop                      &DiskStreamRef, pRegion, MaxRAMPos + GetRAMCacheOffset(), !RAMLoop
84                  );                  );
85    
86                  if (res < 0) {                  if (res < 0) {
# Line 90  namespace LinuxSampler { Line 91  namespace LinuxSampler {
91    
92                  return 0;                  return 0;
93              }              }
94                
95                /** The offset of the RAM cache from the sample start (in sample units). */
96                virtual int GetRAMCacheOffset() { return 0; }
97    
98              /**              /**
99               *  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 125  namespace LinuxSampler {
125                              if (DiskVoice) {                              if (DiskVoice) {
126                                  // check if we reached the allowed limit of the sample RAM cache                                  // check if we reached the allowed limit of the sample RAM cache
127                                  if (finalSynthesisParameters.dPos > MaxRAMPos) {                                  if (finalSynthesisParameters.dPos > MaxRAMPos) {
128                                      dmsg(5,("Voice: switching to disk playback (Pos=%f)\n", finalSynthesisParameters.dPos));                                      dmsg(5,("VoiceBase: switching to disk playback (Pos=%f)\n", finalSynthesisParameters.dPos));
129                                      this->PlaybackState = Voice::playback_state_disk;                                      this->PlaybackState = Voice::playback_state_disk;
130                                  }                                  }
131                              } else if (finalSynthesisParameters.dPos >= pSample->GetCache().Size / SmplInfo.FrameSize) {                              } else if (finalSynthesisParameters.dPos >= pSample->GetCache().Size / SmplInfo.FrameSize) {
# Line 135  namespace LinuxSampler { Line 139  namespace LinuxSampler {
139                                  // check if the disk thread created our ordered disk stream in the meantime                                  // check if the disk thread created our ordered disk stream in the meantime
140                                  DiskStreamRef.pStream = pDiskThread->AskForCreatedStream(DiskStreamRef.OrderID);                                  DiskStreamRef.pStream = pDiskThread->AskForCreatedStream(DiskStreamRef.OrderID);
141                                  if (!DiskStreamRef.pStream) {                                  if (!DiskStreamRef.pStream) {
142                                      std::cout << stderr << "Disk stream not available in time!" << std::endl << std::flush;                                      std::cerr << "Disk stream not available in time!\n" << std::flush;
143                                      KillImmediately();                                      KillImmediately();
144                                      return;                                      return;
145                                  }                                  }
146                                  DiskStreamRef.pStream->IncrementReadPos(SmplInfo.ChannelCount * (int(finalSynthesisParameters.dPos) - MaxRAMPos));                                  DiskStreamRef.pStream->IncrementReadPos(uint(
147                                        SmplInfo.ChannelCount * (int(finalSynthesisParameters.dPos) - MaxRAMPos)
148                                    ));
149                                  finalSynthesisParameters.dPos -= int(finalSynthesisParameters.dPos);                                  finalSynthesisParameters.dPos -= int(finalSynthesisParameters.dPos);
150                                  RealSampleWordsLeftToRead = -1; // -1 means no silence has been added yet                                  RealSampleWordsLeftToRead = -1; // -1 means no silence has been added yet
151                              }                              }
# Line 175  namespace LinuxSampler { Line 181  namespace LinuxSampler {
181                          break;                          break;
182    
183                      case Voice::playback_state_end:                      case Voice::playback_state_end:
184                          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;
185                          break;                          break;
186                  }                  }
187    
# Line 185  namespace LinuxSampler { Line 191  namespace LinuxSampler {
191                  itTriggerEvent = Pool<Event>::Iterator();                  itTriggerEvent = Pool<Event>::Iterator();
192    
193                  // If sample stream or release stage finished, kill the voice                  // If sample stream or release stage finished, kill the voice
194                  if (                  if (PlaybackState == Voice::playback_state_end || EG1Finished()) {
195                      PlaybackState == Voice::playback_state_end ||                      KillImmediately();
196                      EG1.getSegmentType() == gig::EGADSR::segment_end                  }
                 ) KillImmediately();  
197              }              }
198    
199              /**              /**
# Line 227  namespace LinuxSampler { Line 232  namespace LinuxSampler {
232              S*  pSample;   ///< Pointer to the sample to be played back              S*  pSample;   ///< Pointer to the sample to be played back
233              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
234    
235                virtual MidiKeyBase* GetMidiKeyInfo(int MIDIKey) {
236                    EC* pChannel = static_cast<EC*>(pEngineChannel);
237                    return &pChannel->pMIDIKeyInfo[MIDIKey];
238                }
239    
240              virtual unsigned long GetNoteOnTime(int MIDIKey) {              virtual unsigned long GetNoteOnTime(int MIDIKey) {
241                  EC* pChannel = static_cast<EC*>(pEngineChannel);                  EC* pChannel = static_cast<EC*>(pEngineChannel);
242                  return pChannel->pMIDIKeyInfo[MIDIKey].NoteOnTime;                  return pChannel->pMIDIKeyInfo[MIDIKey].NoteOnTime;

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

  ViewVC Help
Powered by ViewVC