SFXSource::SFXSource( SFXProfile *profile, SFXDescription* desc ) : mStatus( SFXStatusStopped ), mPitch( 1 ), mVelocity( 0, 0, 0 ), mTransform( true ), mAttenuatedVolume( 0 ), mDistToListener( 0 ), mModulativeVolume( 1 ), mVoice( NULL ), mProfile( profile ), mStatusCallback( NULL ), mPlayStartTick( 0 ) { mIs3D = desc->mIs3D; mIsLooping = desc->mIsLooping; mIsStreaming = desc->mIsStreaming; mFadeInTime = desc->mFadeInTime; mFadeOutTime = desc->mFadeOutTime; mPitch = desc->mPitch; setVolume( desc->mVolume ); setMinMaxDistance( desc->mReferenceDistance, desc->mMaxDistance ); setCone( F32( desc->mConeInsideAngle ), F32( desc->mConeOutsideAngle ), desc->mConeOutsideVolume ); mChannel = desc->mChannel; // Allow namespace linkage. mNSLinkMask = LinkSuperClassName | LinkClassName; }
aalError DSoundSource::init() { setVolume(channel.volume); setPitch(channel.pitch); // Create 3D interface if required if(channel.flags & FLAG_ANY_3D_FX) { if(sample->getFormat().channels != 1) { // TODO(broken-assets) newer DSound versions don't supprt this } if(lpdsb->QueryInterface(IID_IDirectSound3DBuffer, (void **)&lpds3db)) { return AAL_ERROR_SYSTEM; } if(channel.flags & FLAG_RELATIVE && lpds3db->SetMode(DS3DMODE_HEADRELATIVE, DS3D_DEFERRED)) { return AAL_ERROR_SYSTEM; } setPosition(channel.position); setVelocity(channel.velocity); setDirection(channel.direction); setCone(channel.cone); setFalloff(channel.falloff); if(backend->hasEAX) { lpds3db->QueryInterface(IID_IKsPropertySet, (void **)&lpeax); s32 value = 0; lpeax->Set(DSPROPSETID_EAX_BufferProperties, DSPROPERTY_EAXBUFFER_FLAGS | DSPROPERTY_EAXBUFFER_DEFERRED, NULL, 0, &value, sizeof(s32)); if(!backend->environment || !(channel.flags & FLAG_REVERBERATION)) { value = -10000; lpeax->Set(DSPROPSETID_EAX_BufferProperties, DSPROPERTY_EAXBUFFER_ROOM | DSPROPERTY_EAXBUFFER_DEFERRED, NULL, 0, &value, sizeof(s32)); lpeax->Set(DSPROPSETID_EAX_BufferProperties, DSPROPERTY_EAXBUFFER_ROOMHF | DSPROPERTY_EAXBUFFER_DEFERRED, NULL, 0, &value, sizeof(s32)); } } } else { setPan(channel.pan); } return AAL_OK; }
void Sound::setDefaults() { setPosition(Vector3::ZERO); setDirection(Vector3::UNIT_Y); setPitch(1.f); setGain(1.f, 0.f, 1.f); setLooping(false); setRolloff(1.f); setReferenceDistance(1.f); setCone(360.f,360.f,0.f); setRelative(true); setOffsetSeconds(0.f); rewind(); }
QT_USE_NAMESPACE QSoundSourcePrivate::QSoundSourcePrivate(QObject *parent) : QSoundSource(parent) , m_alSource(0) , m_bindBuffer(0) , m_isReady(false) , m_state(QSoundSource::StoppedState) , m_gain(0) , m_pitch(0) , m_coneInnerAngle(0) , m_coneOuterAngle(0) , m_coneOuterGain(1) { #ifdef DEBUG_AUDIOENGINE qDebug() << "creating new QSoundSourcePrivate"; #endif alGenSources(1, &m_alSource); QAudioEnginePrivate::checkNoError("create source"); setGain(1); setPitch(1); setCone(360, 360, 0); }
bool SFXSource::_allocVoice( SFXDevice* device ) { // We shouldn't have any existing voice! AssertFatal( !mVoice, "SFXSource::_allocVoice() - Already had a voice!" ); // Must not assign voice to source that isn't playing. AssertFatal( getLastStatus() == SFXStatusPlaying, "SFXSource::_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() ) { if( mProfile != NULL ) _setBuffer( mProfile->getBuffer() ); if( mBuffer.isNull() ) return false; } // Ask the device for a voice based on this buffer. mVoice = device->createVoice( mIs3D, mBuffer ); if( !mVoice ) return false; setVolume( mVolume ); if( mPitch != 1.0f ) setPitch( mPitch ); if( mIs3D ) { setTransform( mTransform ); setVelocity( mVelocity ); setMinMaxDistance( mMinDistance, mMaxDistance ); setCone( mConeInsideAngle, mConeOutsideAngle, mConeOutsideVolume ); } // 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. if( mVirtualPlayTimer.isStarted() ) { const U32 playTime = mVirtualPlayTimer.getPosition(); const U32 pos = mBuffer->getFormat().getSampleCount( playTime ); mVoice->setPosition( pos); mVirtualPlayTimer.stop(); } mVoice->play( mIsLooping ); #ifdef DEBUG_SPEW Platform::outputDebugString( "[SFXSource] allocated voice for source '%i'", getId() ); #endif return true; }
SwingTwistConstraint::SwingLimitFunction::SwingLimitFunction() { setCone(PI); }