mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 23:54:35 +00:00
Sfx playlist asset working (#1109)
* GroundWork -Reverted SFXPlaylist since it is going to be made from an asset now instead. -Added extra options to soundAssets description. -SFXPlaylist may need an onAdd function * Update sfxController.cpp * SFXPlaylist data -Added sfxPlaylist init persist fields for the slots to sound asset -Added logic to fil sfxPlaylist if more than 1 slot is filled * Update SoundAsset.cpp to stop git ci complaining, assetImporter........ * Update SoundAsset.h * sfxPlaylist -Fix: incomplete type error -Added onAdd and onRemove to playlist -SoundAsset getProfile define now returns playlist if the asset is a playlist. * Update SoundAsset.h -updated asset array to return playlist or profile depending on what the asset is * SFXPlaylist working -SFXPlaylist works AudioChannelDefault gets its volume set to 0 for some reason and was throwing off making sfxPlaylist inaudible. Still an exception when closing if using a playlist trips on line 355 of sfxSound * Update sfxSound.h * setSoundFile index null fix * Update SoundAsset.h * Update SoundAsset.h * netstream safety in case of a null asset assignment * Update sfxController.cpp added safeties around a null playlist trying to play. * Update with Az's asset err code changes --------- Co-authored-by: AzaezelX <quillus@hotmail.com>
This commit is contained in:
parent
845defb25d
commit
852ed8f225
14 changed files with 550 additions and 245 deletions
|
|
@ -167,7 +167,7 @@ void SFXController::_compileList( SFXPlayList* playList )
|
|||
|
||||
// If there's no track in this slot, ignore it.
|
||||
|
||||
if( !playList->getTrackProfile(slotIndex))
|
||||
if( !playList->getSlots().mTrack[slotIndex])
|
||||
continue;
|
||||
|
||||
// If this is a looped slot and the list is not set to loop
|
||||
|
|
@ -394,7 +394,13 @@ bool SFXController::_execInsn()
|
|||
case OP_Play:
|
||||
{
|
||||
SFXPlayList* playList = getPlayList();
|
||||
SFXTrack* track = playList->getTrackProfile(insn.mSlotIndex);
|
||||
if (playList == NULL)
|
||||
{
|
||||
endUpdate = true;
|
||||
break;
|
||||
}
|
||||
|
||||
SFXTrack* track = playList->getSlots().mTrack[insn.mSlotIndex];
|
||||
|
||||
// Handle existing sources playing on this slot and find
|
||||
// whether we need to start a new source.
|
||||
|
|
@ -817,6 +823,9 @@ void SFXController::_update()
|
|||
|
||||
SFXPlayList* playList = getPlayList();
|
||||
|
||||
if (!playList)
|
||||
Parent::stop();
|
||||
|
||||
// Check all sources against the current state setup and
|
||||
// take appropriate actions.
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "sfx/sfxPlayList.h"
|
||||
#include "sfx/sfxState.h"
|
||||
#include "sfx/sfxTypes.h"
|
||||
#include "sfx/sfxDescription.h"
|
||||
#include "core/stream/bitStream.h"
|
||||
#include "math/mRandom.h"
|
||||
#include "math/mathTypes.h"
|
||||
|
|
@ -218,10 +219,23 @@ SFXPlayList::SFXPlayList()
|
|||
: mRandomMode( RANDOM_NotRandom ),
|
||||
mLoopMode( LOOP_All ),
|
||||
mTrace( false ),
|
||||
mNumSlotsToPlay( NUM_SLOTS )
|
||||
mNumSlotsToPlay( NUM_SLOTS ),
|
||||
mActiveSlots(12)
|
||||
{
|
||||
for (U32 i=0;i<NUM_SLOTS;i++)
|
||||
INIT_SOUNDASSET_ARRAY(Track, i);
|
||||
}
|
||||
|
||||
SFXPlayList::~SFXPlayList()
|
||||
{
|
||||
if (!isTempClone())
|
||||
return;
|
||||
|
||||
// cleanup after a temp-clone
|
||||
|
||||
if (mDescription && mDescription->isTempClone())
|
||||
{
|
||||
delete mDescription;
|
||||
mDescription = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -250,10 +264,10 @@ void SFXPlayList::initPersistFields()
|
|||
|
||||
addArray( "slots", NUM_SLOTS );
|
||||
|
||||
INITPERSISTFIELD_SOUNDASSET_ARRAY( Track, NUM_SLOTS, SFXPlayList,
|
||||
addField("track", TypeSFXTrackName, Offset(mSlots.mTrack, SFXPlayList), NUM_SLOTS,
|
||||
"Track to play in this slot.\n"
|
||||
"This must be set for the slot to be considered for playback. Other settings for a slot "
|
||||
"will not take effect except this field is set." );
|
||||
"will not take effect except this field is set.");
|
||||
addField( "replay", TYPEID< EReplayMode >(), Offset( mSlots.mReplayMode, SFXPlayList ), NUM_SLOTS,
|
||||
"Behavior when an already playing sound is encountered on this slot from a previous cycle.\n"
|
||||
"Each slot can have an arbitrary number of sounds playing on it from previous cycles. This field determines "
|
||||
|
|
@ -340,32 +354,64 @@ void SFXPlayList::initPersistFields()
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
U32 SFXPlayList::getNumSlots()
|
||||
{
|
||||
U32 trackCount = 0;
|
||||
for (U32 i = 0; i < NUM_SLOTS; i++)
|
||||
{
|
||||
if (mSlots.mTrack[i] == NULL)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
trackCount++;
|
||||
}
|
||||
|
||||
return trackCount;
|
||||
}
|
||||
|
||||
bool SFXPlayList::isLooping() const
|
||||
{
|
||||
// pretty useless in playlist, looping handled differently.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SFXPlayList::onAdd()
|
||||
{
|
||||
if (!Parent::onAdd())
|
||||
return false;
|
||||
|
||||
mActiveSlots = getNumSlots();
|
||||
|
||||
validate();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SFXPlayList::onRemove()
|
||||
{
|
||||
Parent::onRemove();
|
||||
}
|
||||
|
||||
bool SFXPlayList::preload( bool server, String& errorStr )
|
||||
{
|
||||
if( !Parent::preload( server, errorStr ) )
|
||||
return false;
|
||||
|
||||
mActiveSlots = getNumSlots();
|
||||
|
||||
validate();
|
||||
|
||||
// Resolve SFXTracks and SFXStates on client.
|
||||
|
||||
|
||||
if( !server )
|
||||
{
|
||||
for( U32 i = 0; i < NUM_SLOTS; ++ i )
|
||||
for( U32 i = 0; i < mActiveSlots; ++ i )
|
||||
{
|
||||
StringTableEntry track = getTrack(i);
|
||||
if (track != StringTable->EmptyString())
|
||||
{
|
||||
_setTrack(getTrack(i), i);
|
||||
if (!getTrackProfile(i))
|
||||
{
|
||||
Con::errorf("SFXPlayList::Preload() - unable to find sfxProfile for asset %s", mTrackAssetId[i]);
|
||||
if (!sfxResolve(&mSlots.mTrack[i], errorStr))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sfxResolve(&mSlots.mState[i], errorStr))
|
||||
if (!sfxResolve(&mSlots.mState[i], errorStr))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -382,55 +428,57 @@ void SFXPlayList::packData( BitStream* stream )
|
|||
stream->writeInt( mLoopMode, NUM_LOOP_MODE_BITS );
|
||||
stream->writeInt( mNumSlotsToPlay, NUM_SLOTS_TO_PLAY_BITS );
|
||||
|
||||
#define FOR_EACH_SLOT \
|
||||
for( U32 i = 0; i < NUM_SLOTS; ++ i )
|
||||
|
||||
FOR_EACH_SLOT stream->writeInt( mSlots.mReplayMode[ i ], NUM_REPLAY_MODE_BITS );
|
||||
FOR_EACH_SLOT stream->writeInt( mSlots.mTransitionIn[ i ], NUM_TRANSITION_MODE_BITS );
|
||||
FOR_EACH_SLOT stream->writeInt( mSlots.mTransitionOut[ i ], NUM_TRANSITION_MODE_BITS );
|
||||
FOR_EACH_SLOT stream->writeInt( mSlots.mStateMode[ i ], NUM_STATE_MODE_BITS );
|
||||
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mFadeTimeIn.mValue[ i ] != -1 ))
|
||||
stream->write( mSlots.mFadeTimeIn.mValue[ i ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag( mSlots.mFadeTimeIn.mVariance[ i ][ 0 ] > 0))
|
||||
stream->write(mSlots.mFadeTimeIn.mVariance[ i ][ 0 ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag( mSlots.mFadeTimeIn.mVariance[ i ][ 1 ] > 0))
|
||||
stream->write(mSlots.mFadeTimeIn.mVariance[ i ][ 1 ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mFadeTimeOut.mValue[ i ] != -1 ))
|
||||
stream->write( mSlots.mFadeTimeOut.mValue[ i ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mFadeTimeOut.mVariance[i][0] > 0))
|
||||
stream->write(mSlots.mFadeTimeOut.mVariance[i][0]);
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mFadeTimeOut.mVariance[i][1] > 0))
|
||||
stream->write(mSlots.mFadeTimeOut.mVariance[i][1]);
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mDelayTimeIn.mValue[ i ] > 0))
|
||||
stream->write(mSlots.mDelayTimeIn.mValue[ i ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mDelayTimeIn.mVariance[ i ][ 0 ] > 0))
|
||||
stream->write(mSlots.mDelayTimeIn.mVariance[ i ][ 0 ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mDelayTimeIn.mVariance[ i ][ 1 ] > 0))
|
||||
stream->write(mSlots.mDelayTimeIn.mVariance[ i ][ 1 ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mDelayTimeOut.mValue[ i ] > 0))
|
||||
stream->write(mSlots.mDelayTimeOut.mValue[ i ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mDelayTimeOut.mVariance[ i ][ 0 ] > 0))
|
||||
stream->write(mSlots.mDelayTimeOut.mVariance[ i ][ 0 ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mDelayTimeOut.mVariance[ i ][ 1 ] > 0))
|
||||
stream->write(mSlots.mDelayTimeOut.mVariance[ i ][ 1 ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mVolumeScale.mValue[ i ] != 1))
|
||||
stream->write(mSlots.mVolumeScale.mValue[ i ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mVolumeScale.mVariance[ i ][ 0 ] > 0))
|
||||
stream->write(mSlots.mVolumeScale.mVariance[ i ][ 0 ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mVolumeScale.mVariance[ i ][ 1 ] > 0))
|
||||
stream->write(mSlots.mVolumeScale.mVariance[ i ][ 1 ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mPitchScale.mValue[ i ] != 1))
|
||||
stream->write(mSlots.mPitchScale.mValue[ i ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mPitchScale.mVariance[ i ][ 0 ] > 0))
|
||||
stream->write(mSlots.mPitchScale.mVariance[ i ][ 0 ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag(mSlots.mPitchScale.mVariance[ i ][ 1 ] > 0))
|
||||
stream->write(mSlots.mPitchScale.mVariance[ i ][ 1 ] );
|
||||
FOR_EACH_SLOT if (stream->writeFlag( mSlots.mRepeatCount[ i ] > 0))
|
||||
stream->write( mSlots.mRepeatCount[ i ] );
|
||||
|
||||
FOR_EACH_SLOT sfxWrite( stream, mSlots.mState[ i ] );
|
||||
FOR_EACH_SLOT PACKDATA_SOUNDASSET_ARRAY(Track, i);
|
||||
stream->writeInt(mActiveSlots, 8);
|
||||
|
||||
for (U32 i = 0; i < mActiveSlots; ++i)
|
||||
{
|
||||
stream->writeInt(mSlots.mReplayMode[i], NUM_REPLAY_MODE_BITS);
|
||||
stream->writeInt(mSlots.mTransitionIn[i], NUM_TRANSITION_MODE_BITS);
|
||||
stream->writeInt(mSlots.mTransitionOut[i], NUM_TRANSITION_MODE_BITS);
|
||||
stream->writeInt(mSlots.mStateMode[i], NUM_STATE_MODE_BITS);
|
||||
|
||||
if (stream->writeFlag(mSlots.mFadeTimeIn.mValue[i] != -1))
|
||||
stream->write(mSlots.mFadeTimeIn.mValue[i]);
|
||||
if (stream->writeFlag(mSlots.mFadeTimeIn.mVariance[i][0] > 0))
|
||||
stream->write(mSlots.mFadeTimeIn.mVariance[i][0]);
|
||||
if (stream->writeFlag(mSlots.mFadeTimeIn.mVariance[i][1] > 0))
|
||||
stream->write(mSlots.mFadeTimeIn.mVariance[i][1]);
|
||||
if (stream->writeFlag(mSlots.mFadeTimeOut.mValue[i] != -1))
|
||||
stream->write(mSlots.mFadeTimeOut.mValue[i]);
|
||||
if (stream->writeFlag(mSlots.mFadeTimeOut.mVariance[i][0] > 0))
|
||||
stream->write(mSlots.mFadeTimeOut.mVariance[i][0]);
|
||||
if (stream->writeFlag(mSlots.mFadeTimeOut.mVariance[i][1] > 0))
|
||||
stream->write(mSlots.mFadeTimeOut.mVariance[i][1]);
|
||||
if (stream->writeFlag(mSlots.mDelayTimeIn.mValue[i] > 0))
|
||||
stream->write(mSlots.mDelayTimeIn.mValue[i]);
|
||||
if (stream->writeFlag(mSlots.mDelayTimeIn.mVariance[i][0] > 0))
|
||||
stream->write(mSlots.mDelayTimeIn.mVariance[i][0]);
|
||||
if (stream->writeFlag(mSlots.mDelayTimeIn.mVariance[i][1] > 0))
|
||||
stream->write(mSlots.mDelayTimeIn.mVariance[i][1]);
|
||||
if (stream->writeFlag(mSlots.mDelayTimeOut.mValue[i] > 0))
|
||||
stream->write(mSlots.mDelayTimeOut.mValue[i]);
|
||||
if (stream->writeFlag(mSlots.mDelayTimeOut.mVariance[i][0] > 0))
|
||||
stream->write(mSlots.mDelayTimeOut.mVariance[i][0]);
|
||||
if (stream->writeFlag(mSlots.mDelayTimeOut.mVariance[i][1] > 0))
|
||||
stream->write(mSlots.mDelayTimeOut.mVariance[i][1]);
|
||||
if (stream->writeFlag(mSlots.mVolumeScale.mValue[i] != 1))
|
||||
stream->write(mSlots.mVolumeScale.mValue[i]);
|
||||
if (stream->writeFlag(mSlots.mVolumeScale.mVariance[i][0] > 0))
|
||||
stream->write(mSlots.mVolumeScale.mVariance[i][0]);
|
||||
if (stream->writeFlag(mSlots.mVolumeScale.mVariance[i][1] > 0))
|
||||
stream->write(mSlots.mVolumeScale.mVariance[i][1]);
|
||||
if (stream->writeFlag(mSlots.mPitchScale.mValue[i] != 1))
|
||||
stream->write(mSlots.mPitchScale.mValue[i]);
|
||||
if (stream->writeFlag(mSlots.mPitchScale.mVariance[i][0] > 0))
|
||||
stream->write(mSlots.mPitchScale.mVariance[i][0]);
|
||||
if (stream->writeFlag(mSlots.mPitchScale.mVariance[i][1] > 0))
|
||||
stream->write(mSlots.mPitchScale.mVariance[i][1]);
|
||||
if (stream->writeFlag(mSlots.mRepeatCount[i] > 0))
|
||||
stream->write(mSlots.mRepeatCount[i]);
|
||||
|
||||
sfxWrite(stream, mSlots.mState[i]);
|
||||
sfxWrite(stream, mSlots.mTrack[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -442,36 +490,39 @@ void SFXPlayList::unpackData( BitStream* stream )
|
|||
mRandomMode = ( ERandomMode ) stream->readInt( NUM_RANDOM_MODE_BITS );
|
||||
mLoopMode = ( ELoopMode ) stream->readInt( NUM_LOOP_MODE_BITS );
|
||||
mNumSlotsToPlay = stream->readInt( NUM_SLOTS_TO_PLAY_BITS );
|
||||
|
||||
FOR_EACH_SLOT mSlots.mReplayMode[ i ] = ( EReplayMode ) stream->readInt( NUM_REPLAY_MODE_BITS );
|
||||
FOR_EACH_SLOT mSlots.mTransitionIn[ i ] = ( ETransitionMode ) stream->readInt( NUM_TRANSITION_MODE_BITS );
|
||||
FOR_EACH_SLOT mSlots.mTransitionOut[ i ] = ( ETransitionMode ) stream->readInt( NUM_TRANSITION_MODE_BITS );
|
||||
FOR_EACH_SLOT mSlots.mStateMode[ i ] = ( EStateMode ) stream->readInt( NUM_STATE_MODE_BITS );
|
||||
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mFadeTimeIn.mValue[ i ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mFadeTimeIn.mVariance[ i ][ 0 ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mFadeTimeIn.mVariance[ i ][ 1 ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mFadeTimeOut.mValue[ i ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mFadeTimeOut.mVariance[ i ][ 0 ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mFadeTimeOut.mVariance[ i ][ 1 ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mDelayTimeIn.mValue[ i ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mDelayTimeIn.mVariance[ i ][ 0 ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mDelayTimeIn.mVariance[ i ][ 1 ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mDelayTimeOut.mValue[ i ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mDelayTimeOut.mVariance[ i ][ 0 ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mDelayTimeOut.mVariance[ i ][ 1 ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mVolumeScale.mValue[ i ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mVolumeScale.mVariance[ i ][ 0 ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mVolumeScale.mVariance[ i ][ 1 ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mPitchScale.mValue[ i ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mPitchScale.mVariance[ i ][ 0 ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mPitchScale.mVariance[ i ][ 1 ] );}
|
||||
FOR_EACH_SLOT if(stream->readFlag()){ stream->read( &mSlots.mRepeatCount[ i ] );}
|
||||
|
||||
FOR_EACH_SLOT sfxRead( stream, &mSlots.mState[ i ] );
|
||||
FOR_EACH_SLOT UNPACKDATA_SOUNDASSET_ARRAY(Track, i);
|
||||
|
||||
#undef FOR_EACH_SLOT
|
||||
|
||||
mActiveSlots = stream->readInt(8);
|
||||
|
||||
for (U32 i = 0; i < mActiveSlots; ++i)
|
||||
{
|
||||
mSlots.mReplayMode[i] = (EReplayMode)stream->readInt(NUM_REPLAY_MODE_BITS);
|
||||
mSlots.mTransitionIn[i] = (ETransitionMode)stream->readInt(NUM_TRANSITION_MODE_BITS);
|
||||
mSlots.mTransitionOut[i] = (ETransitionMode)stream->readInt(NUM_TRANSITION_MODE_BITS);
|
||||
mSlots.mStateMode[i] = (EStateMode)stream->readInt(NUM_STATE_MODE_BITS);
|
||||
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mFadeTimeIn.mValue[i]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mFadeTimeIn.mVariance[i][0]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mFadeTimeIn.mVariance[i][1]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mFadeTimeOut.mValue[i]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mFadeTimeOut.mVariance[i][0]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mFadeTimeOut.mVariance[i][1]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mDelayTimeIn.mValue[i]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mDelayTimeIn.mVariance[i][0]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mDelayTimeIn.mVariance[i][1]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mDelayTimeOut.mValue[i]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mDelayTimeOut.mVariance[i][0]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mDelayTimeOut.mVariance[i][1]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mVolumeScale.mValue[i]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mVolumeScale.mVariance[i][0]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mVolumeScale.mVariance[i][1]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mPitchScale.mValue[i]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mPitchScale.mVariance[i][0]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mPitchScale.mVariance[i][1]); }
|
||||
if (stream->readFlag()) { stream->read(&mSlots.mRepeatCount[i]); }
|
||||
|
||||
sfxRead(stream, &mSlots.mState[i]);
|
||||
sfxRead(stream, &mSlots.mTrack[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -486,8 +537,8 @@ void SFXPlayList::inspectPostApply()
|
|||
|
||||
void SFXPlayList::validate()
|
||||
{
|
||||
if( mNumSlotsToPlay > NUM_SLOTS )
|
||||
mNumSlotsToPlay = NUM_SLOTS;
|
||||
if( mNumSlotsToPlay > mActiveSlots )
|
||||
mNumSlotsToPlay = mActiveSlots;
|
||||
|
||||
mSlots.mFadeTimeIn.validate();
|
||||
mSlots.mFadeTimeOut.validate();
|
||||
|
|
|
|||
|
|
@ -30,13 +30,8 @@
|
|||
#include "sfx/sfxTrack.h"
|
||||
#endif
|
||||
|
||||
#ifndef SOUND_ASSET_H
|
||||
#include "T3D/assets/SoundAsset.h"
|
||||
#endif
|
||||
|
||||
|
||||
class SFXState;
|
||||
|
||||
class SFXDescription;
|
||||
|
||||
/// A playback list of SFXTracks.
|
||||
///
|
||||
|
|
@ -79,7 +74,7 @@ class SFXPlayList : public SFXTrack
|
|||
|
||||
typedef SFXTrack Parent;
|
||||
|
||||
enum
|
||||
enum SFXPlaylistSettings
|
||||
{
|
||||
/// Number of slots in a playlist.
|
||||
///
|
||||
|
|
@ -261,6 +256,9 @@ class SFXPlayList : public SFXTrack
|
|||
/// is playing.
|
||||
EStateMode mStateMode[ NUM_SLOTS ];
|
||||
|
||||
/// Track to play in this slot.
|
||||
SFXTrack* mTrack[NUM_SLOTS];
|
||||
|
||||
SlotData()
|
||||
{
|
||||
dMemset( mReplayMode, 0, sizeof( mReplayMode ) );
|
||||
|
|
@ -268,6 +266,7 @@ class SFXPlayList : public SFXTrack
|
|||
dMemset( mTransitionOut, 0, sizeof( mTransitionOut ) );
|
||||
dMemset( mRepeatCount, 0, sizeof( mRepeatCount ) );
|
||||
dMemset( mState, 0, sizeof( mState ) );
|
||||
dMemset( mTrack, 0, sizeof( mTrack ) );
|
||||
dMemset( mStateMode, 0, sizeof( mStateMode ) );
|
||||
|
||||
for( U32 i = 0; i < NUM_SLOTS; ++ i )
|
||||
|
|
@ -282,31 +281,33 @@ class SFXPlayList : public SFXTrack
|
|||
}
|
||||
}
|
||||
};
|
||||
DECLARE_SOUNDASSET_ARRAY(SFXPlayList, Track, NUM_SLOTS);
|
||||
DECLARE_ASSET_ARRAY_SETGET(SFXPlayList, Track);
|
||||
|
||||
protected:
|
||||
|
||||
public:
|
||||
// moved to public for soundasset
|
||||
|
||||
/// Trace interpreter execution. This field is not networked.
|
||||
bool mTrace;
|
||||
|
||||
|
||||
/// Select slots at random.
|
||||
ERandomMode mRandomMode;
|
||||
|
||||
|
||||
/// Loop over slots in this list.
|
||||
ELoopMode mLoopMode;
|
||||
|
||||
|
||||
/// Number of slots to play from list. This can be used, for example,
|
||||
/// to create a list of tracks where only a single track is selected and
|
||||
/// played for each cycle.
|
||||
U32 mNumSlotsToPlay;
|
||||
|
||||
|
||||
/// Data for each of the playlist slots.
|
||||
SlotData mSlots;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
U32 mActiveSlots;
|
||||
|
||||
SFXPlayList();
|
||||
|
||||
/// The destructor.
|
||||
virtual ~SFXPlayList();
|
||||
|
||||
/// Make all settings conform to constraints.
|
||||
void validate();
|
||||
|
|
@ -324,7 +325,7 @@ class SFXPlayList : public SFXTrack
|
|||
ELoopMode getLoopMode() const { return mLoopMode; }
|
||||
|
||||
/// Return the total number of slots in the list.
|
||||
U32 getNumSlots() const { return NUM_SLOTS; }
|
||||
U32 getNumSlots();
|
||||
|
||||
/// Return the slot data for this list.
|
||||
const SlotData& getSlots() const { return mSlots; }
|
||||
|
|
@ -332,8 +333,13 @@ class SFXPlayList : public SFXTrack
|
|||
DECLARE_CONOBJECT( SFXPlayList );
|
||||
DECLARE_CATEGORY( "SFX" );
|
||||
DECLARE_DESCRIPTION( "A playback list of SFXProfiles or nested SFXPlayLists." );
|
||||
|
||||
|
||||
// SFXTrack.
|
||||
virtual bool isLooping() const;
|
||||
|
||||
// SimDataBlock.
|
||||
bool onAdd();
|
||||
void onRemove();
|
||||
virtual bool preload( bool server, String& errorStr );
|
||||
virtual void packData( BitStream* stream );
|
||||
virtual void unpackData( BitStream* stream );
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class SFXSound : public SFXSource,
|
|||
bool isBlocked() const { return ( mVoice && mVoice->getStatus() == SFXStatusBlocked ); }
|
||||
|
||||
/// Returns true if this is a continuously streaming source.
|
||||
bool isStreaming() const { return mDescription->mIsStreaming; }
|
||||
bool isStreaming() const { return mDescription ? mDescription->mIsStreaming : false; }
|
||||
|
||||
/// Returns true if the source's associated data is ready for playback.
|
||||
bool isReady() const;
|
||||
|
|
|
|||
|
|
@ -192,18 +192,18 @@ SFXSource::SFXSource()
|
|||
mSavedStatus( SFXStatusNull ),
|
||||
mStatusCallback( NULL ),
|
||||
mDescription( NULL ),
|
||||
mVolume( 1.f ),
|
||||
mPreFadeVolume( 1.f ),
|
||||
mFadedVolume( 1.f ),
|
||||
mModulativeVolume( 1.f ),
|
||||
mPreAttenuatedVolume( 1.f ),
|
||||
mAttenuatedVolume( 1.f ),
|
||||
mVolume( 1.0f ),
|
||||
mPreFadeVolume( 1.0f ),
|
||||
mFadedVolume( 1.0f ),
|
||||
mModulativeVolume( 1.0f ),
|
||||
mPreAttenuatedVolume( 1.0f ),
|
||||
mAttenuatedVolume( 1.0f ),
|
||||
mPriority( 0 ),
|
||||
mModulativePriority( 1.f ),
|
||||
mModulativePriority( 1.0f ),
|
||||
mEffectivePriority( 0 ),
|
||||
mPitch( 1.f ),
|
||||
mModulativePitch( 1.f ),
|
||||
mEffectivePitch( 1.f ),
|
||||
mModulativePitch( 1.0f ),
|
||||
mEffectivePitch( 1.0f ),
|
||||
mTransform( true ),
|
||||
mVelocity( 0, 0, 0 ),
|
||||
mMinDistance( 1 ),
|
||||
|
|
@ -213,14 +213,14 @@ SFXSource::SFXSource()
|
|||
mConeOutsideVolume( 1 ),
|
||||
mDistToListener( 0.f ),
|
||||
mTransformScattered( false ),
|
||||
mFadeInTime( 0.f ),
|
||||
mFadeOutTime( 0.f ),
|
||||
mFadeInPoint( -1.f ),
|
||||
mFadeOutPoint( -1.f ),
|
||||
mFadeInTime( 0.0f ),
|
||||
mFadeOutTime( 0.0f ),
|
||||
mFadeInPoint( -1.0f ),
|
||||
mFadeOutPoint( -1.0f ),
|
||||
mFadeSegmentType( FadeSegmentNone ),
|
||||
mFadeSegmentEase( NULL ),
|
||||
mFadeSegmentStartPoint( 0.f ),
|
||||
mFadeSegmentEndPoint( 0.f ),
|
||||
mFadeSegmentStartPoint( 0.0f ),
|
||||
mFadeSegmentEndPoint( 0.0f ),
|
||||
mSavedFadeTime( -1.f ),
|
||||
mPlayStartTick( 0 )
|
||||
{
|
||||
|
|
@ -236,17 +236,17 @@ SFXSource::SFXSource( SFXTrack* track, SFXDescription* description )
|
|||
mTrack( track ),
|
||||
mDescription( description ),
|
||||
mVolume( 1.f ),
|
||||
mPreFadeVolume( 1.f ),
|
||||
mFadedVolume( 1.f ),
|
||||
mModulativeVolume( 1.f ),
|
||||
mPreAttenuatedVolume( 1.f ),
|
||||
mAttenuatedVolume( 1.f ),
|
||||
mPreFadeVolume( 1.0f ),
|
||||
mFadedVolume( 1.0f ),
|
||||
mModulativeVolume( 1.0f ),
|
||||
mPreAttenuatedVolume( 1.0f ),
|
||||
mAttenuatedVolume( 1.0f ),
|
||||
mPriority( 0 ),
|
||||
mModulativePriority( 1.f ),
|
||||
mModulativePriority( 1.0f ),
|
||||
mEffectivePriority( 0 ),
|
||||
mPitch( 1.f ),
|
||||
mModulativePitch( 1.f ),
|
||||
mEffectivePitch( 1.f ),
|
||||
mPitch( 1.0f ),
|
||||
mModulativePitch( 1.0f ),
|
||||
mEffectivePitch( 1.0f ),
|
||||
mTransform( true ),
|
||||
mVelocity( 0, 0, 0 ),
|
||||
mMinDistance( 1 ),
|
||||
|
|
@ -256,15 +256,15 @@ SFXSource::SFXSource( SFXTrack* track, SFXDescription* description )
|
|||
mConeOutsideVolume( 1 ),
|
||||
mDistToListener( 0.f ),
|
||||
mTransformScattered( false ),
|
||||
mFadeInTime( 0.f ),
|
||||
mFadeOutTime( 0.f ),
|
||||
mFadeInPoint( -1.f ),
|
||||
mFadeOutPoint( -1.f ),
|
||||
mFadeInTime( 0.0f ),
|
||||
mFadeOutTime( 0.0f ),
|
||||
mFadeInPoint( -1.0f ),
|
||||
mFadeOutPoint( -1.0f ),
|
||||
mFadeSegmentType( FadeSegmentNone ),
|
||||
mFadeSegmentEase( NULL ),
|
||||
mFadeSegmentStartPoint( 0.f ),
|
||||
mFadeSegmentEndPoint( 0.f ),
|
||||
mSavedFadeTime( -1.f ),
|
||||
mFadeSegmentStartPoint( 0.0f ),
|
||||
mFadeSegmentEndPoint( 0.0f ),
|
||||
mSavedFadeTime( -1.0f ),
|
||||
mPlayStartTick( 0 )
|
||||
{
|
||||
VECTOR_SET_ASSOCIATION( mParameters );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue