--- linuxsampler/trunk/src/engines/gig/EngineChannel.cpp 2005/03/14 22:35:44 460 +++ linuxsampler/trunk/src/engines/gig/EngineChannel.cpp 2005/06/17 19:49:30 660 @@ -31,7 +31,7 @@ pInstrument = NULL; pEvents = NULL; // we allocate when we retrieve the right Engine object pCCEvents = NULL; // we allocate when we retrieve the right Engine object - pEventQueue = new RingBuffer(MAX_EVENTS_PER_FRAGMENT, 0); + pEventQueue = new RingBuffer(CONFIG_MAX_EVENTS_PER_FRAGMENT, 0); pActiveKeys = new Pool(128); for (uint i = 0; i < 128; i++) { pMIDIKeyInfo[i].pActiveVoices = NULL; // we allocate when we retrieve the right Engine object @@ -39,6 +39,7 @@ pMIDIKeyInfo[i].Active = false; pMIDIKeyInfo[i].ReleaseTrigger = false; pMIDIKeyInfo[i].pEvents = NULL; // we allocate when we retrieve the right Engine object + pMIDIKeyInfo[i].VoiceTheftsQueued = 0; pMIDIKeyInfo[i].RoundRobinIndex = 0; } for (uint i = 0; i < Event::destination_count; i++) { @@ -59,6 +60,24 @@ } /** + * Implementation of virtual method from abstract EngineChannel interface. + * This method will periodically be polled (e.g. by the LSCP server) to + * check if some engine channel parameter has changed since the last + * StatusChanged() call. + * + * TODO: This "poll method" is just a lazy solution and might be + * replaced in future. + * + * @returns true if engine channel status has changed since last + * StatusChanged() call + */ + bool EngineChannel::StatusChanged() { + bool b = bStatusChanged; + bStatusChanged = false; + return b; + } + + /** * This method is not thread safe! */ void EngineChannel::ResetInternal() { @@ -69,8 +88,7 @@ GlobalPanRight = 1.0f; CurrentKeyDimension = 0; - // set all MIDI controller values to zero - memset(ControllerTable, 0x00, 128); + ResetControllers(); // reset key info for (uint i = 0; i < 128; i++) { @@ -82,6 +100,7 @@ pMIDIKeyInfo[i].Active = false; pMIDIKeyInfo[i].ReleaseTrigger = false; pMIDIKeyInfo[i].itSelf = Pool::Iterator(); + pMIDIKeyInfo[i].VoiceTheftsQueued = 0; } // reset all key groups @@ -95,6 +114,9 @@ pEventQueue->init(); if (pEngine) pEngine->ResetInternal(); + + // status of engine channel has changed, so set notify flag + bStatusChanged = true; } LinuxSampler::Engine* EngineChannel::GetEngine() { @@ -190,8 +212,8 @@ /** * Will be called by the InstrumentResourceManager when the instrument - * we are currently using in this engine is going to be updated, so we - * can stop playback before that happens. + * we are currently using on this EngineChannel is going to be updated, + * so we can stop playback before that happens. */ void EngineChannel::ResourceToBeUpdated(::gig::Instrument* pResource, void*& pUpdateArg) { dmsg(3,("gig::Engine: Received instrument update message.\n")); @@ -207,6 +229,19 @@ void EngineChannel::ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg) { this->pInstrument = pNewResource; //TODO: there are couple of engine parameters we should update here as well if the instrument was updated (see LoadInstrument()) if (pEngine) pEngine->Enable(); + bStatusChanged = true; // status of engine has changed, so set notify flag + } + + /** + * Will be called by the InstrumentResourceManager on progress changes + * while loading or realoading an instrument for this EngineChannel. + * + * @param fProgress - current progress as value between 0.0 and 1.0 + */ + void EngineChannel::OnResourceProgress(float fProgress) { + this->InstrumentStat = int(fProgress * 100.0f); + dmsg(7,("gig::EngineChannel: progress %d%", InstrumentStat)); + bStatusChanged = true; // status of engine has changed, so set notify flag } void EngineChannel::Connect(AudioOutputDevice* pAudioOut) { @@ -387,6 +422,11 @@ } } + void EngineChannel::ResetControllers() { + // set all MIDI controller values to zero + memset(ControllerTable, 0x00, 128); + } + /** * Copy all events from the engine channel's input event queue buffer to * the internal event list. This will be done at the beginning of each @@ -429,6 +469,7 @@ void EngineChannel::Volume(float f) { GlobalVolume = f; + bStatusChanged = true; // status of engine channel has changed, so set notify flag } uint EngineChannel::Channels() { @@ -451,4 +492,8 @@ return InstrumentStat; } + String EngineChannel::EngineName() { + return LS_GIG_ENGINE_NAME; + } + }} // namespace LinuxSampler::gig