/[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 3724 by schoenebeck, Thu Dec 15 12:47:45 2016 UTC revision 3725 by schoenebeck, Thu Jan 23 18:45:00 2020 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-2008 Christian Schoenebeck                         *   *   Copyright (C) 2005-2020 Christian Schoenebeck                         *
7   *   Copyright (C) 2009-2011 Christian Schoenebeck and Grigor Iliev        *   *   Copyright (C) 2009-2011 Grigor Iliev                                  *
  *   Copyright (C) 2012-2016 Christian Schoenebeck                         *  
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 27  Line 26 
26  #define __LS_VOICEBASE_H__  #define __LS_VOICEBASE_H__
27    
28  #include "AbstractVoice.h"  #include "AbstractVoice.h"
29    #include <limits.h> // for INT_MIN
30    
31    /*
32     * Used as private, special constant value for @c VoiceBase member variable
33     * @c RealSampleWordsLeftToRead. This special constant value denotes that no
34     * silence samples have been added to the end of the stream yet.
35     */
36    #define NO_SILENCE_STREAM_SAMPLES_YET INT_MIN
37    
38  namespace LinuxSampler {  namespace LinuxSampler {
39    
# Line 147  namespace LinuxSampler { Line 154  namespace LinuxSampler {
154                                      SmplInfo.ChannelCount * (int(finalSynthesisParameters.dPos) - MaxRAMPos)                                      SmplInfo.ChannelCount * (int(finalSynthesisParameters.dPos) - MaxRAMPos)
155                                  ));                                  ));
156                                  finalSynthesisParameters.dPos -= int(finalSynthesisParameters.dPos);                                  finalSynthesisParameters.dPos -= int(finalSynthesisParameters.dPos);
157                                  RealSampleWordsLeftToRead = -1; // -1 means no silence has been added yet                                  RealSampleWordsLeftToRead = NO_SILENCE_STREAM_SAMPLES_YET;
158                              }                              }
159    
160                              const int sampleWordsLeftToRead = DiskStreamRef.pStream->GetReadSpace();                              const int sampleWordsLeftToRead = DiskStreamRef.pStream->GetReadSpace();
161    
162                              // add silence sample at the end if we reached the end of the stream (for the interpolator)                              // add silence sample at the end if we reached the end of the stream (for the interpolator)
163                              if (DiskStreamRef.State == Stream::state_end) {                              if (DiskStreamRef.State == Stream::state_end) {
164                                  const int maxSampleWordsPerCycle = (GetEngine()->MaxSamplesPerCycle << CONFIG_MAX_PITCH) * SmplInfo.ChannelCount + 6; // +6 for the interpolator algorithm                                  if (RealSampleWordsLeftToRead == NO_SILENCE_STREAM_SAMPLES_YET) {
                                 if (sampleWordsLeftToRead <= maxSampleWordsPerCycle) {  
165                                      // remember how many sample words there are before any silence has been added                                      // remember how many sample words there are before any silence has been added
166                                      if (RealSampleWordsLeftToRead < 0) RealSampleWordsLeftToRead = sampleWordsLeftToRead;                                      RealSampleWordsLeftToRead = sampleWordsLeftToRead;
167                                    }
168                                    const int maxSampleWordsPerCycle = (GetEngine()->MaxSamplesPerCycle << CONFIG_MAX_PITCH) * SmplInfo.ChannelCount + 6; // +6 for the interpolator algorithm
169                                    if (sampleWordsLeftToRead < maxSampleWordsPerCycle) {
170                                      DiskStreamRef.pStream->WriteSilence(maxSampleWordsPerCycle - sampleWordsLeftToRead);                                      DiskStreamRef.pStream->WriteSilence(maxSampleWordsPerCycle - sampleWordsLeftToRead);
171                                  }                                  }
172                              }                              }
# Line 175  namespace LinuxSampler { Line 184  namespace LinuxSampler {
184                              // change state of voice to 'end' if we really reached the end of the sample data                              // change state of voice to 'end' if we really reached the end of the sample data
185                              if (RealSampleWordsLeftToRead >= 0) {                              if (RealSampleWordsLeftToRead >= 0) {
186                                  RealSampleWordsLeftToRead -= readSampleWords;                                  RealSampleWordsLeftToRead -= readSampleWords;
187                                  if (RealSampleWordsLeftToRead <= 0) this->PlaybackState = Voice::playback_state_end;                                  if (RealSampleWordsLeftToRead <= 0) {
188                                        this->PlaybackState = Voice::playback_state_end;
189                                        RealSampleWordsLeftToRead = 0;
190                                    }
191                              }                              }
192                          }                          }
193                          break;                          break;

Legend:
Removed from v.3724  
changed lines
  Added in v.3725

  ViewVC Help
Powered by ViewVC