void SimpleAudioEngine::end() { checkALError("end"); // clear all the sounds EffectsMap::const_iterator end = s_effects.end(); for (EffectsMap::iterator it = s_effects.begin(); it != end; it++) { alSourceStop(it->second->source); checkALError("end"); alDeleteBuffers(1, &it->second->buffer); checkALError("end"); alDeleteSources(1, &it->second->source); checkALError("end"); delete it->second; } s_effects.clear(); // and the background too stopBackground(true); for (BackgroundMusicsMap::iterator it = s_backgroundMusics.begin(); it != s_backgroundMusics.end(); ++it) { alSourceStop(it->second->source); checkALError("end"); alDeleteBuffers(1, &it->second->buffer); checkALError("end"); alDeleteSources(1, &it->second->source); checkALError("end"); delete it->second; } s_backgroundMusics.clear(); }
void SimpleAudioEngine::pauseAllEffects() { EffectsMap::iterator iter = s_effects.begin(); if (iter != s_effects.end()) { alSourcePause(iter->second->source); checkALError("pauseAllEffects"); } }
void SimpleAudioEngine::stopAllEffects() { EffectsMap::iterator iter = s_effects.begin(); if (iter != s_effects.end()) { checkALError("stopAllEffects:init"); alSourceStop(iter->second->source); checkALError("stopAllEffects:alSourceStop"); } }
void SimpleAudioEngine::resumeAllEffects() { EffectsMap::iterator iter = s_effects.begin(); if (iter != s_effects.end()) { checkALError("resumeAllEffects"); alSourcePlay(iter->second->source); checkALError("resumeAllEffects"); } }
void SimpleAudioEngine::stopAllEffects() { EffectsMap::iterator iter = s_effects.begin(); if (iter != s_effects.end()) { alSourceStop(iter->second->source); int err = alGetError(); if (err != AL_NO_ERROR) printALError(err); } }
void SimpleAudioEngine::resumeAllEffects() { EffectsMap::iterator iter = s_effects.begin(); ALint state; while (iter != s_effects.end()) { alGetSourcei(iter->second->source, AL_SOURCE_STATE, &state); if (state == AL_PAUSED) alSourcePlay(iter->second->source); checkALError("resumeAllEffects:alSourcePlay"); ++iter; } }
void SimpleAudioEngine::setEffectsVolume(float volume) { if (volume != s_effectVolume) { EffectsMap::const_iterator end = s_effects.end(); for (EffectsMap::const_iterator it = s_effects.begin(); it != end; it++) { alSourcef(it->second->source, AL_GAIN, volume * it->second->gain); } s_effectVolume = volume; } }
void SimpleAudioEngine::pauseAllEffects() { EffectsMap::iterator iter = s_effects.begin(); ALint state; while (iter != s_effects.end()) { alGetSourcei(iter->second->source, AL_SOURCE_STATE, &state); if (state == AL_PLAYING) alSourcePause(iter->second->source); checkALError("pauseAllEffects"); ++iter; } }
void SimpleAudioEngine::end() { checkALError("end:init"); // clear all the sound effects EffectsMap::const_iterator end = s_effects.end(); for (auto it = s_effects.begin(); it != end; ++it) { alSourceStop(it->second->source); checkALError("end:alSourceStop"); alDeleteSources(1, &it->second->source); checkALError("end:alDeleteSources"); alDeleteBuffers(1, &it->second->buffer); checkALError("end:alDeleteBuffers"); delete it->second; } s_effects.clear(); // and the background music too stopBackground(true); for (auto it = s_backgroundMusics.begin(); it != s_backgroundMusics.end(); ++it) { alSourceStop(it->second->source); checkALError("end:alSourceStop"); alDeleteSources(1, &it->second->source); checkALError("end:alDeleteSources"); alDeleteBuffers(1, &it->second->buffer); checkALError("end:alDeleteBuffers"); delete it->second; } s_backgroundMusics.clear(); CC_SAFE_DELETE(s_engine); }
void SimpleAudioEngine::end() { // clear all the sounds EffectsMap::const_iterator end = s_effects.end(); for (EffectsMap::iterator it = s_effects.begin(); it != end; it++) { Mix_FreeChunk(it->second->chunk); delete it->second; } s_effects.clear(); // and the background too stopBackground(true); for (BackgroundMusicsMap::iterator it = s_backgroundMusics.begin(); it != s_backgroundMusics.end(); ++it) { Mix_FreeMusic(it->second->music); delete it->second; } s_backgroundMusics.clear(); }
void SimpleAudioEngine::end() { // clear all the sounds EffectsMap::const_iterator end = s_effects.end(); for (EffectsMap::iterator it = s_effects.begin(); it != end; it++) { alSourceStop(it->second->source); alDeleteBuffers(1, &it->second->buffer); alDeleteSources(1, &it->second->source); delete it->second; } s_effects.clear(); if (s_isBackgroundInitialized) { s_isBackgroundInitialized = false; } // and the background too stopBackground(true); }
void System<EffectsComp>::update(double elapsed) { std::map<ObjectId,EffectsComp>::iterator iCom = components_.begin(); while(iCom!=components_.end()) { EffectsComp* effectsComp = &iCom->second; EffectsMap* effectsMap = effectsComp->getEffects(); // std::cout << "Address of effectsMap: "<< effectsMap << std::endl; // std::cout << "copy of effects map size : "<< effectsMap->size() << std::endl; // std::cout << "orig effects map size : " << effectsComp->getEffects()->size() << std::endl; //update each effect in component as necessary EffectsMap::iterator iEffect = effectsMap->begin(); while(iEffect!=effectsMap->end()) { //update timer if necessary if(iEffect->second->hasDuration()) { iEffect->second->updateDuration(elapsed); //check if timer has expired if (iEffect->second->hasExpired()) { //do on end messages std::vector<Parameters> endParams = iEffect->second->getOnEnd(); std::vector<Parameters>::iterator iParams = endParams.begin(); while(iParams!= endParams.end()) { if(iParams->size()>0) { Message msg(effectsComp->getId(), effectsComp->getId(), *iParams); Telegram tel(effectsComp->getId(), effectsComp->getId(), 0.0, msg); core_->getMessageCentre()->addTelegram(tel); } ++iParams; } //delete params effectsMap->erase(iEffect++); continue; } } //carry out onUpdate messages std::vector<Parameters> updateParams = iEffect->second->getOnUpdate(); std::vector<Parameters>::iterator iParams = updateParams.begin(); while(iParams!= updateParams.end()) { if(iParams->size()>0) { Message msg(effectsComp->getId(), effectsComp->getId(), *iParams); Telegram tel(effectsComp->getId(), effectsComp->getId(), 0.0, msg); core_->getMessageCentre()->addTelegram(tel); } ++iParams; } ++iEffect; } ++iCom; } }