Json::Value Bounds::toJson() const { Json::Value json; json.append(m_min.x); json.append(m_min.y); if (is3d()) json.append(m_min.z); json.append(m_max.x); json.append(m_max.y); if (is3d()) json.append(m_max.z); return json; }
void SFXSound::_setMinMaxDistance( F32 min, F32 max ) { Parent::_setMinMaxDistance( min, max ); if( mVoice && is3d() ) mVoice->setMinMaxDistance( mMinDistance, mMaxDistance ); }
void SFXSound::setTransform( const MatrixF& transform ) { Parent::setTransform( transform ); if( mVoice && is3d() ) mVoice->setTransform( mTransform ); }
void SFXSound::setVelocity( const VectorF& velocity ) { Parent::setVelocity( velocity ); if( mVoice && is3d() ) mVoice->setVelocity( velocity ); }
/** * @brief FFT shift * * @param m TO be shifted * @return Shifted */ template <class T> inline Matrix<T> fftshift (const Matrix<T>& m, const bool& fw = true) { assert (isvec(m) || is2d(m) || is3d(m)); Matrix<size_t> tmp = resize(size(m),ndims(m),1); for (size_t i = 0; i<ndims(m); i++) if (tmp[i] == 0) tmp[i] = 1; container<size_t> d = tmp.Container(); // data side lengths container<size_t> c = floor(tmp/2).Container(); // center coords Matrix<T> res (vsize(m)); size_t oi[3]; size_t si[3]; for (oi[0] = 0; oi[0] < d[0]; oi[0]++) { si[0] = (oi[0] + c[0]) % d[0]; for (oi[1] = 0; oi[1] < d[1]; oi[1]++) { si[1] = (oi[1] + c[1]) % d[1]; for (oi[2] = 0; oi[2] < d[2]; oi[2]++) { si[2] = (oi[2] + c[2]) % d[2]; if (fw) res(si[0],si[1],si[2]) = m(oi[0],oi[1],oi[2]); else res(oi[0],oi[1],oi[2]) = m(si[0],si[1],si[2]); } } } return res; }
long Writer::GetGType() { bool bUse3d = is3d(); bool bUseSolidGeometry = getDefaultedOption<bool>("solid"); long gtype = 0; if (bUse3d) { if (bUseSolidGeometry == true) { gtype = 3008; } else { gtype = 3003; } } else { if (bUseSolidGeometry == true) { gtype = 2008; } else { gtype = 2003; } } return gtype; }
void Fmod4SoundStitching::load() throw (RuntimeException) { FMOD_CREATESOUNDEXINFO exinfo; FMOD_MODE mode = FMOD_OPENUSER; if (is3d()) { mode |= FMOD_3D; } else { mode |= FMOD_2D; } if (isLooping()) { mode |= FMOD_LOOP_NORMAL; } else { mode |= FMOD_LOOP_OFF; } memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO)); exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); exinfo.defaultfrequency = 44100; exinfo.numsubsounds = getNumSlots(); exinfo.numchannels = is3d() ? 1 : 2; exinfo.format = FMOD_SOUND_FORMAT_PCM16; FMOD_RESULT res = mDriver->_getFmodSystem()->createStream( getSoundResource()->getName().c_str(), mode, &exinfo, &mSound); CHECK_FMOD4_ERRORS(res); int *sentence = new int[getNumSlots()]; for(unsigned int i = 0; i < getNumSlots(); i++) { sentence[i] = i; } res = mSound->setSubSoundSentence(sentence, getNumSlots()); CHECK_FMOD4_ERRORS(res); }
void Writer::SetOrdinates(Statement statement, OCIArray* ordinates, pdal::Bounds<double> const& extent) { statement->AddElement(ordinates, extent.getMinimum(0)); statement->AddElement(ordinates, extent.getMinimum(1)); if (is3d()) statement->AddElement(ordinates, extent.getMinimum(2)); statement->AddElement(ordinates, extent.getMaximum(0)); statement->AddElement(ordinates, extent.getMaximum(1)); if (is3d()) statement->AddElement(ordinates, extent.getMaximum(2)); }
void SoundStitchingObject::play(bool destroyWhenDone) { getSoundStitching()->play(destroyWhenDone); if (is3d()) { _update(); } }
void SFXSound::_setCone( F32 innerAngle, F32 outerAngle, F32 outerVolume ) { Parent::_setCone( innerAngle, outerAngle, outerVolume ); if( mVoice && is3d() ) mVoice->setCone( mConeInsideAngle, mConeOutsideAngle, mConeOutsideVolume ); }
template<class T> inline static Matrix<T> zpad (const Matrix<T>& a, size_t m, size_t n, size_t o) { assert(is3d(a)); size_t am = size(a,0), an = size(a,1), ao = size(a,2); assert(am<=m); assert(an<=n); assert(ao<=o); size_t am2 = (m-am)/2, an2 = (n-an)/2, ao2 = (o-ao)/2; Matrix<T> ret(m,n,o); for (size_t j = 0; j < ao; ++j) for (size_t i = 0; i < an; ++i) std::copy(&a(0,i,j), &a(0,i,j)+am, &ret(am2,i+an2,j+ao2)); return ret; }
/** * @author JoSch * @date 07-12-2005 */ void Fmod3SoundSample::load() throw (RuntimeException) { getSoundResource()->load(); DataStreamPtr stream = getSoundResource()->getDataStream(); stream->seek(0); int len = stream->size(); char *data = new char[len]; stream->read(data, len); unsigned int mode = FSOUND_LOADMEMORY; if (is3d()) { mode |= FSOUND_HW3D | FSOUND_FORCEMONO; } else { mode |= FSOUND_HW2D; } if (isLooping()) { mode |= FSOUND_LOOP_NORMAL; } else { mode |= FSOUND_LOOP_OFF; } mSample = FSOUND_Sample_Load(FSOUND_FREE, data, mode, 0, len); if (mSample == 0 && !is3d() ) { mode |= FSOUND_FORCEMONO; mSample = FSOUND_Sample_Load(FSOUND_FREE, data, mode, 0, len); } delete[] data; if( mSample == NULL ) { int err = FSOUND_GetError(); Throw( RuntimeException, "Fmod Error:" + Ogre::StringConverter::toString(err) + " while loading " + getName() ); } }
/** * @author JoSch * @date 08-03-2008 * @version 1.0 */ void Fmod4SoundStitching::putSoundIntoSlot(unsigned int slot, CeGuiString label) { if (isValid()) { FMOD_MODE mode = FMOD_DEFAULT; if (is3d()) { mode |= FMOD_3D; } else { mode |= FMOD_2D; } if (isLooping()) { mode |= FMOD_LOOP_NORMAL; } else { mode |= FMOD_LOOP_OFF; } FMOD::Sound *sound; FMOD_RESULT result = mDriver->_getFmodSystem()->createStream( mSoundCache[label]->getName().c_str(), mode, NULL, &sound); CHECK_FMOD4_ERRORS(result); if (mSoundSlots[slot] != NULL) { mSoundSlots[slot]->release(); } mSoundSlots[slot] = sound; result = sound->setSubSound(slot, sound); CHECK_FMOD4_ERRORS(result); } }
std::string Writer::CreatePCElemInfo() { bool bUse3d = is3d(); bool bUseSolidGeometry = getDefaultedOption<bool>("solid"); std::ostringstream s_eleminfo; if (bUse3d) { if (bUseSolidGeometry == true) { // s_gtype << "3008"; s_eleminfo << "(1,1007,3)"; } else { // s_gtype << "3003"; s_eleminfo << "(1,1003,3)"; } } else { if (bUseSolidGeometry == true) { // s_gtype << "2008"; s_eleminfo << "(1,1007,3)"; } else { // s_gtype << "2003"; s_eleminfo << "(1,1003,3)"; } } return s_eleminfo.str(); }
void Fmod4SoundStitching::play(bool destroyWhenDone) { if (!isValid()) { load(); } FMOD_RESULT res = mDriver->_getFmodSystem()->playSound( FMOD_CHANNEL_FREE, mSound, true, &mChannel); CHECK_FMOD4_ERRORS(res); RlAssert1(mChannel != NULL); mAutoDestroy = destroyWhenDone; // mDriver->_registerChannel(mChannel, this); float vol; if (is3d()) { vol = mDriver->getDefaultSoundVolume(); } else { vol = mDriver->getDefaultMusicVolume(); } setVolume(vol); setPriority(mPriority); setPosition(mPosition); setDirection(mDirection); setVelocity(mVelocity); pause(false); SoundPlayEvent event = SoundPlayEvent(this, SoundPlayEvent::STARTEVENT); dispatchEvent(&event); }
bool isCubic() const { return width() == depth() && (!is3d() || width() == height()); }
bool SFXSound::_allocVoice( SFXDevice* device ) { // We shouldn't have any existing voice! AssertFatal( !mVoice, "SFXSound::_allocVoice() - Already had a voice!" ); // Must not assign voice to source that isn't playing. AssertFatal( getLastStatus() == SFXStatusPlaying, "SFXSound::_allocVoice() - Source is not playing!" ); // The buffer can be lost when the device is reset // or changed, so initialize it if we have to. If // that fails then we cannot create the voice. if( mBuffer.isNull() ) { SFXProfile* profile = getProfile(); if( profile != NULL ) { SFXBuffer* buffer = profile->getBuffer(); if( buffer ) _setBuffer( buffer ); } if( mBuffer.isNull() ) return false; } // Ask the device for a voice based on this buffer. mVoice = device->createVoice( is3d(), mBuffer ); if( !mVoice ) return false; // Set initial properties. mVoice->setVolume( mPreAttenuatedVolume ); mVoice->setPitch( mEffectivePitch ); mVoice->setPriority( mEffectivePriority ); if( mDescription->mRolloffFactor != -1.f ) mVoice->setRolloffFactor( mDescription->mRolloffFactor ); // Set 3D parameters. if( is3d() ) { // Scatter the position, if requested. Do this only once so // we don't change position when resuming from virtualized // playback. if( !mTransformScattered ) _scatterTransform(); // Set the 3D attributes. setTransform( mTransform ); setVelocity( mVelocity ); _setMinMaxDistance( mMinDistance, mMaxDistance ); _setCone( mConeInsideAngle, mConeOutsideAngle, mConeOutsideVolume ); } // Set reverb, if enabled. if( mDescription->mUseReverb ) mVoice->setReverb( mDescription->mReverb ); // Update the duration... it shouldn't have changed, but // its probably better that we're accurate if it did. mDuration = mBuffer->getDuration(); // If virtualized playback has been started, we transfer its position to the // voice and stop virtualization. const U32 playTime = mPlayTimer.getPosition(); if( playTime > 0 ) { const U32 pos = mBuffer->getFormat().getSampleCount( playTime ); mVoice->setPosition( pos); } mVoice->play( isLooping() ); #ifdef DEBUG_SPEW Platform::outputDebugString( "[SFXSound] allocated voice for source '%i' (pos=%i, 3d=%i, vol=%f)", getId(), playTime, is3d(), mPreAttenuatedVolume ); #endif return true; }