/[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 2015 by iliev, Sun Oct 25 22:22:52 2009 UTC revision 2027 by iliev, Tue Nov 3 19:27:42 2009 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 1306  namespace LinuxSampler { Line 1305  namespace LinuxSampler {
1305    
1306              virtual int GetMinFadeOutSamples() { return MinFadeOutSamples; }              virtual int GetMinFadeOutSamples() { return MinFadeOutSamples; }
1307    
1308                int InitNewVoice (
1309                    EngineChannelBase<V, R, I>*  pChannel,
1310                    R*                           pRegion,
1311                    Pool<Event>::Iterator&       itNoteOnEvent,
1312                    Voice::type_t                VoiceType,
1313                    int                          iLayer,
1314                    int                          iKeyGroup,
1315                    bool                         ReleaseTriggerVoice,
1316                    bool                         VoiceStealing,
1317                    typename Pool<V>::Iterator&  itNewVoice
1318                ) {
1319                    int key = itNoteOnEvent->Param.Note.Key;
1320                    typename MidiKeyboardManager<V>::MidiKey* pKey = &pChannel->pMIDIKeyInfo[key];
1321                    if (itNewVoice) {
1322                        // launch the new voice
1323                        if (itNewVoice->Trigger(pChannel, itNoteOnEvent, pChannel->Pitch, pRegion, VoiceType, iKeyGroup) < 0) {
1324                            dmsg(4,("Voice not triggered\n"));
1325                            pKey->pActiveVoices->free(itNewVoice);
1326                        }
1327                        else { // on success
1328                            --VoiceSpawnsLeft;
1329                            if (!pKey->Active) { // mark as active key
1330                                pKey->Active = true;
1331                                pKey->itSelf = pChannel->pActiveKeys->allocAppend();
1332                                *pKey->itSelf = itNoteOnEvent->Param.Note.Key;
1333                            }
1334                            if (itNewVoice->KeyGroup) {
1335                                uint** ppKeyGroup = &pChannel->ActiveKeyGroups[itNewVoice->KeyGroup];
1336                                *ppKeyGroup = &*pKey->itSelf; // put key as the (new) active key to its key group
1337                            }
1338                            if (itNewVoice->Type == Voice::type_release_trigger_required) pKey->ReleaseTrigger = true; // mark key for the need of release triggered voice(s)
1339                            return 0; // success
1340                        }
1341                    }
1342                    else if (VoiceStealing) {
1343                        // try to steal one voice
1344                        int result = StealVoice(pChannel, itNoteOnEvent);
1345                        if (!result) { // voice stolen successfully
1346                            // put note-on event into voice-stealing queue, so it will be reprocessed after killed voice died
1347                            RTList<Event>::Iterator itStealEvent = pVoiceStealingQueue->allocAppend();
1348                            if (itStealEvent) {
1349                                *itStealEvent = *itNoteOnEvent; // copy event
1350                                itStealEvent->Param.Note.Layer = iLayer;
1351                                itStealEvent->Param.Note.ReleaseTrigger = ReleaseTriggerVoice;
1352                                pKey->VoiceTheftsQueued++;
1353                            }
1354                            else dmsg(1,("Voice stealing queue full!\n"));
1355                        }
1356                    }
1357    
1358                    return -1;
1359                }
1360    
1361          private:          private:
1362              Pool<V>*    pVoicePool;            ///< Contains all voices that can be activated.              Pool<V>*    pVoicePool;            ///< Contains all voices that can be activated.
1363              Pool<RR*>   SuspendedRegions;              Pool<RR*>   SuspendedRegions;

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

  ViewVC Help
Powered by ViewVC