--- linuxsampler/trunk/src/engines/EngineBase.h 2016/07/11 17:10:40 2938 +++ linuxsampler/trunk/src/engines/EngineBase.h 2017/01/05 16:04:00 3073 @@ -5,7 +5,7 @@ * Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * * Copyright (C) 2005-2008 Christian Schoenebeck * * Copyright (C) 2009-2012 Christian Schoenebeck and Grigor Iliev * - * Copyright (C) 2012-2016 Christian Schoenebeck and Andreas Persson * + * Copyright (C) 2012-2017 Christian Schoenebeck and Andreas Persson * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -58,7 +58,7 @@ typedef typename RTList::Iterator RootRegionIterator; typedef typename MidiKeyboardManager::MidiKey MidiKey; - EngineBase() : SuspendedRegions(128), noteIDPool(GLOBAL_MAX_NOTES) { + EngineBase() : noteIDPool(GLOBAL_MAX_NOTES), SuspendedRegions(128) { pDiskThread = NULL; pNotePool = new Pool< Note >(GLOBAL_MAX_NOTES); pNotePool->setPoolElementIDsReservedBits(INSTR_SCRIPT_EVENT_ID_RESERVED_BITS); @@ -163,6 +163,7 @@ dmsg(5,("Engine: Sysex received\n")); ProcessSysex(itEvent); break; + default: ; // noop } } } @@ -596,7 +597,7 @@ } // implementation of abstract method derived from class 'LinuxSampler::RegionPools' - virtual Pool* GetRegionPool(int index) { + virtual Pool* GetRegionPool(int index) OVERRIDE { if (index < 0 || index > 1) throw Exception("Index out of bounds"); return pRegionPool[index]; } @@ -604,7 +605,7 @@ // implementation of abstract methods derived from class 'LinuxSampler::NotePool' virtual Pool* GetVoicePool() OVERRIDE { return pVoicePool; } virtual Pool< Note >* GetNotePool() OVERRIDE { return pNotePool; } - virtual Pool* GetNodeIDPool() OVERRIDE { return ¬eIDPool; } + virtual Pool* GetNoteIDPool() OVERRIDE { return ¬eIDPool; } D* GetDiskThread() { return pDiskThread; } @@ -689,6 +690,9 @@ NoteIterator itNewNote = pNotePool->allocAppend(); const note_id_t newNoteID = pNotePool->getID(itNewNote); + // remember the engine's time when this note was triggered exactly + itNewNote->triggerSchedTime = pNoteOnEvent->SchedTime(); + // usually the new note (and its subsequent voices) will be // allocated on the key provided by the event's note number, // however if this new note is requested not to be a regular @@ -795,6 +799,18 @@ case Event::type_note_pressure: //TODO: ... break; + + case Event::type_sysex: + //TODO: ... + break; + + case Event::type_cancel_release_key: + case Event::type_release_key: + case Event::type_release_note: + case Event::type_play_note: + case Event::type_stop_note: + case Event::type_note_synth_param: + break; // noop } // see HACK comment above @@ -885,6 +901,13 @@ dmsg(5,("Engine: Note Synth Param received\n")); ProcessNoteSynthParam(itEvent->pEngineChannel, itEvent); break; + case Event::type_sysex: + break; // TODO ... + + case Event::type_cancel_release_key: + case Event::type_release_key: + case Event::type_release_note: + break; // noop } } } @@ -987,6 +1010,8 @@ itScriptEvent->cause = *itEvent; itScriptEvent->currentHandler = 0; itScriptEvent->executionSlices = 0; + itScriptEvent->ignoreAllWaitCalls = false; + itScriptEvent->handlerType = pEventHandler->eventHandlerType(); // this is the native representation of the $EVENT_ID script variable itScriptEvent->id = (itEvent->Type == Event::type_note_on) @@ -1254,14 +1279,19 @@ // the script's "init" event handler is only executed // once (when the script is loaded or reloaded) if (pEngineChannel->pScript && pEngineChannel->pScript->handlerInit) { + dmsg(5,("Engine: exec handlerInit %p\n", pEngineChannel->pScript->handlerInit)); RTList::Iterator itScriptEvent = pEngineChannel->pScript->pEvents->allocAppend(); itScriptEvent->cause.pEngineChannel = pEngineChannel; itScriptEvent->handlers[0] = pEngineChannel->pScript->handlerInit; itScriptEvent->handlers[1] = NULL; + itScriptEvent->currentHandler = 0; + itScriptEvent->executionSlices = 0; + itScriptEvent->ignoreAllWaitCalls = false; + itScriptEvent->handlerType = VM_EVENT_HANDLER_INIT; - VMExecStatus_t res = pScriptVM->exec( + /*VMExecStatus_t res = */ pScriptVM->exec( pEngineChannel->pScript->parserContext, &*itScriptEvent ); @@ -1601,7 +1631,7 @@ * @param pEngineChannel - engine channel on which this event occurred on * @param itNoteOnEvent - key, velocity and time stamp of the event */ - virtual void ProcessNoteOn(EngineChannel* pEngineChannel, Pool::Iterator& itNoteOnEvent) { + virtual void ProcessNoteOn(EngineChannel* pEngineChannel, Pool::Iterator& itNoteOnEvent) OVERRIDE { EngineChannelBase* pChannel = static_cast*>(pEngineChannel); @@ -1732,7 +1762,7 @@ * @param pEngineChannel - engine channel on which this event occurred on * @param itNoteOffEvent - key, velocity and time stamp of the event */ - virtual void ProcessNoteOff(EngineChannel* pEngineChannel, Pool::Iterator& itNoteOffEvent) { + virtual void ProcessNoteOff(EngineChannel* pEngineChannel, Pool::Iterator& itNoteOffEvent) OVERRIDE { EngineChannelBase* pChannel = static_cast*>(pEngineChannel); const int iKey = itNoteOffEvent->Param.Note.Key; @@ -1914,7 +1944,7 @@ * @param pEngineChannel - engine channel on which this event occurred on * @param itEvent - note synthesis parameter change event */ - virtual void ProcessNoteSynthParam(EngineChannel* pEngineChannel, RTList::Iterator& itEvent) OVERRIDE { + virtual void ProcessNoteSynthParam(EngineChannel* pEngineChannel, RTList::Iterator& itEvent) { EngineChannelBase* pChannel = static_cast*>(pEngineChannel); NoteBase* pNote = pChannel->pEngine->NoteByID( itEvent->Param.NoteSynthParam.NoteID ); @@ -1952,6 +1982,15 @@ case Event::synth_param_resonance: pNote->Override.Resonance = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta; break; + case Event::synth_param_attack: + pNote->Override.Attack = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta; + break; + case Event::synth_param_decay: + pNote->Override.Decay = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta; + break; + case Event::synth_param_release: + pNote->Override.Release = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta; + break; } // move note parameter event to its MIDI key @@ -1963,7 +2002,7 @@ * Reset all voices and disk thread and clear input event queue and all * control and status variables. This method is protected by a mutex. */ - virtual void ResetInternal() { + virtual void ResetInternal() OVERRIDE { LockGuard lock(ResetInternalMutex); // make sure that the engine does not get any sysex messages @@ -2022,7 +2061,7 @@ * @param pEngineChannel - engine channel on which all voices should be killed * @param itKillEvent - event which caused this killing of all voices */ - virtual void KillAllVoices(EngineChannel* pEngineChannel, Pool::Iterator& itKillEvent) { + virtual void KillAllVoices(EngineChannel* pEngineChannel, Pool::Iterator& itKillEvent) OVERRIDE { EngineChannelBase* pChannel = static_cast*>(pEngineChannel); int count = pChannel->KillAllVoices(itKillEvent); VoiceSpawnsLeft -= count; //FIXME: just a temporary workaround, we should check the cause in StealVoice() instead @@ -2057,7 +2096,7 @@ bool HandleKeyGroupConflicts ) = 0; - virtual int GetMinFadeOutSamples() { return MinFadeOutSamples; } + virtual int GetMinFadeOutSamples() OVERRIDE { return MinFadeOutSamples; } int InitNewVoice ( EngineChannelBase* pChannel,