// PUBLIC void RADAR::gotoPan(int pan) { if (pan == _pan) return; _prevPan = getPan(); _pan = pan; analogWrite(_pinPan, _pan); _lastPanTime = millis(); }
void PanTilt::setLimits(int pMin, int pMax, int tMin, int tMax) { _minPan = pMin; _maxPan = pMax; _minTilt = tMin; _maxTilt = tMax; panTo(getPan()); tiltTo(getTilt()); }
void Soloud::fadePan(handle aVoiceHandle, float aTo, time aTime) { float from = getPan(aVoiceHandle); if (aTime <= 0 || aTo == from) { setPan(aVoiceHandle, aTo); return; } if (mLockMutexFunc) mLockMutexFunc(mMutex); int ch = getVoiceFromHandle(aVoiceHandle); if (ch == -1) { if (mUnlockMutexFunc) mUnlockMutexFunc(mMutex); return; } mVoice[ch]->mPanFader.set(from, aTo, aTime, mVoice[ch]->mStreamTime); if (mUnlockMutexFunc) mUnlockMutexFunc(mMutex); }
bool RADAR::ready() { return ((getPan() == _pan) && (getTilt == _tilt)); }
bool RADAR::isMoving() { return ((getPan() != _pan) || (getTilt() != _tilt)); }
// playSample for DiscWorld 2 bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int priority, Audio::Mixer::SoundType type, Audio::SoundHandle *handle) { // Floppy version has no sample file if (_vm->getFeatures() & GF_FLOPPY) return false; // no sample driver? if (!_vm->_mixer->isReady()) return false; Channel *curChan; uint8 sndVol = 255; // Sample on screen? if (!offscreenChecks(x, y)) return false; // If that sample is already playing, stop it stopSpecSample(id, sub); if (type == Audio::Mixer::kSpeechSoundType) { curChan = &_channels[kChannelTalk]; } else if (type == Audio::Mixer::kSFXSoundType) { uint32 oldestTime = g_system->getMillis(); int oldestChan = kChannelSFX; int chan; for (chan = kChannelSFX; chan < kNumChannels; chan++) { if (!_vm->_mixer->isSoundHandleActive(_channels[chan].handle)) break; if ((_channels[chan].lastStart < oldestTime) && (_channels[chan].priority <= priority)) { oldestTime = _channels[chan].lastStart; oldestChan = chan; } } if (chan == kNumChannels) { if (_channels[oldestChan].priority > priority) { warning("playSample: No free channel"); return false; } chan = oldestChan; } if (_vm->_pcmMusic->isDimmed() && SysVar(SYS_SceneFxDimFactor)) sndVol = 255 - 255/SysVar(SYS_SceneFxDimFactor); curChan = &_channels[chan]; } else { warning("playSample: Unknown SoundType"); return false; } // stop any currently playing sample _vm->_mixer->stopHandle(curChan->handle); // make sure id is in range assert(id > 0 && id < _sampleIndexLen); // get file offset for this sample uint32 dwSampleIndex = _sampleIndex[id]; if (dwSampleIndex == 0) { warning("Tinsel2 playSample, non-existant sample %d", id); return false; } // move to correct position in the sample file _sampleStream.seek(dwSampleIndex); if (_sampleStream.eos() || _sampleStream.err() || (uint32)_sampleStream.pos() != dwSampleIndex) error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); // read the length of the sample uint32 sampleLen = _sampleStream.readUint32(); if (_sampleStream.eos() || _sampleStream.err()) error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); if (sampleLen & 0x80000000) { // Has sub samples int32 numSubs = sampleLen & ~0x80000000; assert(sub >= 0 && sub < numSubs); // Skipping for (int32 i = 0; i < sub; i++) { sampleLen = _sampleStream.readUint32(); _sampleStream.skip(sampleLen); if (_sampleStream.eos() || _sampleStream.err()) error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); } sampleLen = _sampleStream.readUint32(); if (_sampleStream.eos() || _sampleStream.err()) error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); } debugC(DEBUG_DETAILED, kTinselDebugSound, "Playing sound %d.%d, %d bytes at %d (pan %d)", id, sub, sampleLen, _sampleStream.pos(), getPan(x)); // allocate a buffer byte *sampleBuf = (byte *) malloc(sampleLen); assert(sampleBuf); // read all of the sample if (_sampleStream.read(sampleBuf, sampleLen) != sampleLen) error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); Common::MemoryReadStream *compressedStream = new Common::MemoryReadStream(sampleBuf, sampleLen, DisposeAfterUse::YES); Audio::AudioStream *sampleStream = 0; switch (_soundMode) { case kMP3Mode: #ifdef USE_MAD sampleStream = Audio::makeMP3Stream(compressedStream, DisposeAfterUse::YES); #endif break; case kVorbisMode: #ifdef USE_VORBIS sampleStream = Audio::makeVorbisStream(compressedStream, DisposeAfterUse::YES); #endif break; case kFLACMode: #ifdef USE_FLAC sampleStream = Audio::makeFLACStream(compressedStream, DisposeAfterUse::YES); #endif break; default: sampleStream = Audio::makeADPCMStream(compressedStream, DisposeAfterUse::YES, sampleLen, Audio::kADPCMTinsel6, 22050, 1, 24); break; } // FIXME: Should set this in a different place ;) bool mute = false; if (ConfMan.hasKey("mute")) mute = ConfMan.getBool("mute"); _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, mute ? 0 : _vm->_config->_soundVolume); //_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic); _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, mute ? 0 : _vm->_config->_voiceVolume); curChan->sampleNum = id; curChan->subSample = sub; curChan->looped = bLooped; curChan->x = x; curChan->y = y; curChan->priority = priority; curChan->lastStart = g_system->getMillis(); // /---Compression----\ Milis BytesPerSecond // not needed and won't work when using MP3/OGG/FLAC anyway //curChan->timeDuration = (((sampleLen * 64) / 25) * 1000) / (22050 * 2); // Play it _vm->_mixer->playStream(type, &curChan->handle, sampleStream); _vm->_mixer->setChannelVolume(curChan->handle, sndVol); _vm->_mixer->setChannelBalance(curChan->handle, getPan(x)); if (handle) *handle = curChan->handle; return true; }
float Lamp::getDmxPan(){ float _pan = getPan(); return ofMap(_pan, panMin, panMax, dmxPanMin, dmxPanMax); }
void FModSound::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { Inherited::changed(whichField, origin, details); if(whichField & FileFieldMask) { if(!boost::filesystem::exists(getFile())) { SWARNING << "FModSound: error loading sound from file: " << getFile().string() << " This file does not exist." << std::endl; } else { FMOD_RESULT result; FMOD_MODE soundMode(FMOD_DEFAULT); if(getEnable3D()) { soundMode |= FMOD_3D; } //soundMode |= FMOD_NONBLOCKING; if(getLooping() != 0) { soundMode |= FMOD_LOOP_NORMAL | FMOD_SOFTWARE; } else { soundMode |= FMOD_HARDWARE; } if(getStreaming()) { result = FModSoundManager::the()->getSystem()->createStream(getFile().string().c_str(), soundMode, 0, &_FModSound); // FMOD_DEFAULT uses the defaults. These are the same as FMOD_LOOP_OFF | FMOD_2D | FMOD_HARDWARE. } else { result = FModSoundManager::the()->getSystem()->createSound(getFile().string().c_str(), soundMode, 0, &_FModSound); // FMOD_DEFAULT uses the defaults. These are the same as FMOD_LOOP_OFF | FMOD_2D | FMOD_HARDWARE. } FMOD_ERRCHECK(result,"FModSound::changed()"); if(result != FMOD_OK) { if(getStreaming()) { result = FModSoundManager::the()->getSystem()->createStream(getFile().string().c_str(), FMOD_SOFTWARE, 0, &_FModSound); // FMOD_DEFAULT uses the defaults. These are the same as FMOD_LOOP_OFF | FMOD_2D | FMOD_HARDWARE. } else { result = FModSoundManager::the()->getSystem()->createSound(getFile().string().c_str(), FMOD_SOFTWARE, 0, &_FModSound); // FMOD_DEFAULT uses the defaults. These are the same as FMOD_LOOP_OFF | FMOD_2D | FMOD_HARDWARE. } } FMOD_ERRCHECK(result,"FModSound::changed()"); } } if(whichField & VolumeFieldMask || whichField & PanFieldMask || whichField & FrequencyFieldMask) { FMOD_RESULT result; result = _FModSound->setDefaults(getFrequency(), getVolume(),getPan(), 128); FMOD_ERRCHECK(result,"FModSound::changed()"); } if(whichField & LoopingFieldMask) { FMOD_RESULT result; result = _FModSound->setLoopCount(getLooping() - 1); FMOD_ERRCHECK(result,"FModSound::changed()"); } }