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

Diff of /linuxsampler/trunk/src/engines/EngineBase.h

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

revision 2012 by iliev, Fri Oct 23 17:53:17 2009 UTC revision 2043 by persson, Sat Jan 9 09:37:01 2010 UTC
# Line 564  namespace LinuxSampler { Line 564  namespace LinuxSampler {
564              int       MinFadeOutSamples;     ///< The number of samples needed to make an instant fade out (e.g. for voice stealing) without leading to clicks.              int       MinFadeOutSamples;     ///< The number of samples needed to make an instant fade out (e.g. for voice stealing) without leading to clicks.
565              D*        pDiskThread;              D*        pDiskThread;
566    
             int                          VoiceSpawnsLeft;       ///< We only allow CONFIG_MAX_VOICES voices to be spawned per audio fragment, we use this variable to ensure this limit.  
567              int                          ActiveVoiceCountTemp;  ///< number of currently active voices (for internal usage, will be used for incrementation)              int                          ActiveVoiceCountTemp;  ///< number of currently active voices (for internal usage, will be used for incrementation)
568              VoiceIterator                itLastStolenVoice;     ///< Only for voice stealing: points to the last voice which was theft in current audio fragment, NULL otherwise.              VoiceIterator                itLastStolenVoice;     ///< Only for voice stealing: points to the last voice which was theft in current audio fragment, NULL otherwise.
569              RTList<uint>::Iterator       iuiLastStolenKey;      ///< Only for voice stealing: key number of last key on which the last voice was theft in current audio fragment, NULL otherwise.              RTList<uint>::Iterator       iuiLastStolenKey;      ///< Only for voice stealing: key number of last key on which the last voice was theft in current audio fragment, NULL otherwise.
# Line 1097  namespace LinuxSampler { Line 1096  namespace LinuxSampler {
1096                      pKey->pEvents->free(itNoteOnEventOnKeyList);                      pKey->pEvents->free(itNoteOnEventOnKeyList);
1097    
1098                  if (!pChannel->SoloMode || pChannel->PortamentoPos < 0.0f) pChannel->PortamentoPos = (float) key;                  if (!pChannel->SoloMode || pChannel->PortamentoPos < 0.0f) pChannel->PortamentoPos = (float) key;
1099                  pKey->RoundRobinIndex++;                  if (pKey->pRoundRobinIndex) {
1100                        (*pKey->pRoundRobinIndex)++; // counter specific for the key or region
1101                        pChannel->RoundRobinIndex++; // common counter for the channel
1102                    }
1103                  pChannel->listeners.PostProcessNoteOn(key, vel);                  pChannel->listeners.PostProcessNoteOn(key, vel);
1104              }              }
1105    
# Line 1304  namespace LinuxSampler { Line 1306  namespace LinuxSampler {
1306                  bool                    HandleKeyGroupConflicts                  bool                    HandleKeyGroupConflicts
1307              ) = 0;              ) = 0;
1308    
1309                virtual int GetMinFadeOutSamples() { return MinFadeOutSamples; }
1310    
1311                int InitNewVoice (
1312                    EngineChannelBase<V, R, I>*  pChannel,
1313                    R*                           pRegion,
1314                    Pool<Event>::Iterator&       itNoteOnEvent,
1315                    Voice::type_t                VoiceType,
1316                    int                          iLayer,
1317                    int                          iKeyGroup,
1318                    bool                         ReleaseTriggerVoice,
1319                    bool                         VoiceStealing,
1320                    typename Pool<V>::Iterator&  itNewVoice
1321                ) {
1322                    int key = itNoteOnEvent->Param.Note.Key;
1323                    typename MidiKeyboardManager<V>::MidiKey* pKey = &pChannel->pMIDIKeyInfo[key];
1324                    if (itNewVoice) {
1325                        // launch the new voice
1326                        if (itNewVoice->Trigger(pChannel, itNoteOnEvent, pChannel->Pitch, pRegion, VoiceType, iKeyGroup) < 0) {
1327                            dmsg(4,("Voice not triggered\n"));
1328                            pKey->pActiveVoices->free(itNewVoice);
1329                        }
1330                        else { // on success
1331                            --VoiceSpawnsLeft;
1332                            if (!pKey->Active) { // mark as active key
1333                                pKey->Active = true;
1334                                pKey->itSelf = pChannel->pActiveKeys->allocAppend();
1335                                *pKey->itSelf = itNoteOnEvent->Param.Note.Key;
1336                            }
1337                            if (itNewVoice->KeyGroup) {
1338                                uint** ppKeyGroup = &pChannel->ActiveKeyGroups[itNewVoice->KeyGroup];
1339                                *ppKeyGroup = &*pKey->itSelf; // put key as the (new) active key to its key group
1340                            }
1341                            if (itNewVoice->Type == Voice::type_release_trigger_required) pKey->ReleaseTrigger = true; // mark key for the need of release triggered voice(s)
1342                            return 0; // success
1343                        }
1344                    }
1345                    else if (VoiceStealing) {
1346                        // try to steal one voice
1347                        int result = StealVoice(pChannel, itNoteOnEvent);
1348                        if (!result) { // voice stolen successfully
1349                            // put note-on event into voice-stealing queue, so it will be reprocessed after killed voice died
1350                            RTList<Event>::Iterator itStealEvent = pVoiceStealingQueue->allocAppend();
1351                            if (itStealEvent) {
1352                                *itStealEvent = *itNoteOnEvent; // copy event
1353                                itStealEvent->Param.Note.Layer = iLayer;
1354                                itStealEvent->Param.Note.ReleaseTrigger = ReleaseTriggerVoice;
1355                                pKey->VoiceTheftsQueued++;
1356                            }
1357                            else dmsg(1,("Voice stealing queue full!\n"));
1358                        }
1359                    }
1360    
1361                    return -1;
1362                }
1363    
1364          private:          private:
1365              Pool<V>*    pVoicePool;            ///< Contains all voices that can be activated.              Pool<V>*    pVoicePool;            ///< Contains all voices that can be activated.
1366              Pool<RR*>   SuspendedRegions;              Pool<RR*>   SuspendedRegions;

Legend:
Removed from v.2012  
changed lines
  Added in v.2043

  ViewVC Help
Powered by ViewVC