/[svn]/linuxsampler/trunk/src/engines/AbstractEngineChannel.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/AbstractEngineChannel.cpp

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

revision 2594 by schoenebeck, Thu Jun 5 00:16:25 2014 UTC revision 2600 by schoenebeck, Sat Jun 7 00:16:03 2014 UTC
# Line 171  namespace LinuxSampler { Line 171  namespace LinuxSampler {
171    
172          script.handlerInit = script.parserContext->eventHandlerByName("init");          script.handlerInit = script.parserContext->eventHandlerByName("init");
173          script.handlerNote = script.parserContext->eventHandlerByName("note");          script.handlerNote = script.parserContext->eventHandlerByName("note");
174            script.handlerRelease = script.parserContext->eventHandlerByName("release");
175          script.handlerController = script.parserContext->eventHandlerByName("controller");          script.handlerController = script.parserContext->eventHandlerByName("controller");
176          script.bHasValidScript =          script.bHasValidScript =
177              script.handlerInit || script.handlerNote || script.handlerController;              script.handlerInit || script.handlerNote || script.handlerRelease ||
178                script.handlerController;
179    
180          // amount of script handlers each script event has to execute          // amount of script handlers each script event has to execute
181          int handlerExecCount = 0;          int handlerExecCount = 0;
182          if (script.handlerInit) handlerExecCount++;          if (script.handlerInit) handlerExecCount++; // "init" handler is always executed before the actual event handler
183          if (script.handlerNote || script.handlerController) handlerExecCount++;          if (script.handlerNote || script.handlerRelease || script.handlerController) // only one of these are executed after "init" handler
184                handlerExecCount++;
185    
186          // create script event pool (if it doesn't exist already)          // create script event pool (if it doesn't exist already)
187          if (!pScriptEvents)          if (!pScriptEvents)
# Line 228  namespace LinuxSampler { Line 231  namespace LinuxSampler {
231              script.parserContext = NULL;              script.parserContext = NULL;
232              script.handlerInit = NULL;              script.handlerInit = NULL;
233              script.handlerNote = NULL;              script.handlerNote = NULL;
234                script.handlerRelease = NULL;
235              script.handlerController = NULL;              script.handlerController = NULL;
236          }          }
237          script.bHasValidScript = false;          script.bHasValidScript = false;
# Line 467  namespace LinuxSampler { Line 471  namespace LinuxSampler {
471              event.Param.Note.Key      = Key;              event.Param.Note.Key      = Key;
472              event.Param.Note.Velocity = Velocity;              event.Param.Note.Velocity = Velocity;
473              event.Param.Note.Channel  = MidiChannel;              event.Param.Note.Channel  = MidiChannel;
474                event.Format              = {}; // init format specific stuff with zeroes
475              event.pEngineChannel      = this;              event.pEngineChannel      = this;
476              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
477              else dmsg(1,("EngineChannel: Input event queue full!"));              else dmsg(1,("EngineChannel: Input event queue full!"));
# Line 508  namespace LinuxSampler { Line 513  namespace LinuxSampler {
513              event.Param.Note.Key      = Key;              event.Param.Note.Key      = Key;
514              event.Param.Note.Velocity = Velocity;              event.Param.Note.Velocity = Velocity;
515              event.Param.Note.Channel  = MidiChannel;              event.Param.Note.Channel  = MidiChannel;
516                event.Format              = {}; // init format specific stuff with zeroes
517              event.pEngineChannel      = this;              event.pEngineChannel      = this;
518              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
519              else dmsg(1,("EngineChannel: Input event queue full!"));              else dmsg(1,("EngineChannel: Input event queue full!"));
# Line 544  namespace LinuxSampler { Line 550  namespace LinuxSampler {
550              event.Param.Note.Key      = Key;              event.Param.Note.Key      = Key;
551              event.Param.Note.Velocity = Velocity;              event.Param.Note.Velocity = Velocity;
552              event.Param.Note.Channel  = MidiChannel;              event.Param.Note.Channel  = MidiChannel;
553                event.Format              = {}; // init format specific stuff with zeroes
554              event.pEngineChannel      = this;              event.pEngineChannel      = this;
555              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
556              else dmsg(1,("EngineChannel: Input event queue full!"));              else dmsg(1,("EngineChannel: Input event queue full!"));
# Line 585  namespace LinuxSampler { Line 592  namespace LinuxSampler {
592              event.Param.Note.Key      = Key;              event.Param.Note.Key      = Key;
593              event.Param.Note.Velocity = Velocity;              event.Param.Note.Velocity = Velocity;
594              event.Param.Note.Channel  = MidiChannel;              event.Param.Note.Channel  = MidiChannel;
595                event.Format              = {}; // init format specific stuff with zeroes
596              event.pEngineChannel      = this;              event.pEngineChannel      = this;
597              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
598              else dmsg(1,("EngineChannel: Input event queue full!"));              else dmsg(1,("EngineChannel: Input event queue full!"));
# Line 619  namespace LinuxSampler { Line 627  namespace LinuxSampler {
627              event.Type              = Event::type_pitchbend;              event.Type              = Event::type_pitchbend;
628              event.Param.Pitch.Pitch = Pitch;              event.Param.Pitch.Pitch = Pitch;
629              event.Param.Pitch.Channel = MidiChannel;              event.Param.Pitch.Channel = MidiChannel;
630                event.Format            = {}; // init format specific stuff with zeroes
631              event.pEngineChannel    = this;              event.pEngineChannel    = this;
632              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
633              else dmsg(1,("EngineChannel: Input event queue full!"));              else dmsg(1,("EngineChannel: Input event queue full!"));
# Line 648  namespace LinuxSampler { Line 657  namespace LinuxSampler {
657              event.Type              = Event::type_pitchbend;              event.Type              = Event::type_pitchbend;
658              event.Param.Pitch.Pitch = Pitch;              event.Param.Pitch.Pitch = Pitch;
659              event.Param.Pitch.Channel = MidiChannel;              event.Param.Pitch.Channel = MidiChannel;
660                event.Format            = {}; // init format specific stuff with zeroes
661              event.pEngineChannel    = this;              event.pEngineChannel    = this;
662              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
663              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));
# Line 674  namespace LinuxSampler { Line 684  namespace LinuxSampler {
684              event.Param.CC.Controller = Controller;              event.Param.CC.Controller = Controller;
685              event.Param.CC.Value      = Value;              event.Param.CC.Value      = Value;
686              event.Param.CC.Channel    = MidiChannel;              event.Param.CC.Channel    = MidiChannel;
687                event.Format              = {}; // init format specific stuff with zeroes
688              event.pEngineChannel      = this;              event.pEngineChannel      = this;
689              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
690              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));
# Line 705  namespace LinuxSampler { Line 716  namespace LinuxSampler {
716              event.Param.CC.Controller = Controller;              event.Param.CC.Controller = Controller;
717              event.Param.CC.Value      = Value;              event.Param.CC.Value      = Value;
718              event.Param.CC.Channel    = MidiChannel;              event.Param.CC.Channel    = MidiChannel;
719                event.Format              = {}; // init format specific stuff with zeroes
720              event.pEngineChannel      = this;              event.pEngineChannel      = this;
721              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
722              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));
# Line 721  namespace LinuxSampler { Line 733  namespace LinuxSampler {
733              event.Type                          = Event::type_channel_pressure;              event.Type                          = Event::type_channel_pressure;
734              event.Param.ChannelPressure.Value   = Value;              event.Param.ChannelPressure.Value   = Value;
735              event.Param.ChannelPressure.Channel = MidiChannel;              event.Param.ChannelPressure.Channel = MidiChannel;
736                event.Format                        = {}; // init format specific stuff with zeroes
737              event.pEngineChannel                = this;              event.pEngineChannel                = this;
738              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
739              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));
# Line 737  namespace LinuxSampler { Line 750  namespace LinuxSampler {
750              event.Type                          = Event::type_channel_pressure;              event.Type                          = Event::type_channel_pressure;
751              event.Param.ChannelPressure.Value   = Value;              event.Param.ChannelPressure.Value   = Value;
752              event.Param.ChannelPressure.Channel = MidiChannel;              event.Param.ChannelPressure.Channel = MidiChannel;
753                event.Format                        = {}; // init format specific stuff with zeroes
754              event.pEngineChannel                = this;              event.pEngineChannel                = this;
755              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
756              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));
# Line 754  namespace LinuxSampler { Line 768  namespace LinuxSampler {
768              event.Param.NotePressure.Key     = Key;              event.Param.NotePressure.Key     = Key;
769              event.Param.NotePressure.Value   = Value;              event.Param.NotePressure.Value   = Value;
770              event.Param.NotePressure.Channel = MidiChannel;              event.Param.NotePressure.Channel = MidiChannel;
771                event.Format                     = {}; // init format specific stuff with zeroes
772              event.pEngineChannel             = this;              event.pEngineChannel             = this;
773              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
774              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));
# Line 771  namespace LinuxSampler { Line 786  namespace LinuxSampler {
786              event.Param.NotePressure.Key     = Key;              event.Param.NotePressure.Key     = Key;
787              event.Param.NotePressure.Value   = Value;              event.Param.NotePressure.Value   = Value;
788              event.Param.NotePressure.Channel = MidiChannel;              event.Param.NotePressure.Channel = MidiChannel;
789                event.Format                     = {}; // init format specific stuff with zeroes
790              event.pEngineChannel             = this;              event.pEngineChannel             = this;
791              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
792              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));              else dmsg(1,("AbstractEngineChannel: Input event queue full!"));
# Line 884  namespace LinuxSampler { Line 900  namespace LinuxSampler {
900          eventQueueReader.free(); // free all copied events from input queue          eventQueueReader.free(); // free all copied events from input queue
901      }      }
902    
903        /**
904         * Called by real-time instrument script functions to schedule a new event
905         * somewhere in future.
906         *
907         * @returns unique event ID of scheduled new event
908         */
909        int AbstractEngineChannel::ScheduleEvent(const Event* pEvent, int delay) { //TODO: delay not implemented yet
910            // since delay is not implemented yet, we simply add the new event
911            // to the event list of the current audio fragmet cycle for now
912            RTList<Event>::Iterator itEvent = pEvents->allocAppend();
913            if (itEvent) *itEvent = *pEvent; // copy event
914            return pEvents->getID(itEvent);
915        }
916    
917        /**
918         * Called by real-time instrument script functions to ignore the event
919         * reflected by given event ID. The event will be freed immediately to its
920         * pool and cannot be dereferenced by its old ID anymore. Even if its
921         * allocated back from the Pool later on, it will have a different ID.
922         */
923        void AbstractEngineChannel::IgnoreEvent(int id) {
924            RTList<Event>::Iterator it = pEvents->fromID(id);
925            if (it) pEvents->free(it);
926        }
927    
928      FxSend* AbstractEngineChannel::AddFxSend(uint8_t MidiCtrl, String Name) throw (Exception) {      FxSend* AbstractEngineChannel::AddFxSend(uint8_t MidiCtrl, String Name) throw (Exception) {
929          if (pEngine) pEngine->DisableAndLock();          if (pEngine) pEngine->DisableAndLock();
930          FxSend* pFxSend = new FxSend(this, MidiCtrl, Name);          FxSend* pFxSend = new FxSend(this, MidiCtrl, Name);

Legend:
Removed from v.2594  
changed lines
  Added in v.2600

  ViewVC Help
Powered by ViewVC