initial
This commit is contained in:
220
engine/audio/private/snd_op_sys/sos_entry_match_system.cpp
Normal file
220
engine/audio/private/snd_op_sys/sos_entry_match_system.cpp
Normal file
@@ -0,0 +1,220 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
#include "audio_pch.h"
|
||||
|
||||
#include "sos_system.h"
|
||||
#include "sos_entry_match_system.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
extern ConVar snd_sos_show_block_debug;
|
||||
ConVar snd_sos_show_entry_match_free( "snd_sos_show_entry_match_free", "0" );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosEntryMatch
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CSosEntryMatch::IsAMatch( CSosEntryMatch *pEntryMatch )
|
||||
{
|
||||
|
||||
bool bMatchString1 = true;
|
||||
bool bMatchString2 = true;
|
||||
bool bMatchInt1 = true;
|
||||
bool bMatchInt2 = true;
|
||||
bool bMatchInt3 = true;
|
||||
|
||||
|
||||
if ( m_bMatchString1 )
|
||||
{
|
||||
if( m_bMatchSubString )
|
||||
{
|
||||
if ( V_stristr( pEntryMatch->m_nMatchString1, m_nMatchString1 ) == NULL )
|
||||
{
|
||||
bMatchString1 = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// optimize to be scripthandle
|
||||
if ( V_stricmp( pEntryMatch->m_nMatchString1, m_nMatchString1 ) )
|
||||
{
|
||||
bMatchString1 = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_bMatchString2 )
|
||||
{
|
||||
if ( m_bMatchSubString )
|
||||
{
|
||||
if ( V_stristr( pEntryMatch->m_nMatchString2, m_nMatchString2 ) == NULL )
|
||||
{
|
||||
bMatchString2 = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// optimize to be scripthandle
|
||||
if ( V_stricmp( pEntryMatch->m_nMatchString2, m_nMatchString2 ) )
|
||||
{
|
||||
bMatchString2 = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( m_bMatchInt1 )
|
||||
{
|
||||
if ( pEntryMatch->m_nMatchInt1 != m_nMatchInt1 )
|
||||
{
|
||||
bMatchInt1 = false;
|
||||
}
|
||||
}
|
||||
if ( m_bMatchInt2 )
|
||||
{
|
||||
if ( pEntryMatch->m_nMatchInt2 != m_nMatchInt2 )
|
||||
{
|
||||
bMatchInt2 = false;
|
||||
}
|
||||
}
|
||||
if ( m_bMatchInt3 )
|
||||
{
|
||||
if ( pEntryMatch->m_nMatchInt3 != m_nMatchInt3 )
|
||||
{
|
||||
bMatchInt3 = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( ( bMatchString1 && m_bMatchString1 ) || !m_bMatchString1 ) &&
|
||||
( ( bMatchString2 && m_bMatchString2 ) || !m_bMatchString2 )&&
|
||||
( ( bMatchInt1 && m_bMatchInt1 ) || !m_bMatchInt1 ) &&
|
||||
( ( bMatchInt2 && m_bMatchInt2 ) || !m_bMatchInt2 ) &&
|
||||
( ( bMatchInt3 && m_bMatchInt3 ) || !m_bMatchInt3 ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosEntryMatchList
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CSosEntryMatchList::Update()
|
||||
{
|
||||
uint32 bit = 1;
|
||||
for ( int i = 0; i < SOS_BLOCKSYS_MAX_ENTRIES; i++, ( bit <<= 1 ) )
|
||||
{
|
||||
if ( !( m_Free & bit ) )
|
||||
{
|
||||
Assert( !m_vEntryMatchList[i]->m_bFree );
|
||||
if( m_vEntryMatchList[i]->m_bTimed )
|
||||
{
|
||||
if ( m_vEntryMatchList[i]->m_flDuration > -1.0 && m_vEntryMatchList[i]->m_flStartTime > -1.0 )
|
||||
{
|
||||
float flCurTime = g_pSoundServices->GetClientTime();
|
||||
if ( ( m_vEntryMatchList[i]->m_flDuration + m_vEntryMatchList[i]->m_flStartTime ) <= flCurTime )
|
||||
{
|
||||
if( snd_sos_show_entry_match_free.GetInt() )
|
||||
{
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "\nFREEING MATCH ENTRY:\n");
|
||||
m_vEntryMatchList[i]->Print();
|
||||
|
||||
}
|
||||
m_vEntryMatchList[i]->Reset();
|
||||
m_Free |= bit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if( snd_sos_show_entry_match_free.GetInt() )
|
||||
{
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "\nFREEING MATCH ENTRY:\n");
|
||||
m_vEntryMatchList[i]->Print();
|
||||
}
|
||||
m_vEntryMatchList[i]->Reset();
|
||||
m_Free |= bit;
|
||||
}
|
||||
}
|
||||
if( snd_sos_show_block_debug.GetInt() )
|
||||
{
|
||||
m_vEntryMatchList[i]->Print();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CSosEntryMatchList::GetFreeEntryIndex() const
|
||||
{
|
||||
uint32 bit = 1;
|
||||
for( int i = 0; i < SOS_BLOCKSYS_MAX_ENTRIES; i++, ( bit <<= 1 ) )
|
||||
{
|
||||
if ( m_vEntryMatchList[i]->m_bFree )
|
||||
{
|
||||
Assert( m_Free & bit );
|
||||
m_vEntryMatchList[i]->m_bFree = false;
|
||||
m_Free &= ~bit;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
CSosManagedEntryMatch *CSosEntryMatchList::GetEntryFromIndex( int nIndex ) const
|
||||
{
|
||||
Assert( IsValidIndex( nIndex ) );
|
||||
|
||||
if ( IsValidIndex( nIndex ) )
|
||||
{
|
||||
return m_vEntryMatchList[ nIndex ];
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
CSosManagedEntryMatch *CSosEntryMatchList::GetFreeEntry( int &nIndex ) const
|
||||
{
|
||||
int nMatchEntryIndex = g_pSoundOperatorSystem->m_sosEntryBlockList.GetFreeEntryIndex();
|
||||
|
||||
CSosManagedEntryMatch *pSosEntryMatch = g_pSoundOperatorSystem->m_sosEntryBlockList.GetEntryFromIndex( nMatchEntryIndex );
|
||||
if ( !pSosEntryMatch )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: EntryMatchList has no free slots!\n" );
|
||||
nIndex = -1;
|
||||
return NULL;
|
||||
}
|
||||
return pSosEntryMatch;
|
||||
|
||||
}
|
||||
void CSosEntryMatchList::FreeEntry( int nIndex, bool bForce /* = false */ )
|
||||
{
|
||||
if ( !m_vEntryMatchList[ nIndex ]->m_bTimed || bForce )
|
||||
{
|
||||
m_vEntryMatchList[ nIndex ]->Reset();
|
||||
m_Free |= GetBitForBitnum( nIndex );
|
||||
}
|
||||
}
|
||||
|
||||
bool CSosEntryMatchList::HasAMatch( CSosEntryMatch *pEntryMatch ) const
|
||||
{
|
||||
uint32 bit = 1;
|
||||
for( int i = 0; i < SOS_BLOCKSYS_MAX_ENTRIES; i++, (bit <<= 1) )
|
||||
{
|
||||
if ( !( m_Free & bit ) && m_vEntryMatchList[i]->m_bActive )
|
||||
{
|
||||
Assert( !m_vEntryMatchList[i]->m_bFree );
|
||||
if ( m_vEntryMatchList[i]->IsAMatch( pEntryMatch ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void CSosEntryMatchList::Print() const
|
||||
{
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "\nCUE Operators:\n");
|
||||
}
|
||||
169
engine/audio/private/snd_op_sys/sos_entry_match_system.h
Normal file
169
engine/audio/private/snd_op_sys/sos_entry_match_system.h
Normal file
@@ -0,0 +1,169 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_ENTRY_MATCH_SYSTEM_H
|
||||
#define SOS_ENTRY_MATCH_SYSTEM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "bitvec.h"
|
||||
//#include "snd_channels.h"
|
||||
|
||||
// Externs the logging channel
|
||||
DECLARE_LOGGING_CHANNEL( LOG_SND_OPERATORS );
|
||||
|
||||
extern Color StackColor;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Match Entry system
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CSosEntryMatch
|
||||
{
|
||||
|
||||
public:
|
||||
CSosEntryMatch()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
m_nMatchString1[0] = '\n';
|
||||
m_bMatchString1 = false;
|
||||
m_nMatchString2[0] = '\n';
|
||||
m_bMatchString2 = false;
|
||||
m_bMatchSubString = false;
|
||||
m_nMatchInt1 = -1;
|
||||
m_bMatchInt1 = false;
|
||||
m_nMatchInt2 = -1;
|
||||
m_bMatchInt2 = false;
|
||||
m_nMatchInt3 = -1;
|
||||
m_bMatchInt3 = false;
|
||||
}
|
||||
|
||||
bool IsAMatch( CSosEntryMatch *pEntryMatch );
|
||||
|
||||
public:
|
||||
char m_nMatchString1[64];
|
||||
bool m_bMatchString1;
|
||||
char m_nMatchString2[64];
|
||||
bool m_bMatchString2;
|
||||
bool m_bMatchSubString;
|
||||
int m_nMatchInt1;
|
||||
bool m_bMatchInt1;
|
||||
int m_nMatchInt2;
|
||||
bool m_bMatchInt2;
|
||||
int m_nMatchInt3;
|
||||
bool m_bMatchInt3;
|
||||
|
||||
};
|
||||
|
||||
class CSosEntryMatchList;
|
||||
class CSosManagedEntryMatch : public CSosEntryMatch
|
||||
{
|
||||
friend class CSosEntryMatchList;
|
||||
|
||||
void Reset()
|
||||
{
|
||||
CSosEntryMatch::Reset();
|
||||
m_bActive = false;
|
||||
m_bTimed = false;
|
||||
m_flStartTime = -1.0;
|
||||
m_flDuration = -1.0;
|
||||
m_bFree = true;
|
||||
}
|
||||
|
||||
public:
|
||||
void Start()
|
||||
{
|
||||
m_flStartTime = g_pSoundServices->GetClientTime();
|
||||
}
|
||||
private:
|
||||
void Print()
|
||||
{
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Match String 1: %s\n", m_nMatchString1 );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Match String 1?: %s\n", m_bMatchString1 ? "true" : "false" );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Match String 2: %s\n", m_nMatchString2 );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Match String 2?: %s\n", m_bMatchString2 ? "true" : "false" );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Match SubString ?: %s\n", m_bMatchSubString ? "true" : "false" );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Match Int 1: %i\n", m_nMatchInt1 );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Match Int 1?: %s\n", m_bMatchInt1 ? "true" : "false" );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Match Int 2: %i\n", m_nMatchInt2 );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Match Int 2?: %s\n", m_bMatchInt2 ? "true" : "false" );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Match Int 3: %i\n", m_nMatchInt3 );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Match Int 3?: %s\n", m_bMatchInt3 ? "true" : "false" );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Timed ?: %s\n", m_bTimed ? "true" : "false" );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Duration: %f\n", m_flDuration );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "StartTime: %f\n", m_flStartTime );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "StopTime: %f\n", m_flStartTime + m_flDuration );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "CurTime: %f\n", g_pSoundServices->GetClientTime() );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Active ?: %s\n", m_bActive ? "true" : "false" );
|
||||
Log_Msg( LOG_SOUND_OPERATOR_SYSTEM, StackColor, "Free ?: %s\n", m_bFree ? "true" : "false" );
|
||||
}
|
||||
|
||||
bool m_bFree;
|
||||
public:
|
||||
bool m_bActive;
|
||||
bool m_bTimed;
|
||||
float m_flStartTime;
|
||||
float m_flDuration;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define SOS_BLOCKSYS_MAX_ENTRIES 32
|
||||
|
||||
class CSosEntryMatchList
|
||||
{
|
||||
|
||||
public:
|
||||
~CSosEntryMatchList()
|
||||
{
|
||||
for( int i = 0; i < SOS_BLOCKSYS_MAX_ENTRIES; i++ )
|
||||
{
|
||||
delete m_vEntryMatchList[i];
|
||||
m_vEntryMatchList[i] = NULL;
|
||||
}
|
||||
}
|
||||
CSosEntryMatchList()
|
||||
{
|
||||
uint32 bit = 1;
|
||||
for( int i = 0; i < SOS_BLOCKSYS_MAX_ENTRIES; i++, ( bit <<= 1 ) )
|
||||
{
|
||||
m_vEntryMatchList[i] = new CSosManagedEntryMatch;
|
||||
m_vEntryMatchList[i]->Reset();
|
||||
m_Free |= bit;
|
||||
}
|
||||
}
|
||||
void Update();
|
||||
inline void Start( int nIndex ) { m_vEntryMatchList[ nIndex ]->Start(); }
|
||||
inline bool IsValidIndex( int nIndex ) const { return nIndex > -1 && nIndex < SOS_BLOCKSYS_MAX_ENTRIES; }
|
||||
int GetFreeEntryIndex() const;
|
||||
CSosManagedEntryMatch *GetEntryFromIndex( int nIndex ) const ;
|
||||
CSosManagedEntryMatch *GetFreeEntry( int &nIndex ) const ;
|
||||
|
||||
void FreeEntry( int nIndex, bool bForce = false );
|
||||
|
||||
bool HasAMatch( CSosEntryMatch *pEntryMatch ) const;
|
||||
void Print() const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
mutable uint32 m_Free;
|
||||
CSosManagedEntryMatch *m_vEntryMatchList[ SOS_BLOCKSYS_MAX_ENTRIES ];
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // SOS_ENTRY_MATCH_SYSTEM_H
|
||||
441
engine/audio/private/snd_op_sys/sos_op.cpp
Normal file
441
engine/audio/private/snd_op_sys/sos_op.cpp
Normal file
@@ -0,0 +1,441 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
extern ConVar snd_sos_show_operator_init;
|
||||
extern ConVar snd_sos_show_operator_shutdown;
|
||||
|
||||
BEGIN_DEFINE_LOGGING_CHANNEL( LOG_SND_OPERATORS, "SndOperators", LCF_CONSOLE_ONLY, LS_MESSAGE );
|
||||
ADD_LOGGING_CHANNEL_TAG( "SndOperators" );
|
||||
ADD_LOGGING_CHANNEL_TAG( "SND" );
|
||||
END_DEFINE_LOGGING_CHANNEL();
|
||||
|
||||
|
||||
Color OpNameColor( 185, 215, 255, 255 );
|
||||
Color OpColor( 185, 185, 255, 255 );
|
||||
Color ConnectColor( 255, 185, 255, 255 );
|
||||
Color NotExecuteColor( 255, 0, 0, 255 );
|
||||
Color ResultColor( 255, 185, 185, 255 );
|
||||
int foo;
|
||||
|
||||
void S_GetFloatFromString( float *pFlVector, const char *pString, int nSize = 3 )
|
||||
{
|
||||
char tempString[128];
|
||||
Q_strncpy( tempString, pString, sizeof(tempString) );
|
||||
|
||||
int i = 0;
|
||||
char *token = strtok( tempString, "," );
|
||||
while( token )
|
||||
{
|
||||
*pFlVector = atof( token );
|
||||
token = strtok( NULL, "," );
|
||||
i++;
|
||||
if ( i >= nSize )
|
||||
{
|
||||
break;
|
||||
}
|
||||
pFlVector++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperator
|
||||
// Operator base class
|
||||
//-----------------------------------------------------------------------------
|
||||
CSosOperator::CSosOperator( )
|
||||
{
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperator, m_flExecute, SO_SINGLE, "input_execute" )
|
||||
}
|
||||
|
||||
void CSosOperator::SetBaseDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperator_t *pStructMem = (CSosOperator_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flExecute, SO_SINGLE, 1.0 )
|
||||
pStructMem->m_bExecuteOnce = false;
|
||||
pStructMem->m_bHasExecuted = false;
|
||||
}
|
||||
|
||||
void CSosOperator::PrintIO( CSosOperator_t *pStructMem, CSosOperatorStack *pStack, int nLevel ) const
|
||||
{
|
||||
|
||||
int nNumberOfInputs = m_vInputs.Count();
|
||||
for(int i = 0; i < nNumberOfInputs; i++ )
|
||||
{
|
||||
const InputData_t & inputData = m_vInputs[i];
|
||||
|
||||
const char *pInputName = m_vInputMap.GetElementName( i );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor , "%*s%s: ", nLevel, " ", pInputName );
|
||||
|
||||
int nConnections[8];
|
||||
int nNumConnections = 0;
|
||||
|
||||
char *pInputValue = (char *)pStructMem + inputData.m_nValueOffset;
|
||||
char *pOffsetOffset = (char *)pStructMem + inputData.m_nOffsetOffset;
|
||||
bool bAnyConnected = false;
|
||||
for( int j = 0; j < inputData.m_nCount; j++ )
|
||||
{
|
||||
|
||||
int nOffsetValue = *((int *)pOffsetOffset + j );
|
||||
bool bIsConnected = nOffsetValue < 0 ? false : true ;
|
||||
bAnyConnected |= bIsConnected;
|
||||
if( bIsConnected )
|
||||
{
|
||||
nConnections[ nNumConnections ] = nOffsetValue;
|
||||
nNumConnections++;
|
||||
}
|
||||
else
|
||||
{
|
||||
nConnections[ nNumConnections ] = -1;
|
||||
nNumConnections++;
|
||||
}
|
||||
|
||||
Color connectedColor = bIsConnected ? ConnectColor : OpColor;
|
||||
|
||||
switch( inputData.m_Type )
|
||||
{
|
||||
case SO_FLOAT:
|
||||
Log_Msg( LOG_SND_OPERATORS, connectedColor, "%f ", *((float *)pInputValue+j) );
|
||||
break;
|
||||
default:
|
||||
Log_Msg( LOG_SND_OPERATORS, connectedColor, " UNKNOWN DATA TYPE %i ", inputData.m_Type );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( bAnyConnected )
|
||||
{
|
||||
int nOpIndex = pStack->FindOperatorViaOffset( nConnections[0] );
|
||||
Log_Msg( LOG_SND_OPERATORS, ConnectColor, "%%(connected: %s", pStack->GetOperatorName( nOpIndex ) );
|
||||
|
||||
if( nNumConnections > 0 )
|
||||
{
|
||||
for( int k = 0; k < nNumConnections; k++ )
|
||||
{
|
||||
Log_Msg( LOG_SND_OPERATORS, ConnectColor, " %i", nConnections[k] );
|
||||
}
|
||||
}
|
||||
Log_Msg( LOG_SND_OPERATORS, ConnectColor, ")");
|
||||
}
|
||||
Log_Msg( LOG_SND_OPERATORS, ConnectColor, "\n");
|
||||
|
||||
}
|
||||
|
||||
int nNumberOfOutputs = m_vOutputs.Count();
|
||||
for(int i = 0; i < nNumberOfOutputs; i++ )
|
||||
{
|
||||
const OutputData_t & outputData = m_vOutputs[i];
|
||||
const char *pOutputName = m_vOutputMap.GetElementName( i );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*s%s: ", nLevel, " ", pOutputName );
|
||||
|
||||
char *pOutput = (char *)pStructMem + outputData.m_nValueOffset;
|
||||
for( int j = 0; j < outputData.m_nCount; j++ )
|
||||
{
|
||||
switch( outputData.m_Type )
|
||||
{
|
||||
case SO_FLOAT:
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%f ", *((float *)pOutput+j) );
|
||||
break;
|
||||
default:
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, " UNKNOWN DATA TYPE %i ", outputData.m_Type );
|
||||
break;
|
||||
}
|
||||
}
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
void CSosOperator::PrintBaseParams( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperator_t *pStructMem = (CSosOperator_t *)pVoidMem;
|
||||
const char *pName = pStack->GetOperatorName( nOpIndex );
|
||||
Color executeColor = ( ( pStructMem->m_flExecute[0] > 0.0 ) && !( pStructMem->m_bExecuteOnce && pStructMem->m_bHasExecuted ) ) ? OpNameColor : NotExecuteColor;
|
||||
Log_Msg( LOG_SND_OPERATORS, executeColor, "\n%*sName: %s\n", nLevel, " ", pName );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "\n%*sExecute Once: %s\n", nLevel, " ", pStructMem->m_bExecuteOnce ? "true" : "false" );
|
||||
|
||||
PrintIO( pStructMem, pStack, nLevel );
|
||||
}
|
||||
|
||||
int CSosOperator::ParseValueRef( CSosOperatorStack *pStack, const char *pParamString, const char *pValueString ) const
|
||||
{
|
||||
if ( pValueString[0] == VALUE_REF_CHAR )
|
||||
{
|
||||
pValueString++;
|
||||
char tempString[64];
|
||||
Q_strncpy( tempString, pValueString, sizeof(tempString) );
|
||||
|
||||
char *pOpname = strtok( tempString, "." );
|
||||
char *pOutputName = strtok( NULL, "");
|
||||
int nOutOffset = pStack->GetOperatorOutputOffset( pOpname, pOutputName );
|
||||
if ( nOutOffset < 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int nOutIndex = BaseParseHasArrayIndice( pOutputName );
|
||||
if ( nOutIndex > -1 )
|
||||
{
|
||||
nOutOffset += nOutIndex;
|
||||
}
|
||||
|
||||
return nOutOffset;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
int CSosOperator::BaseParseHasArrayIndice( const char *pParamString ) const
|
||||
{
|
||||
int nInputIndex = -1;
|
||||
char tempString[64];
|
||||
Q_strncpy( tempString, pParamString, sizeof(tempString) );
|
||||
// char *pInputParamString = strtok( tempString, "[" );
|
||||
char *pIndexString = strtok( NULL, "]");
|
||||
if ( pIndexString && *pIndexString )
|
||||
{
|
||||
nInputIndex = Q_atoi( pIndexString );
|
||||
}
|
||||
return nInputIndex;
|
||||
|
||||
}
|
||||
|
||||
bool CSosOperator::BaseParseKV( CSosOperatorStack *pStack, CSosOperator_t *pStructMem, const char *pParamString, const char *pValueString ) const
|
||||
{
|
||||
// if we succeed in finding the specified parameter we return true otw false
|
||||
|
||||
if ( pParamString && *pParamString && pValueString && *pValueString )
|
||||
{
|
||||
// check for simple global params
|
||||
if ( !V_strcasecmp( pParamString, "operator" ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "execute_once" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bExecuteOnce = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bExecuteOnce = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// is this accessing into the array?
|
||||
// "parse" it, UGLY, CLEAN IT... move it to "HasIndice"
|
||||
// int nInputIndex = BaseParseHasArrayIndice( pParamString );
|
||||
|
||||
int nInputIndex = -1;
|
||||
char tempString[64];
|
||||
Q_strncpy( tempString, pParamString, sizeof(tempString) );
|
||||
char *pInputParamString = strtok( tempString, "[" );
|
||||
char *pIndexString = strtok( NULL, "]");
|
||||
bool bFillInputArray = false;
|
||||
if ( pIndexString && *pIndexString )
|
||||
{
|
||||
if ( pIndexString[0] == '*' )
|
||||
{
|
||||
bFillInputArray = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
nInputIndex = Q_atoi( pIndexString );
|
||||
}
|
||||
}
|
||||
|
||||
// find the input
|
||||
int nInputParamIndex = m_vInputMap.Find( pInputParamString );
|
||||
|
||||
if ( ! m_vInputs.IsValidIndex( nInputParamIndex ) )
|
||||
{
|
||||
// Log_Warning( LOG_SND_OPERATORS, "Error: Unable to find input parameter %s", pParamString );
|
||||
return false;
|
||||
}
|
||||
const InputData_t & inputData = m_vInputs[ nInputParamIndex ];
|
||||
short nCount = inputData.m_nCount;
|
||||
|
||||
// gotta put some kind of type matching test in here!
|
||||
// SODataType_t nType = m_vInputType[ nInputParamIndex ];
|
||||
|
||||
int nOffsetOffset = inputData.m_nOffsetOffset;
|
||||
|
||||
int nOutputOffset = ParseValueRef( pStack, pParamString, pValueString );
|
||||
if ( nOutputOffset > -1 )
|
||||
{
|
||||
if ( nInputIndex > -1 )
|
||||
{
|
||||
if ( nInputIndex < nCount )
|
||||
{
|
||||
*((int *)((char *)pStructMem + nOffsetOffset) + nInputIndex) = nOutputOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, illegal array access: %s", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < nCount; i++ )
|
||||
{
|
||||
if ( bFillInputArray )
|
||||
{
|
||||
*((int *)((char *)pStructMem + nOffsetOffset) + i) = nOutputOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
*((int *)((char *)pStructMem + nOffsetOffset) + i) = ( nOutputOffset + (sizeof(float)*i) );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if an input is explicit, fill array with single value
|
||||
int nInputOffset = inputData.m_nValueOffset;
|
||||
float flValue = RandomInterval( ReadInterval( pValueString ) );
|
||||
//S_GetFloatFromString( &flValue, pValueString );
|
||||
|
||||
if ( nInputIndex > -1 )
|
||||
{
|
||||
if ( nInputIndex < nCount )
|
||||
{
|
||||
*((float *)( (char *)pStructMem + nInputOffset ) + nInputIndex ) = flValue;
|
||||
|
||||
// clear potential previous connections
|
||||
*((int *)((char *)pStructMem + nOffsetOffset) + nInputIndex) = -1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//error
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < nCount; i++ )
|
||||
{
|
||||
*((float *)( (char *)pStructMem + nInputOffset ) + i )= flValue;
|
||||
|
||||
// clear potential previous connections
|
||||
*((int *)((char *)pStructMem + nOffsetOffset) + i) = nOutputOffset;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int CSosOperator::GetOutputOffset( const char *pOutputName ) const
|
||||
{
|
||||
int nIndex = m_vOutputMap.Find( pOutputName );
|
||||
if ( !m_vOutputs.IsValidIndex( nIndex ) )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Unable to find referenced sound operator output: %s", pOutputName );
|
||||
return -1;
|
||||
}
|
||||
return m_vOutputs[ nIndex ].m_nValueOffset;
|
||||
}
|
||||
|
||||
void CSosOperator::ResolveInputValue( void *pInputDefault, int *pOffsetArray, short nDataCount, SODataType_t nDataType, void *pStackMem ) const
|
||||
{
|
||||
size_t nDataSize = 0;
|
||||
switch( nDataType )
|
||||
{
|
||||
case SO_FLOAT:
|
||||
nDataSize = sizeof( float );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < nDataCount; i++ )
|
||||
{
|
||||
int nOffset = *( pOffsetArray + i );
|
||||
void *pSrc = NULL;
|
||||
if ( nOffset > -1 )
|
||||
{
|
||||
|
||||
// pSrc = (float *)( (char *)pStackMem + nOffset );
|
||||
pSrc = ( void *)( (char *)pStackMem + nOffset );
|
||||
Q_memcpy( ( void *) ( (char *) pInputDefault + ( i * nDataSize ) ) , pSrc, nDataSize );
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// // copying from itself to itself?
|
||||
// pSrc = ( void *) ( (char *) pInputDefault + ( i * nDataSize ) );
|
||||
// }
|
||||
//
|
||||
//
|
||||
// Q_memcpy( pInputDefault[i] , pSrc, nDataSize );
|
||||
// pInputDefault[i] = *pSrc;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CSosOperator::ResolveInputValues( void *pStructMem, void *pStackMem ) const
|
||||
{
|
||||
for ( unsigned int i = 0; i < m_vInputMap.Count(); i++ )
|
||||
{
|
||||
int nInputIndex = m_vInputMap[ i ];
|
||||
const InputData_t & inputData = m_vInputs[ nInputIndex ];
|
||||
SODataType_t nDataType = inputData.m_Type;
|
||||
short nDataCount = inputData.m_nCount;
|
||||
|
||||
size_t nOffset = inputData.m_nValueOffset;
|
||||
int nOffsetOffset = inputData.m_nOffsetOffset;
|
||||
void *pInput = (void *)( (char *)pStructMem + nOffset );
|
||||
int *pOffset = (int *)( (char *)pStructMem + nOffsetOffset );
|
||||
|
||||
ResolveInputValue( pInput, pOffset, nDataCount, nDataType, pStackMem );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CSosOperator::OffsetConnections( void *pVoidMem, size_t nOffset ) const
|
||||
{
|
||||
// point offsets to a different memory segment
|
||||
for ( unsigned int i = 0; i < m_vInputMap.Count(); i++ )
|
||||
{
|
||||
int nInputIndex = m_vInputMap[ i ];
|
||||
|
||||
const InputData_t & inputData = m_vInputs[ nInputIndex ];
|
||||
// SODataType_t nDataType = inputData.m_Type;
|
||||
short nDataCount = inputData.m_nCount;
|
||||
|
||||
int nOffsetOffset = m_vInputs[ nInputIndex ].m_nOffsetOffset;
|
||||
int *pOffset = (int *)( (char *)pVoidMem + nOffsetOffset );
|
||||
|
||||
for( int j = 0; j < nDataCount; j++ )
|
||||
{
|
||||
if ( *(pOffset + j) > -1 )
|
||||
{
|
||||
*(pOffset + j) += nOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSosOperator::StackInit( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex )
|
||||
{
|
||||
|
||||
}
|
||||
void CSosOperator::StackShutdown( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex )
|
||||
{
|
||||
if ( snd_sos_show_operator_shutdown.GetInt() )
|
||||
{
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "Stack Shutdown: Stack: %s : Operator: %s\n", pStack->GetName(), pStack->GetOperatorName( nOpIndex ) );
|
||||
}
|
||||
}
|
||||
170
engine/audio/private/snd_op_sys/sos_op.h
Normal file
170
engine/audio/private/snd_op_sys/sos_op.h
Normal file
@@ -0,0 +1,170 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_H
|
||||
#define SOS_OP_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_system.h"
|
||||
#include "snd_channels.h"
|
||||
|
||||
// Externs the logging channel
|
||||
DECLARE_LOGGING_CHANNEL( LOG_SND_OPERATORS );
|
||||
|
||||
|
||||
|
||||
#define THREAD_LOCK_SOUND() AUTO_LOCK( g_SndMutex )
|
||||
|
||||
|
||||
|
||||
|
||||
#define VALUE_REF_CHAR '@'
|
||||
#define CLOSE_SQ_BRACKET ']'
|
||||
|
||||
#define SOS_INPUT_FLOAT( memberName, memberCount ) \
|
||||
float memberName[memberCount]; \
|
||||
int memberName##Offset[memberCount];
|
||||
|
||||
#define SOS_OUTPUT_FLOAT( memberName, memberCount ) \
|
||||
float memberName[memberCount];
|
||||
|
||||
#define SOS_INIT_INPUT_VAR( memberName, memberCount, value ) \
|
||||
for( int i = 0; i < memberCount; i++ ) \
|
||||
{ pStructMem->memberName[i] = value; pStructMem->memberName##Offset[i] = -1; }
|
||||
|
||||
#define SOS_INIT_OUTPUT_VAR( memberName, memberType, value ) \
|
||||
for( int i = 0; i < memberType; i++ ) \
|
||||
{ pStructMem->memberName[i] = value; }
|
||||
|
||||
#define SOS_REGISTER_INPUT( className, memberName, memberCount, memberString, type ) \
|
||||
{ \
|
||||
InputData_t inputData; \
|
||||
inputData.m_nValueOffset = offsetof( className##_t, memberName ); \
|
||||
inputData.m_nOffsetOffset = offsetof( className##_t, memberName##Offset ); \
|
||||
inputData.m_Type = type; \
|
||||
inputData.m_nCount = memberCount; \
|
||||
int nIndex = m_vInputs.AddToTail( inputData ); \
|
||||
m_vInputMap.Insert( memberString, nIndex ); \
|
||||
}
|
||||
|
||||
#define SOS_REGISTER_INPUT_FLOAT( className, memberName, memberCount, memberString ) \
|
||||
SOS_REGISTER_INPUT( className, memberName, memberCount, memberString, SO_FLOAT )
|
||||
|
||||
#define SOS_REGISTER_OUTPUT( className, memberName, memberCount, memberString, type ) \
|
||||
{ \
|
||||
OutputData_t outputData; \
|
||||
outputData.m_nValueOffset = offsetof( className##_t, memberName ); \
|
||||
outputData.m_Type = type; \
|
||||
outputData.m_nCount = memberCount; \
|
||||
int nIndex = m_vOutputs.AddToTail( outputData ); \
|
||||
m_vOutputMap.Insert( memberString, nIndex ); \
|
||||
}
|
||||
|
||||
#define SOS_REGISTER_OUTPUT_FLOAT( className, memberName, memberCount, memberString ) \
|
||||
SOS_REGISTER_OUTPUT( className, memberName, memberCount, memberString, SO_FLOAT )
|
||||
|
||||
|
||||
|
||||
#define SOS_BEGIN_OPERATOR_CONSTRUCTOR( classname, operatorstring ) \
|
||||
classname::classname() \
|
||||
{
|
||||
|
||||
|
||||
#define SOS_END_OPERATOR_CONSTRUCTOR( classname, operatorstring ) \
|
||||
g_pSoundOperatorSystem->m_vOperatorCollection.Insert(operatorstring, this ); \
|
||||
} \
|
||||
classname g_##classname;
|
||||
|
||||
|
||||
#define SOS_HEADER_DESC( classname ) \
|
||||
public: \
|
||||
classname(); \
|
||||
virtual void SetDefaults( void *pVoidMem ) const ; \
|
||||
virtual size_t GetSize() const { return sizeof( classname##_t ); } \
|
||||
virtual void Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const ; \
|
||||
virtual void Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const ; \
|
||||
virtual void OpHelp( ) const ; \
|
||||
virtual void ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pParamKV ) const ; \
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The CSosOperator class:
|
||||
//
|
||||
// Base class for all sound operators, each operator must override "execute"
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flExecute, SO_SINGLE )
|
||||
bool m_bExecuteOnce;
|
||||
bool m_bHasExecuted;
|
||||
};
|
||||
|
||||
|
||||
class CSosOperator
|
||||
{
|
||||
public:
|
||||
|
||||
CSosOperator();
|
||||
virtual ~CSosOperator() { } ;
|
||||
int GetOutputOffset( const char *pOutputName ) const;
|
||||
// Proposal to optimize this:
|
||||
// For each InputData_t, we store a function pointer to handle the resolution.
|
||||
// We would create a different resolve function for the major cases (write a float, write 3 floats, generic case - same as current implementation).
|
||||
// When filling the inputs initially, we would store the optimal function pointer.
|
||||
// Cost: 4 bytes per InputData_t
|
||||
// One dynamic call instead of one static call (currently ResolveInputValue).
|
||||
// But then in most cases, the implementation would more efficient (estimated at 4 to 10 times faster).
|
||||
void ResolveInputValue( void *pInputDefault, int *pOffsetArray, short nDataCount, SODataType_t nDataType, void *pStackMem ) const;
|
||||
void ResolveInputValues( void *pStructMem, void *pStackMem ) const;
|
||||
void OffsetConnections( void *pVoidMem, size_t nOffset ) const;
|
||||
bool BaseParseKV( CSosOperatorStack *pStack, CSosOperator_t *pStructMem, const char *pParamString, const char *pValueString ) const;
|
||||
int ParseValueRef( CSosOperatorStack *pStack, const char *pParamString, const char *pValueString ) const;
|
||||
void PrintBaseParams( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const;
|
||||
void PrintIO( CSosOperator_t *pStructMem, CSosOperatorStack *pStack, int nLevel ) const;
|
||||
int BaseParseHasArrayIndice( const char *pParamString ) const;
|
||||
void SetBaseDefaults( void *pVoidMem ) const;
|
||||
|
||||
virtual void SetDefaults( void *pVoidMem ) const = 0;
|
||||
virtual size_t GetSize() const = 0;
|
||||
virtual void Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const = 0;
|
||||
virtual void Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const = 0;
|
||||
virtual void OpHelp( ) const = 0;
|
||||
virtual void ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pParamKV ) const = 0;
|
||||
|
||||
virtual void StackInit( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex );
|
||||
virtual void StackShutdown( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex );
|
||||
|
||||
|
||||
protected:
|
||||
public:
|
||||
|
||||
struct OutputData_t
|
||||
{
|
||||
size_t m_nValueOffset;
|
||||
SODataType_t m_Type;
|
||||
short m_nCount;
|
||||
};
|
||||
|
||||
struct InputData_t
|
||||
{
|
||||
size_t m_nValueOffset;
|
||||
size_t m_nOffsetOffset;
|
||||
SODataType_t m_Type;
|
||||
short m_nCount;
|
||||
};
|
||||
|
||||
CUtlDict <int, int> m_vOutputMap;
|
||||
CUtlVector < OutputData_t > m_vOutputs;
|
||||
|
||||
CUtlDict <int, int> m_vInputMap;
|
||||
CUtlVector< InputData_t > m_vInputs;
|
||||
};
|
||||
|
||||
#endif // SOS_OP_H
|
||||
215
engine/audio/private/snd_op_sys/sos_op_block_entry.cpp
Normal file
215
engine/audio/private/snd_op_sys/sos_op_block_entry.cpp
Normal file
@@ -0,0 +1,215 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_entry_match_system.h"
|
||||
#include "sos_op_block_entry.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorBlockEntry
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorBlockEntry, "sys_block_entries" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorBlockEntry, m_flInputDuration, SO_SINGLE, "input_duration" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorBlockEntry, m_flInputActive, SO_SINGLE, "input_active" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorBlockEntry, "sys_block_entries" )
|
||||
|
||||
|
||||
void CSosOperatorBlockEntry::StackShutdown( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex )
|
||||
{
|
||||
CSosOperatorBlockEntry_t *pStructMem = (CSosOperatorBlockEntry_t *)pVoidMem;
|
||||
|
||||
if( pStructMem->m_nEntryIndex > -1 )
|
||||
{
|
||||
//g_pSoundOperatorSystem->m_sosEntryBlockList.FreeEntry( pStructMem->m_nEntryIndex );
|
||||
}
|
||||
}
|
||||
|
||||
void CSosOperatorBlockEntry::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorBlockEntry_t *pStructMem = (CSosOperatorBlockEntry_t *)pVoidMem;
|
||||
V_strncpy( pStructMem->m_nMatchEntryName, "", sizeof(pStructMem->m_nMatchEntryName) );
|
||||
V_strncpy( pStructMem->m_nMatchSoundName, "", sizeof(pStructMem->m_nMatchSoundName) );
|
||||
pStructMem->m_bMatchEntry = false;
|
||||
pStructMem->m_bMatchSound = false;
|
||||
pStructMem->m_bMatchEntity = false;
|
||||
pStructMem->m_bMatchChannel = false;
|
||||
pStructMem->m_bMatchSubString = false;
|
||||
pStructMem->m_nEntryIndex = -1;
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flInputDuration, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputActive, SO_SINGLE, 1.0 )
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorBlockEntry::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
// THREAD_LOCK_SOUND();
|
||||
|
||||
CSosOperatorBlockEntry_t *pStructMem = (CSosOperatorBlockEntry_t *)pVoidMem;
|
||||
|
||||
|
||||
if( pStructMem->m_nEntryIndex < 0 )
|
||||
{
|
||||
|
||||
int nMatchEntryIndex = g_pSoundOperatorSystem->m_sosEntryBlockList.GetFreeEntryIndex();
|
||||
|
||||
CSosManagedEntryMatch *pSosEntryMatch = g_pSoundOperatorSystem->m_sosEntryBlockList.GetEntryFromIndex( nMatchEntryIndex );
|
||||
if( !pSosEntryMatch )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, EntryMatchList has no free slots!\n", pStack->GetOperatorName( nOpIndex ) );
|
||||
return;
|
||||
}
|
||||
|
||||
pStructMem->m_nEntryIndex = nMatchEntryIndex;
|
||||
pSosEntryMatch->m_bMatchString1 = pStructMem->m_bMatchEntry;
|
||||
V_strncpy( pSosEntryMatch->m_nMatchString1, pStructMem->m_nMatchEntryName, sizeof( pSosEntryMatch->m_nMatchString1 ) );
|
||||
|
||||
// pSosEntryMatch->m_bMatchString2 = pStructMem->m_bMatchSound;
|
||||
// V_strncpy( pSosEntryMatch->m_nMatchString2, pStructMem->m_nMatchSoundName, sizeof( pSosEntryMatch->m_nMatchString2 ) );
|
||||
|
||||
pSosEntryMatch->m_bMatchSubString = pStructMem->m_bMatchSubString;
|
||||
|
||||
pSosEntryMatch->m_bMatchInt1 = pStructMem->m_bMatchChannel;
|
||||
pSosEntryMatch->m_nMatchInt1 = pScratchPad->m_nChannel;
|
||||
|
||||
pSosEntryMatch->m_bMatchInt2 = pStructMem->m_bMatchEntity;
|
||||
pSosEntryMatch->m_nMatchInt2 = pScratchPad->m_nSoundSource;
|
||||
|
||||
pSosEntryMatch->Start();
|
||||
|
||||
}
|
||||
|
||||
CSosManagedEntryMatch *pSosEntryMatch = g_pSoundOperatorSystem->m_sosEntryBlockList.GetEntryFromIndex( pStructMem->m_nEntryIndex );
|
||||
if( pSosEntryMatch )
|
||||
{
|
||||
// defaults for now
|
||||
pSosEntryMatch->m_bActive = pStructMem->m_flInputActive[0] > 0.0 ? true : false;
|
||||
|
||||
pSosEntryMatch->m_flDuration = pStructMem->m_flInputDuration[0] >= 0.0 ? pStructMem->m_flInputDuration[0] : 0.0;
|
||||
//pSosEntryMatch->m_bTimed = pSosEntryMatch->m_flDuration > -1 ? true : false;
|
||||
pSosEntryMatch->m_bTimed = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorBlockEntry::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorBlockEntry_t *pStructMem = (CSosOperatorBlockEntry_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
// Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sNumber Allowed: %i\n", nLevel, " ", pStructMem->m_nNumAllowed );
|
||||
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*smatch_entry: %s\n", nLevel, " ", pStructMem->m_bMatchEntry ? pStructMem->m_nMatchEntryName : "\"\"" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*smatch_sound: %s\n", nLevel, " ", pStructMem->m_bMatchSound ? pStructMem->m_nMatchSoundName : "\"\"" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*smatch_entity: %s\n", nLevel, " ", pStructMem->m_bMatchEntity ? "true" : "false" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*smatch_channel: %s\n", nLevel, " ", pStructMem->m_bMatchEntity ? "true" : "false" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*smatch_substring: %s\n", nLevel, " ", pStructMem->m_bMatchSubString ? "true" : "false" );
|
||||
|
||||
|
||||
}
|
||||
void CSosOperatorBlockEntry::OpHelp( ) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorBlockEntry::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorBlockEntry_t *pStructMem = (CSosOperatorBlockEntry_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "match_entry" ) )
|
||||
{
|
||||
pStructMem->m_bMatchEntry = true;
|
||||
V_strncpy( pStructMem->m_nMatchEntryName, pValueString, sizeof(pStructMem->m_nMatchEntryName) );
|
||||
}
|
||||
// else if ( !V_strcasecmp( pParamString, "match_sound" ) )
|
||||
// {
|
||||
// pStructMem->m_bMatchSound = true;
|
||||
// V_strncpy( pStructMem->m_nMatchSoundName, pValueString, sizeof(pStructMem->m_nMatchSoundName) );
|
||||
// }
|
||||
else if ( !V_strcasecmp( pParamString, "match_entity" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bMatchEntity = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bMatchEntity = false;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "match_channel" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bMatchChannel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bMatchChannel = false;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "match_substring" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bMatchSubString = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bMatchSubString = false;
|
||||
}
|
||||
}
|
||||
// else if ( !V_strcasecmp( pParamString, "stop_oldest" ) )
|
||||
// {
|
||||
// if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
// {
|
||||
// pStructMem->m_bStopOldest = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// pStructMem->m_bStopOldest = false;
|
||||
// }
|
||||
// }
|
||||
// else if ( !V_strcasecmp( pParamString, "num_allowed" ) )
|
||||
// {
|
||||
// pStructMem->m_nNumAllowed = V_atoi( pValueString );
|
||||
// }
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
43
engine/audio/private/snd_op_sys/sos_op_block_entry.h
Normal file
43
engine/audio/private/snd_op_sys/sos_op_block_entry.h
Normal file
@@ -0,0 +1,43 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_BLOCK_ENTRY_H
|
||||
#define SOS_OP_BLOCK_ENTRY_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// stop other sound entries
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorBlockEntry_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInputActive, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputDuration, SO_SINGLE )
|
||||
|
||||
char m_nMatchEntryName[64];
|
||||
bool m_bMatchEntry;
|
||||
char m_nMatchSoundName[64];
|
||||
bool m_bMatchSound;
|
||||
bool m_bMatchSubString;
|
||||
bool m_bMatchEntity;
|
||||
bool m_bMatchChannel;
|
||||
|
||||
int m_nEntryIndex;
|
||||
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorBlockEntry : public CSosOperator
|
||||
{
|
||||
virtual void StackShutdown( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex );
|
||||
|
||||
SOS_HEADER_DESC( CSosOperatorBlockEntry )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_BLOCK_ENTRY_H
|
||||
186
engine/audio/private/snd_op_sys/sos_op_convar.cpp
Normal file
186
engine/audio/private/snd_op_sys/sos_op_convar.cpp
Normal file
@@ -0,0 +1,186 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_convar.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
ConVar snd_op_test_convar("snd_op_test_convar", "1.0", FCVAR_CHEAT );
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorSetConvar
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorSetConvar, "set_convar" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorSetConvar, m_flInput, SO_SINGLE, "input" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorSetConvar, "set_convar" )
|
||||
|
||||
|
||||
void CSosOperatorSetConvar::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorSetConvar_t *pStructMem = (CSosOperatorSetConvar_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flInput, SO_SINGLE, 0.0 )
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorSetConvar::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorSetConvar_t *pStructMem = (CSosOperatorSetConvar_t *)pVoidMem;
|
||||
|
||||
if ( pStructMem->m_ConVarRef.IsValid() )
|
||||
{
|
||||
pStructMem->m_ConVarRef.SetValue( pStructMem->m_flInput[0] );
|
||||
}
|
||||
else
|
||||
{
|
||||
// The stored ref is not valid, maybe was not initialized at load time, let's try again
|
||||
pStructMem->m_ConVarRef.Init( pStructMem->m_nConvar, true );
|
||||
if ( pStructMem->m_ConVarRef.IsValid() )
|
||||
{
|
||||
pStructMem->m_ConVarRef.SetValue( pStructMem->m_flInput[0] ); // Great success! Will be cached for next time.
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Warning: Unable to set convar value: %s\n", pStructMem->m_nConvar );
|
||||
}
|
||||
}
|
||||
}
|
||||
void CSosOperatorSetConvar::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorSetConvar_t *pStructMem = (CSosOperatorSetConvar_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sconvar: %s\n", nLevel, " ", pStructMem->m_nConvar );
|
||||
}
|
||||
void CSosOperatorSetConvar::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorSetConvar::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorSetConvar_t *pStructMem = (CSosOperatorSetConvar_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "convar" ) )
|
||||
{
|
||||
V_strcpy_safe( pStructMem->m_nConvar, pValueString );
|
||||
pStructMem->m_ConVarRef.Init( pValueString, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorConvar
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorConvar, "get_convar" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorConvar, m_flOutput, SO_SINGLE, "output" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorConvar, "get_convar" )
|
||||
|
||||
|
||||
|
||||
void CSosOperatorConvar::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorConvar_t *pStructMem = (CSosOperatorConvar_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutput, SO_SINGLE, 1.0 )
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorConvar::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorConvar_t *pStructMem = (CSosOperatorConvar_t *)pVoidMem;
|
||||
|
||||
float flValue;
|
||||
if ( pStructMem->m_ConVarRef.IsValid() )
|
||||
{
|
||||
flValue = pStructMem->m_ConVarRef.GetFloat();
|
||||
}
|
||||
else
|
||||
{
|
||||
// The stored ref is not valid, maybe was not initialized at load time, let's try again
|
||||
pStructMem->m_ConVarRef.Init( pStructMem->m_nConvar, true );
|
||||
if ( pStructMem->m_ConVarRef.IsValid() )
|
||||
{
|
||||
flValue = pStructMem->m_ConVarRef.GetFloat(); // Great success! Will be cached for next time.
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Warning: Unable to acquire convar value: %s\n", pStructMem->m_nConvar );
|
||||
flValue = 1.0;
|
||||
}
|
||||
}
|
||||
pStructMem->m_flOutput[0] = flValue;
|
||||
|
||||
}
|
||||
void CSosOperatorConvar::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorConvar_t *pStructMem = (CSosOperatorConvar_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sconvar: %s\n", nLevel, " ", pStructMem->m_nConvar );
|
||||
}
|
||||
void CSosOperatorConvar::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorConvar::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorConvar_t *pStructMem = (CSosOperatorConvar_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "convar" ) )
|
||||
{
|
||||
V_strcpy_safe( pStructMem->m_nConvar, pValueString );
|
||||
pStructMem->m_ConVarRef.Init( pValueString, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
64
engine/audio/private/snd_op_sys/sos_op_convar.h
Normal file
64
engine/audio/private/snd_op_sys/sos_op_convar.h
Normal file
@@ -0,0 +1,64 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_CONVAR_H
|
||||
#define SOS_OP_CONVAR_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "tier1/convar.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// simple operator for getting a convar value
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorConvar_t : CSosOperator_t
|
||||
{
|
||||
CSosOperatorConvar_t()
|
||||
:
|
||||
m_ConVarRef( ( IConVar * )NULL )
|
||||
{
|
||||
// Do nothing...
|
||||
}
|
||||
|
||||
char m_nConvar[64];
|
||||
ConVarRef m_ConVarRef;
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
};
|
||||
|
||||
class CSosOperatorConvar : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorConvar )
|
||||
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// simple operator for setting a convar value
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorSetConvar_t : CSosOperator_t
|
||||
{
|
||||
CSosOperatorSetConvar_t()
|
||||
:
|
||||
m_ConVarRef( ( IConVar * )NULL )
|
||||
{
|
||||
// Do nothing...
|
||||
}
|
||||
|
||||
char m_nConvar[64];
|
||||
ConVarRef m_ConVarRef;
|
||||
SOS_INPUT_FLOAT( m_flInput, SO_SINGLE )
|
||||
};
|
||||
|
||||
class CSosOperatorSetConvar : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorSetConvar )
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // SOS_OP_CONVAR_H
|
||||
97
engine/audio/private/snd_op_sys/sos_op_dashboard.cpp
Normal file
97
engine/audio/private/snd_op_sys/sos_op_dashboard.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_dashboard.h"
|
||||
|
||||
#include "snd_dma.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorDashboard
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorDashboard, "get_dashboard" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorDashboard, m_flOutput, SO_SINGLE, "output" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorDashboard, "get_dashboard" )
|
||||
|
||||
void CSosOperatorDashboard::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorDashboard_t *pStructMem = (CSosOperatorDashboard_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutput, SO_SINGLE, 1.0 )
|
||||
pStructMem->m_bMusic = true;
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorDashboard::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorDashboard_t *pStructMem = (CSosOperatorDashboard_t *)pVoidMem;
|
||||
|
||||
float flValue = 1.0;
|
||||
if ( pStructMem->m_bMusic )
|
||||
{
|
||||
flValue = S_GetDashboarMusicMixValue();
|
||||
}
|
||||
pStructMem->m_flOutput[0] = flValue;
|
||||
|
||||
}
|
||||
void CSosOperatorDashboard::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorDashboard_t *pStructMem = (CSosOperatorDashboard_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
/// Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sDashboard: %s\n", nLevel, " ", pStructMem->m_nConvar );
|
||||
}
|
||||
void CSosOperatorDashboard::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorDashboard::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorDashboard_t *pStructMem = (CSosOperatorDashboard_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "ds_type" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "music" ) )
|
||||
{
|
||||
pStructMem->m_bMusic = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bMusic = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
31
engine/audio/private/snd_op_sys/sos_op_dashboard.h
Normal file
31
engine/audio/private/snd_op_sys/sos_op_dashboard.h
Normal file
@@ -0,0 +1,31 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_DASHBOARD_H
|
||||
#define SOS_OP_DASHBOARD_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// simple operator for getting the dashboard value
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorDashboard_t : CSosOperator_t
|
||||
{
|
||||
bool m_bMusic;
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
};
|
||||
|
||||
class CSosOperatorDashboard : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorDashboard )
|
||||
|
||||
};
|
||||
|
||||
#endif // SOS_OP_DASHBOARD
|
||||
90
engine/audio/private/snd_op_sys/sos_op_delta.cpp
Normal file
90
engine/audio/private/snd_op_sys/sos_op_delta.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_delta.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorDelta
|
||||
// Setting a single, simple scratch pad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorDelta, "math_delta" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorDelta, m_flInput, SO_SINGLE, "input" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorDelta, m_flOutput, SO_SINGLE, "output" );
|
||||
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorDelta, "math_delta" )
|
||||
|
||||
void CSosOperatorDelta::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorDelta_t *pStructMem = (CSosOperatorDelta_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flInput, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutput, SO_SINGLE, 0.0 )
|
||||
pStructMem->m_flLastInput = 0.0;
|
||||
pStructMem->m_flLastTime = g_pSoundServices->GetHostTime();
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorDelta::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorDelta_t *pStructMem = (CSosOperatorDelta_t *)pVoidMem;
|
||||
|
||||
// need to normalize for frame time
|
||||
pStructMem->m_flOutput[0] = pStructMem->m_flInput[0] - pStructMem->m_flLastInput;
|
||||
|
||||
pStructMem->m_flLastInput = pStructMem->m_flInput[0];
|
||||
|
||||
}
|
||||
void CSosOperatorDelta::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorDelta_t *pStructMem = (CSosOperatorDelta_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
|
||||
}
|
||||
void CSosOperatorDelta::OpHelp( ) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorDelta::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorDelta_t *pStructMem = (CSosOperatorDelta_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
36
engine/audio/private/snd_op_sys/sos_op_delta.h
Normal file
36
engine/audio/private/snd_op_sys/sos_op_delta.h
Normal file
@@ -0,0 +1,36 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_DELTA_H
|
||||
#define SOS_OP_DELTA_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// get elapsed time
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorDelta_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInput, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
|
||||
float m_flLastInput;
|
||||
float m_flLastTime;
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorDelta : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorDelta )
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // SOS_OP_DELTA_VALUE_H
|
||||
95
engine/audio/private/snd_op_sys/sos_op_distant_dsp.cpp
Normal file
95
engine/audio/private/snd_op_sys/sos_op_distant_dsp.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_distant_dsp.h"
|
||||
|
||||
#include "snd_dma.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorDistantDSP
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorDistantDSP, "calc_distant_dsp" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorDistantDSP, m_flOutput, SO_SINGLE, "output" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorDistantDSP, m_flInputDist, SO_SINGLE, "input_distance" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorDistantDSP, m_flInputLevel, SO_SINGLE, "input_level" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorDistantDSP, "calc_distant_dsp" )
|
||||
|
||||
|
||||
void CSosOperatorDistantDSP::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorDistantDSP_t *pStructMem = (CSosOperatorDistantDSP_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutput, SO_SINGLE, 1.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputDist, SO_SINGLE, 1.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputLevel, SO_SINGLE, 65.0 )
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CSosOperatorDistantDSP::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorDistantDSP_t *pStructMem = (CSosOperatorDistantDSP_t *)pVoidMem;
|
||||
|
||||
if( !pChannel )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Sound operator %s requires valid channel pointer, being called without one\n", pStack->GetOperatorName( nOpIndex ));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pStructMem->m_flOutput[0] = SND_GetDspMix( pChannel, pStructMem->m_flInputDist[0], pStructMem->m_flInputLevel[0] );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CSosOperatorDistantDSP::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
//CSosOperatorDistantDSP_t *pStructMem = (CSosOperatorDistantDSP_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
|
||||
}
|
||||
void CSosOperatorDistantDSP::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorDistantDSP::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorDistantDSP_t *pStructMem = (CSosOperatorDistantDSP_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
30
engine/audio/private/snd_op_sys/sos_op_distant_dsp.h
Normal file
30
engine/audio/private/snd_op_sys/sos_op_distant_dsp.h
Normal file
@@ -0,0 +1,30 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_DISTANT_DSP_H
|
||||
#define SOS_OP_DISTANT_DSP_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// basic dsp by distance operator
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorDistantDSP_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInputDist, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputLevel, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
};
|
||||
|
||||
class CSosOperatorDistantDSP : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorDistantDSP )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_DISTANT_DSP_H
|
||||
192
engine/audio/private/snd_op_sys/sos_op_entity_info.cpp
Normal file
192
engine/audio/private/snd_op_sys/sos_op_entity_info.cpp
Normal file
@@ -0,0 +1,192 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
#include "client.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_entity_info.h"
|
||||
#include "icliententitylist.h"
|
||||
#include "icliententity.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
// ConVar snd_sos_show_source_info("snd_sos_show_source_info", "0" );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorEntityInfo
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorEntityInfo, "game_entity_info" )
|
||||
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntityInfo, m_flOutPosition, SO_VEC3, "output_position" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntityInfo, m_flOutPosition_x, SO_SINGLE, "output_position_x" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntityInfo, m_flOutPosition_y, SO_SINGLE, "output_position_y" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntityInfo, m_flOutPosition_z, SO_SINGLE, "output_position_z" );
|
||||
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntityInfo, m_flOutAngles, SO_VEC3, "output_angles" );
|
||||
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntityInfo, m_flOutVelocityVector, SO_VEC3, "output_velocity_vector" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntityInfo, m_flOutVelocityVector_x, SO_SINGLE, "output_velocity_vector_x" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntityInfo, m_flOutVelocityVector_y, SO_SINGLE, "output_velocity_vector_y" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntityInfo, m_flOutVelocityVector_z, SO_SINGLE, "output_velocity_vector_z" );
|
||||
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntityInfo, m_flOutVelocity, SO_SINGLE, "output_velocity" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntityInfo, m_flOutVelocityXY, SO_SINGLE, "output_velocity_xy" );
|
||||
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorEntityInfo, m_flInputEntityIndex, SO_SINGLE, "input_entity_index" );
|
||||
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorEntityInfo, "game_entity_info" )
|
||||
|
||||
|
||||
void CSosOperatorEntityInfo::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorEntityInfo_t *pStructMem = (CSosOperatorEntityInfo_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutPosition, SO_VEC3, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutPosition_x, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutPosition_y, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutPosition_z, SO_SINGLE, 0.0 )
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutAngles, SO_VEC3, 0.0 )
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutVelocity, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutVelocityVector, SO_VEC3, 0.0 )
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutVelocityVector_x, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutVelocityVector_y, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutVelocityVector_z, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutVelocityXY, SO_SINGLE, 0.0 )
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flInputEntityIndex, SO_SINGLE, 0.0 )
|
||||
|
||||
pStructMem->m_vecPrevPosition.Init();
|
||||
pStructMem->m_flPrevTime = g_pSoundServices->GetHostTime();
|
||||
}
|
||||
|
||||
void CSosOperatorEntityInfo::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
#ifndef DEDICATED
|
||||
CSosOperatorEntityInfo_t *pStructMem = (CSosOperatorEntityInfo_t *)pVoidMem;
|
||||
|
||||
// for future use with splitscreen
|
||||
int nCurIndex = (int) pStructMem->m_flInputEntityIndex[0];
|
||||
if( nCurIndex < 0 )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: %s, input_entity_index %i invalid\n", pStack->GetOperatorName( nOpIndex ), nCurIndex );
|
||||
return;
|
||||
}
|
||||
|
||||
Vector vEntityAbsPos;
|
||||
vEntityAbsPos.Init( 0.0, 0.0, 0.0 );
|
||||
IClientEntity *pClientEntity = entitylist->GetClientEntity(nCurIndex );
|
||||
if ( pClientEntity )
|
||||
{
|
||||
vEntityAbsPos = pClientEntity->GetAbsOrigin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// first frame init position to avoid, erroneous deltas, zero is best option
|
||||
if( pStructMem->m_flPrevTime == 0.0 )
|
||||
{
|
||||
VectorCopy( ( pScratchPad->m_vPlayerOrigin[ nCurIndex ]), pStructMem->m_vecPrevPosition );
|
||||
}
|
||||
|
||||
// calculate delta time for this operator updates
|
||||
float flCurTime = g_ClientGlobalVariables.curtime;
|
||||
float flDeltaTime = flCurTime - pStructMem->m_flPrevTime;
|
||||
pStructMem->m_flPrevTime = flCurTime;
|
||||
|
||||
if( flDeltaTime > 0.0 )
|
||||
{
|
||||
|
||||
// per/sec factor
|
||||
float flPerSec = 1.0 / flDeltaTime;
|
||||
|
||||
pStructMem->m_flOutPosition[0] = vEntityAbsPos[0];
|
||||
pStructMem->m_flOutPosition[1] = vEntityAbsPos[1];
|
||||
pStructMem->m_flOutPosition[2] = vEntityAbsPos[2];
|
||||
|
||||
// this is temporary for accessing single elements in array, will be a [] "feature" later when there's time
|
||||
pStructMem->m_flOutPosition_x[0] = pStructMem->m_flOutPosition[0];
|
||||
pStructMem->m_flOutPosition_y[0] = pStructMem->m_flOutPosition[1];
|
||||
pStructMem->m_flOutPosition_z[0] = pStructMem->m_flOutPosition[2];
|
||||
|
||||
// get raw velocity vector
|
||||
Vector vPositionDelta;
|
||||
vPositionDelta[0] = pStructMem->m_flOutPosition[0] - pStructMem->m_vecPrevPosition[0];
|
||||
vPositionDelta[1] = pStructMem->m_flOutPosition[1] - pStructMem->m_vecPrevPosition[1];
|
||||
vPositionDelta[2] = pStructMem->m_flOutPosition[2] - pStructMem->m_vecPrevPosition[2];
|
||||
|
||||
// scale vector to per/sec
|
||||
Vector vVelocity = vPositionDelta * flPerSec;
|
||||
pStructMem->m_flOutVelocityVector[0] = vVelocity[0];
|
||||
pStructMem->m_flOutVelocityVector[1] = vVelocity[1];
|
||||
pStructMem->m_flOutVelocityVector[2] = vVelocity[2];
|
||||
|
||||
// this is temporary for accessing single elements in array, will be a "feature" later when there's time
|
||||
pStructMem->m_flOutVelocityVector_x[0] = pStructMem->m_flOutVelocityVector[0];
|
||||
pStructMem->m_flOutVelocityVector_y[0] = pStructMem->m_flOutVelocityVector[1];
|
||||
pStructMem->m_flOutVelocityVector_z[0] = pStructMem->m_flOutVelocityVector[2];
|
||||
|
||||
pStructMem->m_flOutVelocity[0] = vVelocity.Length();
|
||||
|
||||
pStructMem->m_flOutVelocityXY[0] = vVelocity.Length2D();
|
||||
|
||||
VectorCopy( vEntityAbsPos, pStructMem->m_vecPrevPosition );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CSosOperatorEntityInfo::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorEntityInfo_t *pStructMem = (CSosOperatorEntityInfo_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
}
|
||||
|
||||
void CSosOperatorEntityInfo::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorEntityInfo::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorEntityInfo_t *pStructMem = (CSosOperatorEntityInfo_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
48
engine/audio/private/snd_op_sys/sos_op_entity_info.h
Normal file
48
engine/audio/private/snd_op_sys/sos_op_entity_info.h
Normal file
@@ -0,0 +1,48 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_ENTITY_INFO_H
|
||||
#define SOS_OP_ENTITY_INFO_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// simple operator for setting a single position
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorEntityInfo_t : CSosOperator_t
|
||||
{
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutPosition, SO_VEC3 )
|
||||
SOS_OUTPUT_FLOAT( m_flOutPosition_x, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutPosition_y, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutPosition_z, SO_SINGLE )
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutAngles, SO_VEC3 )
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutVelocity, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutVelocityVector, SO_VEC3 )
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutVelocityVector_x, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutVelocityVector_y, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutVelocityVector_z, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutVelocityXY, SO_SINGLE )
|
||||
|
||||
SOS_INPUT_FLOAT( m_flInputEntityIndex, SO_SINGLE )
|
||||
|
||||
float m_flPrevTime;
|
||||
Vector m_vecPrevPosition;
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorEntityInfo : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorEntityInfo )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_ENTITY_INFO_H
|
||||
134
engine/audio/private/snd_op_sys/sos_op_entry_time.cpp
Normal file
134
engine/audio/private/snd_op_sys/sos_op_entry_time.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "snd_dma.h"
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_entry_time.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorEntryTime
|
||||
// Setting a single, simple scratch pad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorEntryTime, "get_entry_time" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntryTime, m_flOutputEntryElapsed, SO_SINGLE, "output_entry_elapsed" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntryTime, m_flOutputSoundElapsed, SO_SINGLE, "output_sound_elapsed" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntryTime, m_flOutputStopElapsed, SO_SINGLE, "output_stop_elapsed" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorEntryTime, m_flOutputSoundDuration, SO_SINGLE, "output_sound_duration" );
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorEntryTime, "get_entry_time" )
|
||||
|
||||
void CSosOperatorEntryTime::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorEntryTime_t *pStructMem = (CSosOperatorEntryTime_t *)pVoidMem;
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputSoundDuration, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputSoundElapsed, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputStopElapsed, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputEntryElapsed, SO_SINGLE, 0.0 )
|
||||
|
||||
pStructMem->m_nScriptHash = SOUNDEMITTER_INVALID_HASH;
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorEntryTime::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorEntryTime_t *pStructMem = (CSosOperatorEntryTime_t *)pVoidMem;
|
||||
|
||||
channel_t *pTimeChannel = NULL;
|
||||
|
||||
if( pStructMem->m_nScriptHash != SOUNDEMITTER_INVALID_HASH )
|
||||
{
|
||||
pTimeChannel = S_FindChannelByScriptHash( pStructMem->m_nScriptHash );
|
||||
}
|
||||
else
|
||||
{
|
||||
pTimeChannel = S_FindChannelByGuid( pStack->GetChannelGuid() );
|
||||
}
|
||||
|
||||
if( !pTimeChannel )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Sound operator %s requires valid channel pointer, being called without one\n", pStack->GetOperatorName( nOpIndex ));
|
||||
return;
|
||||
}
|
||||
|
||||
if( pTimeChannel->m_pStackList )
|
||||
{
|
||||
CSosOperatorStack *pTheStack = NULL;
|
||||
pTheStack = pTimeChannel->m_pStackList->GetStack( CSosOperatorStack::SOS_UPDATE );
|
||||
|
||||
if( pTheStack )
|
||||
{
|
||||
pStructMem->m_flOutputEntryElapsed[0] = pTheStack->GetElapsedTime();
|
||||
}
|
||||
}
|
||||
pStructMem->m_flOutputSoundElapsed[0] = S_GetElapsedTime( pTimeChannel ) * 0.01;
|
||||
pStructMem->m_flOutputSoundDuration[0] = S_SoundDuration( pTimeChannel );
|
||||
pStructMem->m_flOutputStopElapsed[0] = pStack->GetElapsedStopTime( );
|
||||
|
||||
}
|
||||
void CSosOperatorEntryTime::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorEntryTime_t *pStructMem = (CSosOperatorEntryTime_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
|
||||
}
|
||||
void CSosOperatorEntryTime::OpHelp( ) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorEntryTime::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorEntryTime_t *pStructMem = (CSosOperatorEntryTime_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "entry" ) )
|
||||
{
|
||||
if ( !g_pSoundEmitterSystem )
|
||||
{
|
||||
DevWarning("Error: SoundEmitterSystem not initialized in engine!");
|
||||
return;
|
||||
}
|
||||
pStructMem->m_nScriptHash = g_pSoundEmitterSystem->HashSoundName( pValueString );
|
||||
|
||||
if( !g_pSoundEmitterSystem->GetSoundNameForHash( pStructMem->m_nScriptHash ))
|
||||
{
|
||||
DevMsg( "Error: Invalid SoundEntry hash %i from entry %s", pStructMem->m_nScriptHash, pValueString );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
37
engine/audio/private/snd_op_sys/sos_op_entry_time.h
Normal file
37
engine/audio/private/snd_op_sys/sos_op_entry_time.h
Normal file
@@ -0,0 +1,37 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_ENTRY_TIME_H
|
||||
#define SOS_OP_ENTRY_TIME_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// get elapsed time
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorEntryTime_t : CSosOperator_t
|
||||
{
|
||||
SOS_OUTPUT_FLOAT( m_flOutputSoundDuration, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputSoundElapsed, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputEntryElapsed, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputStopElapsed, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputHostElapsed, SO_SINGLE )
|
||||
|
||||
HSOUNDSCRIPTHASH m_nScriptHash;
|
||||
};
|
||||
|
||||
class CSosOperatorEntryTime : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorEntryTime )
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // SOS_OP_ENTRY_TIME_H
|
||||
195
engine/audio/private/snd_op_sys/sos_op_falloff.cpp
Normal file
195
engine/audio/private/snd_op_sys/sos_op_falloff.cpp
Normal file
@@ -0,0 +1,195 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_falloff.h"
|
||||
|
||||
#include "snd_dma.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorFalloff
|
||||
// Setting a single, simple scratch pad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorFalloff, "calc_falloff" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorFalloff, m_flOutput, SO_SINGLE, "output" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorFalloff, m_flInputDist, SO_SINGLE, "input_distance" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorFalloff, m_flInputLevel, SO_SINGLE, "input_level" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorFalloff, "calc_falloff" )
|
||||
|
||||
void CSosOperatorFalloff::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorFalloff_t *pStructMem = (CSosOperatorFalloff_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutput, SO_SINGLE, 1.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputDist, SO_SINGLE, 1.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputLevel, SO_SINGLE, 1.0 )
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorFalloff::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorFalloff_t *pStructMem = (CSosOperatorFalloff_t *)pVoidMem;
|
||||
|
||||
float flDistMult = SNDLVL_TO_DIST_MULT( pStructMem->m_flInputLevel[0] );
|
||||
|
||||
// the first arg used to be because there was a form of compression on the falloff
|
||||
// based on overall volume level, we are not having volume effect our falloff
|
||||
pStructMem->m_flOutput[0] = SND_GetGainFromMult( 1.0, flDistMult, pStructMem->m_flInputDist[0] );
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorFalloff::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorFalloff_t *pStructMem = (CSosOperatorFalloff_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
}
|
||||
void CSosOperatorFalloff::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorFalloff::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorFalloff_t *pStructMem = (CSosOperatorFalloff_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorFalloffTail
|
||||
// Setting a single, simple scratch pad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorFalloffTail, "calc_falloff_curve" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorFalloffTail, m_flOutput, SO_SINGLE, "output" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorFalloffTail, m_flInputDist, SO_SINGLE, "input_distance" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorFalloffTail, m_flInputExp, SO_SINGLE, "input_curve_amount" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorFalloffTail, m_flInputDistantMin, SO_SINGLE, "input_min" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorFalloffTail, m_flInputDistantMax, SO_SINGLE, "input_max" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorFalloffTail, m_flInputAtten, SO_SINGLE, "input_atten" )
|
||||
// SOS_REGISTER_INPUT_FLOAT( CSosOperatorFalloffTail, m_flInputTailMin, SO_SINGLE, "input_tail_min" )
|
||||
// SOS_REGISTER_INPUT_FLOAT( CSosOperatorFalloffTail, m_flInputTailMax, SO_SINGLE, "input_tail_max" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorFalloffTail, "calc_falloff_curve" )
|
||||
|
||||
void CSosOperatorFalloffTail::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorFalloffTail_t *pStructMem = (CSosOperatorFalloffTail_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutput, SO_SINGLE, 1.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputDist, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputExp, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputDistantMin, SO_SINGLE, 36.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputDistantMax, SO_SINGLE, 360.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputAtten, SO_SINGLE, 360.0 )
|
||||
|
||||
// SOS_INIT_INPUT_VAR( m_flInputTailMin, SO_SINGLE, 240.0 )
|
||||
// SOS_INIT_INPUT_VAR( m_flInputTailMax, SO_SINGLE, 540.0 )
|
||||
}
|
||||
#define SOP_FALLOFF_MIN_EXP 0.1f
|
||||
void CSosOperatorFalloffTail::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
|
||||
CSosOperatorFalloffTail_t *pStructMem = (CSosOperatorFalloffTail_t *)pVoidMem;
|
||||
|
||||
float flDistance = pStructMem->m_flInputDist[0];
|
||||
float flDistantMin = pStructMem->m_flInputDistantMin[0];
|
||||
float flDistantMax = pStructMem->m_flInputDistantMax[0];
|
||||
// float flTailMin = pStructMem->m_flInputTailMin[0];
|
||||
// float flTailMax = pStructMem->m_flInputTailMax[0];
|
||||
|
||||
flDistantMax = flDistantMax > flDistantMin ? flDistantMax : flDistantMin;
|
||||
// flTailMin < flDistantMax ? flTailMin : flDistantMax;
|
||||
// flTailMax > flDistantMax ? flTailMax : flDistantMax;
|
||||
|
||||
float flResult;
|
||||
if ( flDistance <= flDistantMin )
|
||||
{
|
||||
flResult = pStructMem->m_flInputAtten[0];
|
||||
}
|
||||
// else if ( flDistance >= flTailMax ||
|
||||
// ( flDistance > flDistantMax && flTailMin == flDistantMax ) )
|
||||
else if ( flDistance > flDistantMax )
|
||||
{
|
||||
|
||||
flResult = 0.0;
|
||||
}
|
||||
// else if ( flDistance > flTailMin && flDistance < flTailMax )
|
||||
// {
|
||||
// flResult = 1.0 - ( ( flDistance - flTailMin ) / ( flTailMax - flTailMin ) );
|
||||
// flResult *= FastPow( 1.0 - ( flTailMin - flDistantMin ) / ( flDistantMax - flDistantMin ), pStructMem->m_flInputDistantExp[0] );
|
||||
// }
|
||||
// else if ( flDistance > flDistantMin && flDistance <= flTailMin )
|
||||
else // flDistance is between flDistantMin and flDistantMax
|
||||
{
|
||||
flResult = ( flDistance - flDistantMin ) / ( flDistantMax - flDistantMin );
|
||||
|
||||
flResult = (1.0 - FastPow( flResult, ( 1.0 + SOP_FALLOFF_MIN_EXP) - pStructMem->m_flInputExp[0] )) * pStructMem->m_flInputAtten[0];
|
||||
}
|
||||
pStructMem->m_flOutput[0] = flResult;
|
||||
}
|
||||
|
||||
void CSosOperatorFalloffTail::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorFalloffTail_t *pStructMem = (CSosOperatorFalloffTail_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
}
|
||||
void CSosOperatorFalloffTail::OpHelp() const
|
||||
{
|
||||
}
|
||||
void CSosOperatorFalloffTail::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorFalloffTail_t *pStructMem = (CSosOperatorFalloffTail_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
53
engine/audio/private/snd_op_sys/sos_op_falloff.h
Normal file
53
engine/audio/private/snd_op_sys/sos_op_falloff.h
Normal file
@@ -0,0 +1,53 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_FALLOFF_H
|
||||
#define SOS_OP_FALLOFF_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// falloff
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorFalloff_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInputDist, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputLevel, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
};
|
||||
class CSosOperatorFalloff : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorFalloff )
|
||||
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// falloff
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorFalloffTail_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInputDist, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputAtten, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputDistantMin, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputDistantMax, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputExp, SO_SINGLE )
|
||||
|
||||
// SOS_INPUT_FLOAT( m_flInputTailMin, SO_SINGLE )
|
||||
// SOS_INPUT_FLOAT( m_flInputTailMax, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
};
|
||||
class CSosOperatorFalloffTail : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorFalloffTail )
|
||||
|
||||
};
|
||||
|
||||
#endif // SOS_OP_FALLOFF
|
||||
134
engine/audio/private/snd_op_sys/sos_op_filters.cpp
Normal file
134
engine/audio/private/snd_op_sys/sos_op_filters.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
#include "client.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_filters.h"
|
||||
#include "icliententitylist.h"
|
||||
#include "icliententity.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
// ConVar snd_sos_show_source_info("snd_sos_show_source_info", "0" );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorFloatFilter
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorFloatFilter, "math_float_filter" )
|
||||
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorFloatFilter, m_flOutput, SO_SINGLE, "output" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorFloatFilter, m_flInput, SO_SINGLE, "input" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorFloatFilter, m_flInputMaxVel, SO_SINGLE, "input_max_velocity" );
|
||||
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorFloatFilter, "math_float_filter" )
|
||||
|
||||
|
||||
void CSosOperatorFloatFilter::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorFloatFilter_t *pStructMem = (CSosOperatorFloatFilter_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutput, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInput, SO_SINGLE, 0.0 )
|
||||
|
||||
//pStructMem->m_flPrevTime = g_pSoundServices->GetHostTime();
|
||||
pStructMem->m_flPrevTime = -1.0;
|
||||
}
|
||||
|
||||
void CSosOperatorFloatFilter::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
#ifndef DEDICATED
|
||||
CSosOperatorFloatFilter_t *pStructMem = (CSosOperatorFloatFilter_t *)pVoidMem;
|
||||
|
||||
|
||||
// first frame init position to avoid, erroneous deltas, zero is best option
|
||||
if( pStructMem->m_flPrevTime < 0.0 )
|
||||
{
|
||||
pStructMem->m_flOutput[0] = pStructMem->m_flInput[0];
|
||||
pStructMem->m_flPrevTime = g_ClientGlobalVariables.curtime;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// calculate delta time for this operator updates
|
||||
float flCurTime = g_ClientGlobalVariables.curtime;
|
||||
float flDeltaTime = flCurTime - pStructMem->m_flPrevTime;
|
||||
pStructMem->m_flPrevTime = flCurTime;
|
||||
|
||||
float flDeltaValue = pStructMem->m_flInput[0] - pStructMem->m_flOutput[0];
|
||||
|
||||
if( flDeltaTime > 0.0 && flDeltaValue != 0.0 )
|
||||
{
|
||||
float flMaxVel = pStructMem->m_flInputMaxVel[0];
|
||||
|
||||
// per/sec factor
|
||||
float flPerSec = 1.0 / flDeltaTime;
|
||||
float flValueVel = flPerSec * flDeltaValue;
|
||||
if( fabs(flValueVel) > flMaxVel )
|
||||
{
|
||||
float flVector = ( flDeltaTime * (flMaxVel * ( flDeltaValue < 0.0 ? -1.0 : 1.0 )));
|
||||
pStructMem->m_flOutput[0] += flVector;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_flOutput[0] = pStructMem->m_flInput[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CSosOperatorFloatFilter::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorFloatFilter_t *pStructMem = (CSosOperatorFloatFilter_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
}
|
||||
|
||||
void CSosOperatorFloatFilter::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorFloatFilter::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorFloatFilter_t *pStructMem = (CSosOperatorFloatFilter_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
35
engine/audio/private/snd_op_sys/sos_op_filters.h
Normal file
35
engine/audio/private/snd_op_sys/sos_op_filters.h
Normal file
@@ -0,0 +1,35 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_FILTERS_H
|
||||
#define SOS_OP_FILTERS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// simple operator for setting a single position
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorFloatFilter_t : CSosOperator_t
|
||||
{
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInput, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputMaxVel, SO_SINGLE )
|
||||
|
||||
float m_flPrevTime;
|
||||
float m_flPrevValue;
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorFloatFilter : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorFloatFilter )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_FILTERS_H
|
||||
@@ -0,0 +1,149 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_iterate_merge_speakers.h"
|
||||
|
||||
// #include "../../debugoverlay.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorIterateAndMergeSpeakers_t
|
||||
// Setting a single, simple scratch pad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorIterateAndMergeSpeakers, "iterate_merge_speakers" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorIterateAndMergeSpeakers, m_flInputMaxIterations, SO_SINGLE, "input_max_iterations" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorIterateAndMergeSpeakers, m_flOutputIndex, SO_SINGLE, "output_index" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorIterateAndMergeSpeakers, m_flOutputSpeakers, SO_SPEAKERS, "output" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorIterateAndMergeSpeakers, m_flInputSpeakers, SO_SPEAKERS, "input")
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorIterateAndMergeSpeakers, "iterate_merge_speakers" )
|
||||
|
||||
void CSosOperatorIterateAndMergeSpeakers::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorIterateAndMergeSpeakers_t *pStructMem = ( CSosOperatorIterateAndMergeSpeakers_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flInputMaxIterations, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputSpeakers, SO_SPEAKERS, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputSpeakers, SO_SPEAKERS, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputIndex, SO_SINGLE, 0.0 )
|
||||
|
||||
pStructMem->m_nMaxIterations = 8;
|
||||
pStructMem->m_nOperatorIndex = -1;
|
||||
}
|
||||
|
||||
void CSosOperatorIterateAndMergeSpeakers::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
|
||||
CSosOperatorIterateAndMergeSpeakers_t *pStructMem = ( CSosOperatorIterateAndMergeSpeakers_t *)pVoidMem;
|
||||
|
||||
if( !pChannel )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Sound operator %s requires valid channel pointer, being called without one\n", pStack->GetOperatorName( nOpIndex ));
|
||||
return;
|
||||
}
|
||||
|
||||
int nCurIndex = ( int )pStructMem->m_flOutputIndex[0];
|
||||
int nLastIndex = MIN( ( int ) pStructMem->m_flInputMaxIterations[0], pStructMem->m_nMaxIterations );
|
||||
|
||||
if( nCurIndex == 0 )
|
||||
{
|
||||
for ( int i = 0; i < SO_MAX_SPEAKERS; i++ )
|
||||
{
|
||||
pStructMem->m_flOutputSpeakers[i] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
// merge speaker volumes
|
||||
for ( int v = 0; v < SO_MAX_SPEAKERS; ++v )
|
||||
{
|
||||
// switch ( g_SndMergeMethod )
|
||||
// switch ( SND_MERGE_MAX )
|
||||
// {
|
||||
// default:
|
||||
// case SND_MERGE_SUMANDCLIP:
|
||||
// {
|
||||
// pStructMem->m_flOutputSpeakers[v] = min( pStructMem->m_flInputSpeakers[v]+pStructMem->m_flOutputSpeakers[v], 1.0 );
|
||||
// }
|
||||
// break;
|
||||
// case SND_MERGE_MAX:
|
||||
// {
|
||||
pStructMem->m_flOutputSpeakers[v] = MAX( pStructMem->m_flInputSpeakers[v], pStructMem->m_flOutputSpeakers[v] );
|
||||
// }
|
||||
// break;
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
// are we done?
|
||||
if ( nCurIndex < nLastIndex )
|
||||
{
|
||||
nCurIndex++;
|
||||
pStructMem->m_flOutputIndex[0] = ( float )nCurIndex;
|
||||
pStack->ExecuteIterator( pChannel, pScratchPad, pVoidMem, pStructMem->m_nStartOperatorName, &pStructMem->m_nOperatorIndex );
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// clear index for next time around
|
||||
pStructMem->m_flOutputIndex[0] = 0.0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CSosOperatorIterateAndMergeSpeakers::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorIterateAndMergeSpeakers_t *pStructMem = ( CSosOperatorIterateAndMergeSpeakers_t * )pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sIterate Op: %s\n", nLevel, " ", pStructMem->m_nStartOperatorName );
|
||||
}
|
||||
void CSosOperatorIterateAndMergeSpeakers::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorIterateAndMergeSpeakers::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorIterateAndMergeSpeakers_t *pStructMem = (CSosOperatorIterateAndMergeSpeakers_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "iterate_operator" ) )
|
||||
{
|
||||
Q_strncpy( pStructMem->m_nStartOperatorName, pValueString, sizeof(pStructMem->m_nStartOperatorName) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_ITERATE_MERGE_H
|
||||
#define SOS_OP_ITERATE_MERGE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// calculate and merge multiple pass speaker volumes
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorIterateAndMergeSpeakers_t : CSosOperator_t
|
||||
{
|
||||
char m_nStartOperatorName[64];
|
||||
int m_nMaxIterations;
|
||||
int m_nOperatorIndex;
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutputIndex, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputMaxIterations, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputSpeakers, SO_SPEAKERS )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputSpeakers, SO_SPEAKERS )
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorIterateAndMergeSpeakers : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorIterateAndMergeSpeakers )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_ITERATE_MERGE_H
|
||||
89
engine/audio/private/snd_op_sys/sos_op_map_name.cpp
Normal file
89
engine/audio/private/snd_op_sys/sos_op_map_name.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_map_name.h"
|
||||
|
||||
#include "snd_dma.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorMapName
|
||||
// Setting a single, simple scratch pad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorMapName, "get_map_name" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorMapName, m_flOutput, SO_SINGLE, "output" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorMapName, "get_map_name" )
|
||||
|
||||
void CSosOperatorMapName::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorMapName_t *pStructMem = (CSosOperatorMapName_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutput, SO_SINGLE, 0.0 )
|
||||
}
|
||||
|
||||
void CSosOperatorMapName::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
// CSosOperatorMapName_t *pStructMem = (CSosOperatorMapName_t *)pVoidMem;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorMapName::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorMapName_t *pStructMem = (CSosOperatorMapName_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
}
|
||||
void CSosOperatorMapName::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorMapName::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
extern IVEngineClient *engineClient;
|
||||
CSosOperatorMapName_t *pStructMem = (CSosOperatorMapName_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ))
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "map_name" ) )
|
||||
{
|
||||
pStructMem->m_flOutput[0] = 0.0;
|
||||
if( ! V_strcmp( engineClient->GetLevelNameShort(), pValueString ) )
|
||||
{
|
||||
pStructMem->m_flOutput[0] = 1.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
31
engine/audio/private/snd_op_sys/sos_op_map_name.h
Normal file
31
engine/audio/private/snd_op_sys/sos_op_map_name.h
Normal file
@@ -0,0 +1,31 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_MAPNAME_H
|
||||
#define SOS_OP_MAPNAME_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// mapname
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorMapName_t : CSosOperator_t
|
||||
{
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
|
||||
};
|
||||
class CSosOperatorMapName : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorMapName )
|
||||
|
||||
};
|
||||
|
||||
#endif // SOS_OP_MAPNAME
|
||||
1917
engine/audio/private/snd_op_sys/sos_op_math.cpp
Normal file
1917
engine/audio/private/snd_op_sys/sos_op_math.cpp
Normal file
File diff suppressed because it is too large
Load Diff
296
engine/audio/private/snd_op_sys/sos_op_math.h
Normal file
296
engine/audio/private/snd_op_sys/sos_op_math.h
Normal file
@@ -0,0 +1,296 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_MATH_H
|
||||
#define SOS_OP_MATH_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
enum SOOpCurveType_t
|
||||
{
|
||||
SO_OP_CURVETYPE_NONE = 0,
|
||||
SO_OP_CURVETYPE_STEP,
|
||||
SO_OP_CURVETYPE_LINEAR,
|
||||
};
|
||||
|
||||
enum SOOpType_t
|
||||
{
|
||||
SO_OP_NONE = 0,
|
||||
SO_OP_SET,
|
||||
SO_OP_ADD,
|
||||
SO_OP_SUB,
|
||||
SO_OP_MULT,
|
||||
SO_OP_DIV,
|
||||
SO_OP_MOD,
|
||||
SO_OP_MAX,
|
||||
SO_OP_MIN,
|
||||
SO_OP_INV,
|
||||
SO_OP_GT,
|
||||
SO_OP_LT,
|
||||
SO_OP_GTOE,
|
||||
SO_OP_LTOE,
|
||||
SO_OP_EQ,
|
||||
SO_OP_NOT_EQ,
|
||||
SO_OP_INV_SCALE,
|
||||
SO_OP_POW
|
||||
|
||||
|
||||
};
|
||||
|
||||
enum SOFunc1Type_t
|
||||
{
|
||||
SO_FUNC1_NONE = 0,
|
||||
SO_FUNC1_SIN,
|
||||
SO_FUNC1_ASIN,
|
||||
SO_FUNC1_COS,
|
||||
SO_FUNC1_ACOS,
|
||||
SO_FUNC1_TAN,
|
||||
SO_FUNC1_ATAN,
|
||||
SO_FUNC1_SINH,
|
||||
SO_FUNC1_ASINH,
|
||||
SO_FUNC1_COSH,
|
||||
SO_FUNC1_ACOSH,
|
||||
SO_FUNC1_TANH,
|
||||
SO_FUNC1_ATANH,
|
||||
SO_FUNC1_EXP,
|
||||
SO_FUNC1_EXPM1,
|
||||
SO_FUNC1_EXP2,
|
||||
SO_FUNC1_LOG,
|
||||
SO_FUNC1_LOG2,
|
||||
SO_FUNC1_LOG1P,
|
||||
SO_FUNC1_LOG10,
|
||||
SO_FUNC1_LOGB,
|
||||
SO_FUNC1_FABS,
|
||||
SO_FUNC1_SQRT,
|
||||
SO_FUNC1_ERF,
|
||||
SO_FUNC1_ERFC,
|
||||
SO_FUNC1_GAMMA,
|
||||
SO_FUNC1_LGAMMA,
|
||||
SO_FUNC1_CEIL,
|
||||
SO_FUNC1_FLOOR,
|
||||
SO_FUNC1_RINT,
|
||||
SO_FUNC1_NEARBYINT,
|
||||
SO_FUNC1_RINTOL,
|
||||
SO_FUNC1_ROUND,
|
||||
SO_FUNC1_ROUNDTOL,
|
||||
SO_FUNC1_TRUNC,
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// simple operator for single argument functions
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorFunc1_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInput1, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
SOFunc1Type_t m_funcType;
|
||||
bool m_bNormTrig;
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorFunc1 : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorFunc1 )
|
||||
|
||||
};
|
||||
//-----------------------------------------------------------------------------
|
||||
// simple operator for setting a single scratchpad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorFloat_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInput1, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInput2, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
SOOpType_t m_opType;
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorFloat : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorFloat )
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// simple operator for setting a single scratchpad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorFloatAccumulate12_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInput1, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInput2, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInput3, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInput4, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInput5, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInput6, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInput7, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInput8, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInput9, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInput10, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInput11, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInput12, SO_SINGLE )
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
SOOpType_t m_opType;
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorFloatAccumulate12 : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorFloatAccumulate12 )
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// simple operator for setting a single position
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorVec3_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInput1, SO_VEC3 )
|
||||
SOS_INPUT_FLOAT( m_flInput2, SO_VEC3 )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_VEC3 )
|
||||
SOOpType_t m_opType;
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorVec3 : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorVec3 )
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// simple operator for settting a single speaker scratchpad expression
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorSpeakers_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInput1, SO_SPEAKERS )
|
||||
SOS_INPUT_FLOAT( m_flInput2, SO_SPEAKERS )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SPEAKERS )
|
||||
SOOpType_t m_opType;
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorSpeakers : public CSosOperator
|
||||
{
|
||||
|
||||
SOS_HEADER_DESC( CSosOperatorSpeakers )
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// distance between 2 positions
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorSourceDistance_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInputPos, SO_VEC3 )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
bool m_b2D;
|
||||
bool m_bForceNotPlayerSound;
|
||||
};
|
||||
|
||||
class CSosOperatorSourceDistance : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorSourceDistance )
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// RemapValue
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorRemapValue_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT(m_flInputMin, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInputMax, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInputMapMin, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInputMapMax, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInput, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
|
||||
bool m_bClampRange;
|
||||
bool m_bDefaultMax;
|
||||
};
|
||||
|
||||
class CSosOperatorRemapValue : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorRemapValue )
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Curve4
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorCurve4_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT(m_flInputX1, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInputY1, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInputX2, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInputY2, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInputX3, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInputY3, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInputX4, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInputY4, SO_SINGLE )
|
||||
|
||||
SOS_INPUT_FLOAT(m_flInput, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
|
||||
SOOpCurveType_t m_nCurveType;
|
||||
};
|
||||
|
||||
class CSosOperatorCurve4 : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorCurve4 )
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Facing
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorFacing_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT(m_flInputAngles, SO_VEC3 )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
};
|
||||
|
||||
class CSosOperatorFacing : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorFacing )
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Facing
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorRandom_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT(m_flInputMin, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInputMax, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInputSeed, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
bool m_bRoundToInt;
|
||||
};
|
||||
|
||||
class CSosOperatorRandom : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorRandom )
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Logic Switch
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorLogicSwitch_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT(m_flInput1, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInput2, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT(m_flInputSwitch, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
};
|
||||
|
||||
class CSosOperatorLogicSwitch : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorLogicSwitch )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_MATH_H
|
||||
149
engine/audio/private/snd_op_sys/sos_op_mixer.cpp
Normal file
149
engine/audio/private/snd_op_sys/sos_op_mixer.cpp
Normal file
@@ -0,0 +1,149 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_mixer.h"
|
||||
|
||||
#include "snd_mixgroups.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorMixGroup
|
||||
// Catchall operator
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorMixGroup, "get_soundmixer" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorMixGroup, m_flOutputVolume, SO_SINGLE, "output_volume" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorMixGroup, m_flOutputLevel, SO_SINGLE, "output_level" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorMixGroup, m_flOutputDSP, SO_SINGLE, "output_dsp" );
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorMixGroup, "get_soundmixer" )
|
||||
|
||||
void CSosOperatorMixGroup::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorMixGroup_t *pStructMem = (CSosOperatorMixGroup_t *)pVoidMem;
|
||||
|
||||
pStructMem->m_nMixGroupIndex = -1;
|
||||
pStructMem->m_bSetMixGroupOnChannel = false;
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputVolume, SO_SINGLE, 1.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputLevel, SO_SINGLE, 1.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputDSP, SO_SINGLE, 1.0 )
|
||||
|
||||
}
|
||||
void CSosOperatorMixGroup::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorMixGroup_t *pStructMem = (CSosOperatorMixGroup_t *)pVoidMem;
|
||||
|
||||
if( !pChannel )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Sound operator %s requires valid channel pointer, being called without one\n", pStack->GetOperatorName( nOpIndex ));
|
||||
return;
|
||||
}
|
||||
|
||||
if ( pStructMem->m_nMixGroupIndex < 0 )
|
||||
{
|
||||
char sndname[MAX_PATH];
|
||||
pChannel->sfx->getname(sndname, sizeof(sndname));
|
||||
MXR_GetMixGroupFromSoundsource( pChannel );
|
||||
pStructMem->m_nMixGroupIndex = MXR_GetFirstValidMixGroup( pChannel );
|
||||
|
||||
// DevMsg( "***FILE: %s: INDEX: %i: MIXGROUP: %s\n", sndname, pStructMem->m_nMixGroupIndex, MXR_GetGroupnameFromId( pStructMem->m_nMixGroupIndex ));
|
||||
if ( pStructMem->m_nMixGroupIndex < 0 )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: MixGroup index error, %s, %s", sndname, MXR_GetGroupnameFromId( pStructMem->m_nMixGroupIndex ));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( pStructMem->m_bSetMixGroupOnChannel && pChannel )
|
||||
{
|
||||
pChannel->mixgroups[0] = pStructMem->m_nMixGroupIndex;
|
||||
|
||||
}
|
||||
|
||||
mixervalues_t mixValues;
|
||||
MXR_GetValuesFromMixGroupIndex( &mixValues, pStructMem->m_nMixGroupIndex );
|
||||
|
||||
pStructMem->m_flOutputLevel[0] = mixValues.level;
|
||||
pStructMem->m_flOutputVolume[0] = mixValues.volume;
|
||||
pStructMem->m_flOutputDSP[0] = mixValues.dsp;
|
||||
|
||||
pChannel->last_mixgroupid = pStructMem->m_nMixGroupIndex;
|
||||
}
|
||||
|
||||
void CSosOperatorMixGroup::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
CSosOperatorMixGroup_t *pStructMem = (CSosOperatorMixGroup_t *)pVoidMem;
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*smixgroup: %s\n", nLevel, " ", MXR_GetGroupnameFromId( pStructMem->m_nMixGroupIndex ));
|
||||
|
||||
}
|
||||
void CSosOperatorMixGroup::OpHelp( ) const
|
||||
{
|
||||
|
||||
}
|
||||
void CSosOperatorMixGroup::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorMixGroup_t *pStructMem = (CSosOperatorMixGroup_t *)pVoidMem;
|
||||
bool bHasMixGroupIndex = false;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "set_mixgroup_to_channel" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "false" ) )
|
||||
{
|
||||
pStructMem->m_bSetMixGroupOnChannel = false;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bSetMixGroupOnChannel = true;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "mixgroup" ) )
|
||||
{
|
||||
pStructMem->m_nMixGroupIndex = MXR_GetMixgroupFromName( pValueString );
|
||||
if ( pStructMem->m_nMixGroupIndex > -1 )
|
||||
{
|
||||
bHasMixGroupIndex = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
|
||||
/* if ( !bHasMixGroupIndex )
|
||||
{
|
||||
MXR_GetMixGroupFromSoundsource( pStructMem->m_pChannel );
|
||||
pStructMem->m_nMixGroupIndex = MXR_GetFirstValidMixGroup( pStructMem->m_pChannel );
|
||||
}
|
||||
*/
|
||||
}
|
||||
34
engine/audio/private/snd_op_sys/sos_op_mixer.h
Normal file
34
engine/audio/private/snd_op_sys/sos_op_mixer.h
Normal file
@@ -0,0 +1,34 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_MIXER_H
|
||||
#define SOS_OP_MIXER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// basic mixgroup operator
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorMixGroup_t : CSosOperator_t
|
||||
{
|
||||
int m_nMixGroupIndex;
|
||||
bool m_bSetMixGroupOnChannel;
|
||||
SOS_OUTPUT_FLOAT( m_flOutputVolume, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputLevel, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputDSP, SO_SINGLE )
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorMixGroup : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorMixGroup )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_MIXER
|
||||
163
engine/audio/private/snd_op_sys/sos_op_mixlayer.cpp
Normal file
163
engine/audio/private/snd_op_sys/sos_op_mixlayer.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op_mixlayer.h"
|
||||
|
||||
|
||||
// #include "cdll_engine_int.h"
|
||||
#include "../../debugoverlay.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorMixLayer
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorMixLayer, "sys_mixlayer" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorMixLayer, m_flInput, SO_SINGLE, "input" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorMixLayer, "sys_mixlayer" )
|
||||
|
||||
void CSosOperatorMixLayer::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorMixLayer_t *pStructMem = (CSosOperatorMixLayer_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flInput, SO_SINGLE, 0.0 )
|
||||
pStructMem->m_nFieldType = MXR_MIXGROUP_NONE;
|
||||
pStructMem->m_nMixLayerIndex = -1;
|
||||
pStructMem->m_nMixGroupIndex = -1;
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorMixLayer::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorMixLayer_t *pStructMem = (CSosOperatorMixLayer_t *)pVoidMem;
|
||||
|
||||
if( pStructMem->m_nMixGroupIndex < 0 )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: MixLayer operator has invalid mix group index!\n" );
|
||||
return;
|
||||
}
|
||||
if( pStructMem->m_nMixLayerIndex < 0 )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: MixLayer operator has invalid mix layer index!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
S_SetMixGroupOfMixLayer( pStructMem->m_nMixGroupIndex, pStructMem->m_nMixLayerIndex, pStructMem->m_nFieldType, pStructMem->m_flInput[0] );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CSosOperatorMixLayer::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorMixLayer_t *pStructMem = (CSosOperatorMixLayer_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
|
||||
const char *pFieldTypeString = "none";
|
||||
switch( pStructMem->m_nFieldType )
|
||||
{
|
||||
case MXR_MIXGROUP_VOL:
|
||||
pFieldTypeString = "volume";
|
||||
break;
|
||||
case MXR_MIXGROUP_LEVEL:
|
||||
pFieldTypeString = "level";
|
||||
break;
|
||||
case MXR_MIXGROUP_DSP:
|
||||
pFieldTypeString = "dsp";
|
||||
break;
|
||||
case MXR_MIXGROUP_SOLO:
|
||||
pFieldTypeString = "solo";
|
||||
break;
|
||||
case MXR_MIXGROUP_MUTE:
|
||||
pFieldTypeString = "mute";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sField: %s\n", nLevel, " ", pFieldTypeString );
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorMixLayer::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorMixLayer::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorMixLayer_t *pStructMem = (CSosOperatorMixLayer_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ))
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "field" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "volume" ) )
|
||||
{
|
||||
pStructMem->m_nFieldType = MXR_MIXGROUP_VOL;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "level" ) )
|
||||
{
|
||||
pStructMem->m_nFieldType = MXR_MIXGROUP_LEVEL;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "dsp" ) )
|
||||
{
|
||||
pStructMem->m_nFieldType = MXR_MIXGROUP_DSP;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "solo" ) )
|
||||
{
|
||||
pStructMem->m_nFieldType = MXR_MIXGROUP_SOLO;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "mute" ) )
|
||||
{
|
||||
pStructMem->m_nFieldType = MXR_MIXGROUP_MUTE;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "mixlayer" ) )
|
||||
{
|
||||
int nMixLayerID = MXR_GetMixLayerIndexFromName( pValueString );
|
||||
if ( nMixLayerID == -1 )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Failed to get mix layer %s!\n", pValueString );
|
||||
}
|
||||
pStructMem->m_nMixLayerIndex = nMixLayerID;
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "mixgroup" ) )
|
||||
{
|
||||
int nMixGroupID = S_GetMixGroupIndex( pValueString );
|
||||
if ( nMixGroupID == -1 )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Failed to get mix group %s!\n", pValueString );
|
||||
}
|
||||
pStructMem->m_nMixGroupIndex = nMixGroupID;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
34
engine/audio/private/snd_op_sys/sos_op_mixlayer.h
Normal file
34
engine/audio/private/snd_op_sys/sos_op_mixlayer.h
Normal file
@@ -0,0 +1,34 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_MIXLAYER_H
|
||||
#define SOS_OP_MIXLAYER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "snd_mixgroups.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorMixLayer_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInput, SO_SINGLE )
|
||||
MXRMixGroupFields_t m_nFieldType;
|
||||
int m_nMixLayerIndex;
|
||||
int m_nMixGroupIndex;
|
||||
};
|
||||
|
||||
class CSosOperatorMixLayer : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorMixLayer )
|
||||
};
|
||||
|
||||
|
||||
#endif // SOS_OP_MIXLAYER_H
|
||||
292
engine/audio/private/snd_op_sys/sos_op_occlusion.cpp
Normal file
292
engine/audio/private/snd_op_sys/sos_op_occlusion.cpp
Normal file
@@ -0,0 +1,292 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_occlusion.h"
|
||||
|
||||
#include "snd_dma.h"
|
||||
#include "../../cl_splitscreen.h"
|
||||
#include "../../enginetrace.h"
|
||||
#include "render.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
float S_CalcOcclusion( int nSlot, channel_t *ch, const Vector &vecListenerOrigin, Vector vSoundSource, float flOccludedDBLoss );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorOcclusion
|
||||
// Setting a single, simple scratch pad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorOcclusion, "calc_occlusion" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorOcclusion, m_flInputTraceInterval, SO_SINGLE, "input_trace_interval" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorOcclusion, m_flInputScalar, SO_SINGLE, "input_scalar" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorOcclusion, m_flInputPosition, SO_VEC3, "input_position" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorOcclusion, m_flOutput, SO_SINGLE, "output" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorOcclusion, "calc_occlusion" )
|
||||
|
||||
void CSosOperatorOcclusion::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorOcclusion_t *pStructMem = (CSosOperatorOcclusion_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flInputScalar, SO_SINGLE, 1.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputPosition, SO_VEC3, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutput, SO_SINGLE, 1.0 )
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flInputTraceInterval, SO_SINGLE, -1.0 )
|
||||
pStructMem->m_flLastTraceTime = -1.0;
|
||||
pStructMem->m_flOccludedDBLoss = snd_obscured_gain_db.GetFloat();
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorOcclusion::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorOcclusion_t *pStructMem = (CSosOperatorOcclusion_t *)pVoidMem;
|
||||
|
||||
if( !pChannel )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Sound operator %s requires valid channel pointer, being called without one\n", pStack->GetOperatorName( nOpIndex ));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// scalar of 0.0 = off, do nothing
|
||||
float flScalar = pStructMem->m_flInputScalar[0];
|
||||
if( flScalar == 0.0 )
|
||||
{
|
||||
pStructMem->m_flOutput[0] = 1.0;
|
||||
return;
|
||||
}
|
||||
|
||||
float flCurHostTime = g_pSoundServices->GetHostTime();
|
||||
|
||||
|
||||
bool bIntervalHasPassed = ( ( pStructMem->m_flInputTraceInterval[0] >= 0.0 &&
|
||||
( pStructMem->m_flInputTraceInterval[0] <= ( flCurHostTime - pStructMem->m_flLastTraceTime ) ))
|
||||
|| pChannel->flags.bfirstpass );
|
||||
|
||||
bool bOkToTrace = SND_ChannelOkToTrace( pChannel );
|
||||
|
||||
bool bDoNewTrace = true;
|
||||
|
||||
// During signon just apply regular state machine since world hasn't been
|
||||
// created or settled yet...
|
||||
if ( !SND_IsInGame() && !toolframework->InToolMode() )
|
||||
{
|
||||
bDoNewTrace = false;
|
||||
}
|
||||
|
||||
if( ( !pChannel->flags.bfirstpass && !pChannel->flags.isSentence ) && !bIntervalHasPassed || !bOkToTrace )
|
||||
{
|
||||
bDoNewTrace = false;
|
||||
}
|
||||
|
||||
|
||||
float flResult = 0.0;
|
||||
if( bDoNewTrace )
|
||||
{
|
||||
|
||||
// Log_Msg( LOG_SND_OPERATORS, "UPDATING: Sound operator %s\n", pStack->GetOperatorName( nOpIndex ));
|
||||
|
||||
Vector vOrigin;
|
||||
vOrigin[0] = pStructMem->m_flInputPosition[0];
|
||||
vOrigin[1] = pStructMem->m_flInputPosition[1];
|
||||
vOrigin[2] = pStructMem->m_flInputPosition[2];
|
||||
|
||||
// find the loudest, ie: least occluded ss player
|
||||
FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh )
|
||||
{
|
||||
|
||||
float flGain = S_CalcOcclusion( hh,
|
||||
pChannel,
|
||||
pScratchPad->m_vPlayerOrigin[ hh ],
|
||||
vOrigin,
|
||||
pStructMem->m_flOccludedDBLoss );
|
||||
|
||||
// inverse scale
|
||||
flGain = 1.0 - ( ( 1.0 - flGain ) * flScalar );
|
||||
|
||||
flGain = SND_FadeToNewGain( &(pChannel->gain[ hh ]), pChannel, flGain );
|
||||
|
||||
flResult = MAX( flResult, flGain );
|
||||
|
||||
}
|
||||
pStructMem->m_flLastTraceTime = flCurHostTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh )
|
||||
{
|
||||
float flGain = SND_FadeToNewGain( &(pChannel->gain[ hh ] ), pChannel, -1.0 );
|
||||
flResult = MAX( flResult, flGain );
|
||||
}
|
||||
}
|
||||
|
||||
pStructMem->m_flOutput[0] = flResult;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorOcclusion::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorOcclusion_t *pStructMem = (CSosOperatorOcclusion_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
|
||||
}
|
||||
void CSosOperatorOcclusion::OpHelp( ) const
|
||||
{
|
||||
|
||||
}
|
||||
void CSosOperatorOcclusion::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorOcclusion_t *pStructMem = (CSosOperatorOcclusion_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "occlusio_db_loss" ) )
|
||||
{
|
||||
pStructMem->m_flOccludedDBLoss = V_atof( pValueString ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
float S_CalcOcclusion( int nSlot, channel_t *ch, const Vector &vecListenerOrigin, Vector vSoundSource, float flOccludedDBLoss )
|
||||
{
|
||||
float gain = 1.0;
|
||||
int count = 1;
|
||||
|
||||
trace_t tr;
|
||||
CTraceFilterWorldOnly filter; // UNDONE: also test for static props?
|
||||
Ray_t ray;
|
||||
ray.Init( MainViewOrigin( nSlot ), vSoundSource );
|
||||
g_pEngineTraceClient->TraceRay( ray, MASK_BLOCK_AUDIO, &filter, &tr );
|
||||
// total traces this frame
|
||||
g_snd_trace_count++;
|
||||
|
||||
if (tr.DidHit() && tr.fraction < 0.99)
|
||||
{
|
||||
// can't see center of sound source:
|
||||
// build extents based on dB sndlvl of source,
|
||||
// test to see how many extents are visible,
|
||||
// drop gain by snd_gain_db per extent hidden
|
||||
|
||||
Vector vSoundSources[4];
|
||||
soundlevel_t sndlvl = DIST_MULT_TO_SNDLVL( ch->dist_mult );
|
||||
float radius;
|
||||
Vector vsrc_forward;
|
||||
Vector vsrc_right;
|
||||
Vector vsrc_up;
|
||||
Vector vecl;
|
||||
Vector vecr;
|
||||
Vector vecl2;
|
||||
Vector vecr2;
|
||||
int i;
|
||||
|
||||
// get radius
|
||||
|
||||
if ( ch->radius > 0 )
|
||||
radius = ch->radius;
|
||||
else
|
||||
radius = dB_To_Radius( sndlvl); // approximate radius from soundlevel
|
||||
|
||||
// set up extent vSoundSources - on upward or downward diagonals, facing player
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
vSoundSources[i] = vSoundSource;
|
||||
|
||||
// vsrc_forward is normalized vector from sound source to listener
|
||||
|
||||
VectorSubtract( vecListenerOrigin, vSoundSource, vsrc_forward );
|
||||
VectorNormalize( vsrc_forward );
|
||||
VectorVectors( vsrc_forward, vsrc_right, vsrc_up );
|
||||
|
||||
VectorAdd( vsrc_up, vsrc_right, vecl );
|
||||
|
||||
// if src above listener, force 'up' vector to point down - create diagonals up & down
|
||||
|
||||
if ( vSoundSource.z > vecListenerOrigin.z + (10 * 12) )
|
||||
vsrc_up.z = -vsrc_up.z;
|
||||
|
||||
VectorSubtract( vsrc_up, vsrc_right, vecr );
|
||||
VectorNormalize( vecl );
|
||||
VectorNormalize( vecr );
|
||||
|
||||
// get diagonal vectors from sound source
|
||||
|
||||
vecl2 = radius * vecl;
|
||||
vecr2 = radius * vecr;
|
||||
vecl = (radius / 2.0) * vecl;
|
||||
vecr = (radius / 2.0) * vecr;
|
||||
|
||||
// vSoundSources from diagonal vectors
|
||||
|
||||
vSoundSources[0] += vecl;
|
||||
vSoundSources[1] += vecr;
|
||||
vSoundSources[2] += vecl2;
|
||||
vSoundSources[3] += vecr2;
|
||||
|
||||
// drop gain for each point on radius diagonal that is obscured
|
||||
|
||||
for (count = 0, i = 0; i < 4; i++)
|
||||
{
|
||||
// UNDONE: some vSoundSources are in walls - in this case, trace from the wall hit location
|
||||
|
||||
Ray_t ray;
|
||||
ray.Init( MainViewOrigin( nSlot ), vSoundSources[i] );
|
||||
g_pEngineTraceClient->TraceRay( ray, MASK_BLOCK_AUDIO, &filter, &tr );
|
||||
|
||||
if (tr.DidHit() && tr.fraction < 0.99 && !tr.startsolid )
|
||||
{
|
||||
count++; // skip first obscured point: at least 2 points + center should be obscured to hear db loss
|
||||
if (count > 1)
|
||||
gain = gain * dB_To_Gain( flOccludedDBLoss );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( snd_showstart.GetInt() == 7)
|
||||
{
|
||||
static float g_drop_prev = 0;
|
||||
float drop = (count-1) * flOccludedDBLoss;
|
||||
|
||||
if (drop != g_drop_prev)
|
||||
{
|
||||
DevMsg( "dB drop: %1.4f \n", drop);
|
||||
g_drop_prev = drop;
|
||||
}
|
||||
}
|
||||
return gain;
|
||||
|
||||
}
|
||||
33
engine/audio/private/snd_op_sys/sos_op_occlusion.h
Normal file
33
engine/audio/private/snd_op_sys/sos_op_occlusion.h
Normal file
@@ -0,0 +1,33 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_OCCLUSION_H
|
||||
#define SOS_OP_OCCLUSION_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Occlusion
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorOcclusion_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInputPosition, SO_VEC3 )
|
||||
SOS_INPUT_FLOAT( m_flInputScalar, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputTraceInterval, SO_SINGLE )
|
||||
float m_flLastTraceTime;
|
||||
float m_flOccludedDBLoss;
|
||||
};
|
||||
class CSosOperatorOcclusion : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorOcclusion )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_OCCLUSION
|
||||
255
engine/audio/private/snd_op_sys/sos_op_opvar.cpp
Normal file
255
engine/audio/private/snd_op_sys/sos_op_opvar.cpp
Normal file
@@ -0,0 +1,255 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_opvar.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorSetOpvarFloat
|
||||
// Setting a single, simple scratch pad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorSetOpvarFloat, "set_opvar_float" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorSetOpvarFloat, m_flInput, SO_SINGLE, "input" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorSetOpvarFloat, "set_opvar_float" )
|
||||
|
||||
void CSosOperatorSetOpvarFloat::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorSetOpvarFloat_t *pStructMem = (CSosOperatorSetOpvarFloat_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flInput, SO_SINGLE, 0.0 )
|
||||
pStructMem->m_nOpVarName[ 0 ] = 0;
|
||||
}
|
||||
|
||||
void CSosOperatorSetOpvarFloat::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorSetOpvarFloat_t *pStructMem = (CSosOperatorSetOpvarFloat_t *)pVoidMem;
|
||||
|
||||
float flOpvarVal = pStructMem->m_flInput[0];
|
||||
g_pSoundOperatorSystem->SetOpVarFloat( pStructMem->m_nOpVarName, flOpvarVal );
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorSetOpvarFloat::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorSetOpvarFloat_t *pStructMem = (CSosOperatorSetOpvarFloat_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sopvar: %s\n", nLevel, " ", pStructMem->m_nOpVarName );
|
||||
}
|
||||
void CSosOperatorSetOpvarFloat::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorSetOpvarFloat::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
extern IVEngineClient *engineClient;
|
||||
CSosOperatorSetOpvarFloat_t *pStructMem = (CSosOperatorSetOpvarFloat_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ))
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "opvar" ) )
|
||||
{
|
||||
V_strncpy( pStructMem->m_nOpVarName, pValueString, ARRAYSIZE( pStructMem->m_nOpVarName ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorGetOpvarFloat
|
||||
// Setting a single, simple scratch pad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorGetOpvarFloat, "get_opvar_float" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorGetOpvarFloat, m_flOutput, SO_SINGLE, "output" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorGetOpvarFloat, m_flOpVarExists, SO_SINGLE, "output_opvar_exists" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorGetOpvarFloat, "get_opvar_float" )
|
||||
|
||||
void CSosOperatorGetOpvarFloat::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorGetOpvarFloat_t *pStructMem = (CSosOperatorGetOpvarFloat_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutput, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOpVarExists, SO_SINGLE, 0.0 )
|
||||
pStructMem->m_nOpVarName[ 0 ] = 0;
|
||||
}
|
||||
|
||||
void CSosOperatorGetOpvarFloat::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorGetOpvarFloat_t *pStructMem = (CSosOperatorGetOpvarFloat_t *)pVoidMem;
|
||||
|
||||
float flOpvarVal = 0.0;
|
||||
bool bExists = g_pSoundOperatorSystem->GetOpVarFloat( pStructMem->m_nOpVarName, flOpvarVal );
|
||||
if( bExists )
|
||||
{
|
||||
pStructMem->m_flOpVarExists[0] = 1.0;
|
||||
pStructMem->m_flOutput[0] = flOpvarVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_flOpVarExists[0] = 0.0;
|
||||
pStructMem->m_flOutput[0] = 0.0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorGetOpvarFloat::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorGetOpvarFloat_t *pStructMem = (CSosOperatorGetOpvarFloat_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sopvar: %s\n", nLevel, " ", pStructMem->m_nOpVarName );
|
||||
}
|
||||
void CSosOperatorGetOpvarFloat::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorGetOpvarFloat::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
extern IVEngineClient *engineClient;
|
||||
CSosOperatorGetOpvarFloat_t *pStructMem = (CSosOperatorGetOpvarFloat_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ))
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "opvar" ) )
|
||||
{
|
||||
V_strncpy( pStructMem->m_nOpVarName, pValueString, ARRAYSIZE( pStructMem->m_nOpVarName ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorIncrementOpvarFloat
|
||||
// Setting a single, simple scratch pad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorIncrementOpvarFloat, "increment_opvar_float" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorIncrementOpvarFloat, m_flInput, SO_SINGLE, "input" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorIncrementOpvarFloat, m_flOutput, SO_SINGLE, "output" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorIncrementOpvarFloat, m_flOpVarExists, SO_SINGLE, "output_opvar_exists" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorIncrementOpvarFloat, "increment_opvar_float" )
|
||||
|
||||
void CSosOperatorIncrementOpvarFloat::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorIncrementOpvarFloat_t *pStructMem = (CSosOperatorIncrementOpvarFloat_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flInput, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutput, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOpVarExists, SO_SINGLE, 0.0 )
|
||||
pStructMem->m_nOpVarName[ 0 ] = 0;
|
||||
}
|
||||
|
||||
void CSosOperatorIncrementOpvarFloat::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorIncrementOpvarFloat_t *pStructMem = (CSosOperatorIncrementOpvarFloat_t *)pVoidMem;
|
||||
|
||||
float flOpvarVal = 0.0; //value of the opvar currently
|
||||
float flOpvarNewVal = 0.0; //value that we'll set it to
|
||||
float flOpvarInc = pStructMem->m_flInput[0]; //value to add
|
||||
|
||||
bool bExists = g_pSoundOperatorSystem->GetOpVarFloat( pStructMem->m_nOpVarName, flOpvarVal );
|
||||
|
||||
if( bExists )
|
||||
{
|
||||
flOpvarNewVal = flOpvarVal + flOpvarInc;
|
||||
pStructMem->m_flOpVarExists[0] = 1.0;
|
||||
pStructMem->m_flOutput[0] = flOpvarNewVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
flOpvarNewVal = flOpvarInc;
|
||||
pStructMem->m_flOpVarExists[0] = 0.0;
|
||||
pStructMem->m_flOutput[0] = flOpvarNewVal;
|
||||
}
|
||||
|
||||
g_pSoundOperatorSystem->SetOpVarFloat( pStructMem->m_nOpVarName, flOpvarNewVal );
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorIncrementOpvarFloat::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorIncrementOpvarFloat_t *pStructMem = (CSosOperatorIncrementOpvarFloat_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sopvar: %s\n", nLevel, " ", pStructMem->m_nOpVarName );
|
||||
}
|
||||
void CSosOperatorIncrementOpvarFloat::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorIncrementOpvarFloat::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
extern IVEngineClient *engineClient;
|
||||
CSosOperatorIncrementOpvarFloat_t *pStructMem = (CSosOperatorIncrementOpvarFloat_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ))
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "opvar" ) )
|
||||
{
|
||||
V_strncpy( pStructMem->m_nOpVarName, pValueString, ARRAYSIZE( pStructMem->m_nOpVarName ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
65
engine/audio/private/snd_op_sys/sos_op_opvar.h
Normal file
65
engine/audio/private/snd_op_sys/sos_op_opvar.h
Normal file
@@ -0,0 +1,65 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_OPVAR_H
|
||||
#define SOS_OP_OPVAR_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// set opvar
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorSetOpvarFloat_t : CSosOperator_t
|
||||
{
|
||||
|
||||
SOS_INPUT_FLOAT( m_flInput, SO_SINGLE )
|
||||
char m_nOpVarName[128];
|
||||
|
||||
};
|
||||
class CSosOperatorSetOpvarFloat : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorSetOpvarFloat )
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// get opvar
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorGetOpvarFloat_t : CSosOperator_t
|
||||
{
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOpVarExists, SO_SINGLE )
|
||||
char m_nOpVarName[128];
|
||||
|
||||
};
|
||||
class CSosOperatorGetOpvarFloat : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorGetOpvarFloat )
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// increment opvar
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorIncrementOpvarFloat_t : CSosOperator_t
|
||||
{
|
||||
|
||||
SOS_INPUT_FLOAT( m_flInput, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOpVarExists, SO_SINGLE )
|
||||
char m_nOpVarName[128];
|
||||
|
||||
};
|
||||
class CSosOperatorIncrementOpvarFloat : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorIncrementOpvarFloat )
|
||||
|
||||
};
|
||||
|
||||
#endif // SOS_OP_OPVAR_H
|
||||
258
engine/audio/private/snd_op_sys/sos_op_output.cpp
Normal file
258
engine/audio/private/snd_op_sys/sos_op_output.cpp
Normal file
@@ -0,0 +1,258 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_output.h"
|
||||
|
||||
#include "snd_dma.h"
|
||||
// #include "cdll_engine_int.h"
|
||||
#include "../../debugoverlay.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorOutput
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorOutput, "sys_output" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorOutput, m_flInputSpeakers, SO_SPEAKERS, "input_speakers" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorOutput, m_flInputVec3, SO_VEC3, "input_vec3")
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorOutput, m_flInputFloat, SO_SINGLE, "input_float")
|
||||
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorOutput, "sys_output" )
|
||||
|
||||
void CSosOperatorOutput::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorOutput_t *pStructMem = (CSosOperatorOutput_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flInputFloat, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputVec3, SO_VEC3, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputSpeakers, SO_SPEAKERS, 0.0 )
|
||||
|
||||
pStructMem->m_nOutType = SOS_OUT_NONE;
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorOutput::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorOutput_t *pStructMem = (CSosOperatorOutput_t *)pVoidMem;
|
||||
|
||||
if( pStructMem->m_nOutType == SOS_OUT_DELAY )
|
||||
{
|
||||
pScratchPad->m_flDelay = pStructMem->m_flInputFloat[0];
|
||||
}
|
||||
else if( pStructMem->m_nOutType == SOS_OUT_STOPHOLD )
|
||||
{
|
||||
SOSStopType_t stopType = pStack->GetStopType();
|
||||
if( stopType != SOS_STOP_NONE && stopType != SOS_STOP_FORCE && stopType != SOS_STOP_QUEUE )
|
||||
{
|
||||
pStack->SetStopType( pStructMem->m_flInputFloat[0] > 0.0 ? SOS_STOP_HOLD : SOS_STOP_NORM );
|
||||
}
|
||||
}
|
||||
else if( pStructMem->m_nOutType == SOS_OUT_BLOCK_START )
|
||||
{
|
||||
pScratchPad->m_bBlockStart = pStructMem->m_flInputFloat[0] > 0.0 ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !pChannel )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Sound operator %s requires valid channel pointer, being called without one\n", pStack->GetOperatorName( nOpIndex ));
|
||||
return;
|
||||
}
|
||||
|
||||
switch( pStructMem->m_nOutType )
|
||||
{
|
||||
case SOS_OUT_POSITION:
|
||||
pChannel->origin[0] = pStructMem->m_flInputVec3[0];
|
||||
pChannel->origin[1] = pStructMem->m_flInputVec3[1];
|
||||
pChannel->origin[2] = pStructMem->m_flInputVec3[2];
|
||||
break;
|
||||
case SOS_OUT_DSP:
|
||||
pChannel->dspmix = pStructMem->m_flInputFloat[0];
|
||||
break;
|
||||
case SOS_OUT_SPEAKERS: {
|
||||
float fScaledVolumes[CCHANVOLUMES / 2];
|
||||
for (int i = 0; i != CCHANVOLUMES / 2; ++i)
|
||||
{
|
||||
fScaledVolumes[i] = pStructMem->m_flInputSpeakers[i] * 255.0f;
|
||||
}
|
||||
ChannelSetVolTargets(pChannel, fScaledVolumes, IFRONT_LEFT, CCHANVOLUMES / 2);
|
||||
break;
|
||||
}
|
||||
case SOS_OUT_FACING:
|
||||
pChannel->dspface = (pStructMem->m_flInputFloat[0] * 2.0) - 1.0;
|
||||
break;
|
||||
case SOS_OUT_DISTVAR:
|
||||
pChannel->distmix = pStructMem->m_flInputFloat[0];
|
||||
break;
|
||||
case SOS_OUT_PITCH:
|
||||
pChannel->basePitch = (int)(pStructMem->m_flInputFloat[0] * 100);
|
||||
pChannel->pitch = pStructMem->m_flInputFloat[0];
|
||||
break;
|
||||
case SOS_OUT_MIXLAYER_TRIGGER:
|
||||
pChannel->last_vol = pStructMem->m_flInputFloat[0];
|
||||
break;
|
||||
case SOS_OUT_SAVE_RESTORE:
|
||||
pChannel->flags.m_bShouldSaveRestore = pStructMem->m_flInputFloat[0] > 0.0 ? true : false;
|
||||
break;
|
||||
case SOS_OUT_PHONON_XFADE: {
|
||||
pChannel->hrtf.lerp = pStructMem->m_flInputFloat[0];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CSosOperatorOutput::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorOutput_t *pStructMem = (CSosOperatorOutput_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
|
||||
const char *pOutTypeString = "none";
|
||||
switch( pStructMem->m_nOutType )
|
||||
{
|
||||
case SOS_OUT_VOLUME:
|
||||
pOutTypeString = "volume";
|
||||
break;
|
||||
case SOS_OUT_POSITION:
|
||||
pOutTypeString = "position";
|
||||
break;
|
||||
case SOS_OUT_DSP:
|
||||
pOutTypeString = "dsp";
|
||||
break;
|
||||
case SOS_OUT_SPEAKERS:
|
||||
pOutTypeString = "speakers";
|
||||
break;
|
||||
case SOS_OUT_FACING:
|
||||
pOutTypeString = "facing";
|
||||
break;
|
||||
case SOS_OUT_DISTVAR:
|
||||
pOutTypeString = "distvar";
|
||||
break;
|
||||
case SOS_OUT_PITCH:
|
||||
pOutTypeString = "pitch";
|
||||
break;
|
||||
case SOS_OUT_DELAY:
|
||||
pOutTypeString = "delay";
|
||||
break;
|
||||
case SOS_OUT_STOPHOLD:
|
||||
pOutTypeString = "stop_hold";
|
||||
break;
|
||||
case SOS_OUT_MIXLAYER_TRIGGER:
|
||||
pOutTypeString = "mixlayer_trigger";
|
||||
break;
|
||||
case SOS_OUT_SAVE_RESTORE:
|
||||
pOutTypeString = "save_restore";
|
||||
break;
|
||||
case SOS_OUT_BLOCK_START:
|
||||
pOutTypeString = "block_start";
|
||||
break;
|
||||
case SOS_OUT_PHONON_XFADE:
|
||||
pOutTypeString = "phonon_xfade";
|
||||
break;
|
||||
}
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sOutput: %s\n", nLevel, " ", pOutTypeString );
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorOutput::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorOutput::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorOutput_t *pStructMem = (CSosOperatorOutput_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ))
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "output" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "volume" ) )
|
||||
{
|
||||
pStructMem->m_nOutType = SOS_OUT_VOLUME;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "dsp" ) )
|
||||
{
|
||||
pStructMem->m_nOutType = SOS_OUT_DSP;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "position" ) )
|
||||
{
|
||||
pStructMem->m_nOutType = SOS_OUT_POSITION;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "speakers" ) )
|
||||
{
|
||||
pStructMem->m_nOutType = SOS_OUT_SPEAKERS;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "facing" ) )
|
||||
{
|
||||
pStructMem->m_nOutType = SOS_OUT_FACING;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "distvar" ) )
|
||||
{
|
||||
pStructMem->m_nOutType = SOS_OUT_DISTVAR;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "pitch" ) )
|
||||
{
|
||||
pStructMem->m_nOutType = SOS_OUT_PITCH;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "delay" ) )
|
||||
{
|
||||
pStructMem->m_nOutType = SOS_OUT_DELAY;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "stop_hold" ) )
|
||||
{
|
||||
pStructMem->m_nOutType = SOS_OUT_STOPHOLD;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "mixlayer_trigger" ) )
|
||||
{
|
||||
pStructMem->m_nOutType = SOS_OUT_MIXLAYER_TRIGGER;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "save_restore" ) )
|
||||
{
|
||||
pStructMem->m_nOutType = SOS_OUT_SAVE_RESTORE;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "block_start" ) )
|
||||
{
|
||||
pStructMem->m_nOutType = SOS_OUT_BLOCK_START;
|
||||
}
|
||||
else if (!V_strcasecmp(pValueString, "phonon_xfade"))
|
||||
{
|
||||
pStructMem->m_nOutType = SOS_OUT_PHONON_XFADE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
52
engine/audio/private/snd_op_sys/sos_op_output.h
Normal file
52
engine/audio/private/snd_op_sys/sos_op_output.h
Normal file
@@ -0,0 +1,52 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_OUTPUT_H
|
||||
#define SOS_OP_OUTPUT_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
enum SOSOutputType_t
|
||||
{
|
||||
SOS_OUT_NONE = 0,
|
||||
SOS_OUT_VOLUME,
|
||||
SOS_OUT_DSP,
|
||||
SOS_OUT_POSITION,
|
||||
SOS_OUT_SPEAKERS,
|
||||
SOS_OUT_FACING,
|
||||
SOS_OUT_DISTVAR,
|
||||
SOS_OUT_PITCH,
|
||||
SOS_OUT_DELAY,
|
||||
SOS_OUT_STOPHOLD,
|
||||
SOS_OUT_MIXLAYER_TRIGGER,
|
||||
SOS_OUT_SAVE_RESTORE,
|
||||
SOS_OUT_BLOCK_START,
|
||||
SOS_OUT_PHONON_XFADE,
|
||||
};
|
||||
struct CSosOperatorOutput_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInputFloat, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputVec3, SO_VEC3 )
|
||||
SOS_INPUT_FLOAT( m_flInputSpeakers, SO_SPEAKERS )
|
||||
|
||||
SOSOutputType_t m_nOutType;
|
||||
};
|
||||
|
||||
class CSosOperatorOutput : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorOutput )
|
||||
};
|
||||
|
||||
|
||||
#endif // SOS_OP_OUTPUT_H
|
||||
107
engine/audio/private/snd_op_sys/sos_op_platform.cpp
Normal file
107
engine/audio/private/snd_op_sys/sos_op_platform.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_platform.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorPlatform
|
||||
// Setting a single, simple scratch pad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorPlatform, "sys_platform" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorPlatform, m_flOutput, SO_SINGLE, "output" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorPlatform, "sys_platform" )
|
||||
|
||||
void CSosOperatorPlatform::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorPlatform_t *pStructMem = (CSosOperatorPlatform_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutput, SO_SINGLE, 0.0 )
|
||||
}
|
||||
|
||||
void CSosOperatorPlatform::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
// CSosOperatorPlatform_t *pStructMem = (CSosOperatorPlatform_t *)pVoidMem;
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorPlatform::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorPlatform_t *pStructMem = (CSosOperatorPlatform_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
}
|
||||
void CSosOperatorPlatform::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorPlatform::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
extern IVEngineClient *engineClient;
|
||||
CSosOperatorPlatform_t *pStructMem = (CSosOperatorPlatform_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ))
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "pc" ) )
|
||||
{
|
||||
if( IsPC( ) )
|
||||
{
|
||||
pStructMem->m_flOutput[0] = 1.0;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "x360" ) )
|
||||
{
|
||||
if( IsX360( ) )
|
||||
{
|
||||
pStructMem->m_flOutput[0] = 1.0;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "ps3" ) )
|
||||
{
|
||||
if( IsPS3( ) )
|
||||
{
|
||||
pStructMem->m_flOutput[0] = 1.0;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "osx" ) )
|
||||
{
|
||||
if( IsOSX( ) )
|
||||
{
|
||||
pStructMem->m_flOutput[0] = 1.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
31
engine/audio/private/snd_op_sys/sos_op_platform.h
Normal file
31
engine/audio/private/snd_op_sys/sos_op_platform.h
Normal file
@@ -0,0 +1,31 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_PLATFORM_H
|
||||
#define SOS_OP_PLATFORM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// mapname
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorPlatform_t : CSosOperator_t
|
||||
{
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SINGLE )
|
||||
|
||||
};
|
||||
class CSosOperatorPlatform : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorPlatform )
|
||||
|
||||
};
|
||||
|
||||
#endif // SOS_OP_PLATFORM_H
|
||||
190
engine/audio/private/snd_op_sys/sos_op_player_info.cpp
Normal file
190
engine/audio/private/snd_op_sys/sos_op_player_info.cpp
Normal file
@@ -0,0 +1,190 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
#include "client.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_player_info.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
// ConVar snd_sos_show_source_info("snd_sos_show_source_info", "0" );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorViewInfo
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorViewInfo, "game_view_info" )
|
||||
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorViewInfo, m_flOutPosition, SO_VEC3, "output_position" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorViewInfo, m_flOutPosition_x, SO_SINGLE, "output_position_x" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorViewInfo, m_flOutPosition_y, SO_SINGLE, "output_position_y" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorViewInfo, m_flOutPosition_z, SO_SINGLE, "output_position_z" );
|
||||
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorViewInfo, m_flOutAngles, SO_VEC3, "output_angles" );
|
||||
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorViewInfo, m_flOutVelocityVector, SO_VEC3, "output_velocity_vector" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorViewInfo, m_flOutVelocityVector_x, SO_SINGLE, "output_velocity_vector_x" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorViewInfo, m_flOutVelocityVector_y, SO_SINGLE, "output_velocity_vector_y" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorViewInfo, m_flOutVelocityVector_z, SO_SINGLE, "output_velocity_vector_z" );
|
||||
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorViewInfo, m_flOutVelocity, SO_FLOAT, "output_velocity" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorViewInfo, m_flOutVelocityXY, SO_FLOAT, "output_velocity_xy" );
|
||||
|
||||
// SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorViewInfo, m_flOutSourceCount, SO_SINGLE, "output_source_count" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorViewInfo, m_flInputSourceIndex, SO_SINGLE, "input_source_index" );
|
||||
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorViewInfo, "game_view_info" )
|
||||
|
||||
|
||||
void CSosOperatorViewInfo::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorViewInfo_t *pStructMem = (CSosOperatorViewInfo_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutPosition, SO_VEC3, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutPosition_x, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutPosition_y, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutPosition_z, SO_SINGLE, 0.0 )
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutVelocityVector, SO_VEC3, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutVelocityVector_x, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutVelocityVector_y, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutVelocityVector_z, SO_SINGLE, 0.0 )
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutVelocity, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutVelocityXY, SO_SINGLE, 0.0 )
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutAngles, SO_VEC3, 0.0 )
|
||||
|
||||
// not yet fully supporting splitscreen in operators
|
||||
// SOS_INIT_OUTPUT_VAR( m_flOutSourceCount, SO_SINGLE, 1.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputSourceIndex, SO_SINGLE, 0.0 )
|
||||
|
||||
pStructMem->m_vecPrevPosition.Init();
|
||||
pStructMem->m_flPrevTime = g_pSoundServices->GetHostTime();
|
||||
}
|
||||
|
||||
void CSosOperatorViewInfo::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
#ifndef DEDICATED
|
||||
CSosOperatorViewInfo_t *pStructMem = (CSosOperatorViewInfo_t *)pVoidMem;
|
||||
|
||||
// for future use with splitscreen
|
||||
int nCurIndex = (int) pStructMem->m_flInputSourceIndex[0];
|
||||
if( nCurIndex > MAX_SPLITSCREEN_CLIENTS -1 )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: %s, input_source_index %i is greater than MAX_SPLITSCREEN_CLIENTS, clamped\n", pStack->GetOperatorName( nOpIndex ), nCurIndex );
|
||||
nCurIndex = MAX_SPLITSCREEN_CLIENTS -1;
|
||||
}
|
||||
else if ( nCurIndex < 0 )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: %s, input_source_index %i is invalid, clamped\n", pStack->GetOperatorName( nOpIndex ), nCurIndex );
|
||||
nCurIndex = 0;
|
||||
}
|
||||
|
||||
// first frame init position to avoid, erroneous deltas, zero is best option
|
||||
if( pStructMem->m_flPrevTime == 0.0 )
|
||||
{
|
||||
VectorCopy( ( pScratchPad->m_vPlayerOrigin[ nCurIndex ]), pStructMem->m_vecPrevPosition );
|
||||
}
|
||||
|
||||
// calculate delta time for this operator updates
|
||||
float flCurTime = g_ClientGlobalVariables.curtime;
|
||||
float flDeltaTime = flCurTime - pStructMem->m_flPrevTime;
|
||||
pStructMem->m_flPrevTime = flCurTime;
|
||||
|
||||
if( flDeltaTime > 0.0 )
|
||||
{
|
||||
|
||||
// per/sec factor
|
||||
float flPerSec = 1.0 / flDeltaTime;
|
||||
|
||||
pStructMem->m_flOutPosition[0] = ( pScratchPad->m_vPlayerOrigin[ nCurIndex ] )[0];
|
||||
pStructMem->m_flOutPosition[1] = ( pScratchPad->m_vPlayerOrigin[ nCurIndex ] )[1];
|
||||
pStructMem->m_flOutPosition[2] = ( pScratchPad->m_vPlayerOrigin[ nCurIndex ] )[2];
|
||||
|
||||
// this is temporary for accessing single elements in array, will be a [] "feature" later when there's time
|
||||
pStructMem->m_flOutPosition_x[0] = pStructMem->m_flOutPosition[0];
|
||||
pStructMem->m_flOutPosition_y[0] = pStructMem->m_flOutPosition[1];
|
||||
pStructMem->m_flOutPosition_z[0] = pStructMem->m_flOutPosition[2];
|
||||
|
||||
// get raw velocity vector
|
||||
Vector vPositionDelta;
|
||||
vPositionDelta[0] = pStructMem->m_flOutPosition[0] - pStructMem->m_vecPrevPosition[0];
|
||||
vPositionDelta[1] = pStructMem->m_flOutPosition[1] - pStructMem->m_vecPrevPosition[1];
|
||||
vPositionDelta[2] = pStructMem->m_flOutPosition[2] - pStructMem->m_vecPrevPosition[2];
|
||||
|
||||
// scale vector to per/sec
|
||||
Vector vVelocity = vPositionDelta * flPerSec;
|
||||
pStructMem->m_flOutVelocityVector[0] = vVelocity[0];
|
||||
pStructMem->m_flOutVelocityVector[1] = vVelocity[1];
|
||||
pStructMem->m_flOutVelocityVector[2] = vVelocity[2];
|
||||
|
||||
// this is temporary for accessing single elements in array, will be a "feature" later when there's time
|
||||
pStructMem->m_flOutVelocityVector_x[0] = pStructMem->m_flOutVelocityVector[0];
|
||||
pStructMem->m_flOutVelocityVector_y[0] = pStructMem->m_flOutVelocityVector[1];
|
||||
pStructMem->m_flOutVelocityVector_z[0] = pStructMem->m_flOutVelocityVector[2];
|
||||
|
||||
pStructMem->m_flOutVelocity[0] = vVelocity.Length();
|
||||
|
||||
pStructMem->m_flOutVelocityXY[0] = vVelocity.Length2D();
|
||||
|
||||
VectorCopy( ( pScratchPad->m_vPlayerOrigin[ nCurIndex ] ), pStructMem->m_vecPrevPosition );
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CSosOperatorViewInfo::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorViewInfo_t *pStructMem = (CSosOperatorViewInfo_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
}
|
||||
|
||||
void CSosOperatorViewInfo::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorViewInfo::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorViewInfo_t *pStructMem = (CSosOperatorViewInfo_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
50
engine/audio/private/snd_op_sys/sos_op_player_info.h
Normal file
50
engine/audio/private/snd_op_sys/sos_op_player_info.h
Normal file
@@ -0,0 +1,50 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_PLAYER_INFO_H
|
||||
#define SOS_OP_PLAYER_INFO_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// simple operator for setting a single position
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorViewInfo_t : CSosOperator_t
|
||||
{
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutPosition, SO_VEC3 )
|
||||
SOS_OUTPUT_FLOAT( m_flOutPosition_x, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutPosition_y, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutPosition_z, SO_SINGLE )
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutAngles, SO_VEC3 )
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutVelocity, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutVelocityVector, SO_VEC3 )
|
||||
|
||||
SOS_OUTPUT_FLOAT( m_flOutVelocityVector_x, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutVelocityVector_y, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutVelocityVector_z, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutVelocityXY, SO_SINGLE )
|
||||
|
||||
// for splitscreen players, once it's actually in use
|
||||
SOS_OUTPUT_FLOAT( m_flOutSourceCount, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputSourceIndex, SO_SINGLE )
|
||||
|
||||
float m_flPrevTime;
|
||||
Vector m_vecPrevPosition;
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorViewInfo : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorViewInfo )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_PLAYER_INFO_H
|
||||
149
engine/audio/private/snd_op_sys/sos_op_pos_vec8.cpp
Normal file
149
engine/audio/private/snd_op_sys/sos_op_pos_vec8.cpp
Normal file
@@ -0,0 +1,149 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_pos_vec8.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorPosVec8
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorPosVec8, "util_pos_vec8" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorPosVec8, m_flOutPosition, SO_VEC3, "output_position" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorPosVec8, m_flOutMaxIndex, SO_SINGLE, "output_max_index" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorPosVec8, m_flInputIndex, SO_SINGLE, "input_index" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorPosVec8, m_flInputEntryCount, SO_SINGLE, "input_entry_count" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorPosVec8, m_flInputPos0, SO_VEC3, "input_position_0" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorPosVec8, m_flInputPos1, SO_VEC3, "input_position_1" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorPosVec8, m_flInputPos2, SO_VEC3, "input_position_2" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorPosVec8, m_flInputPos3, SO_VEC3, "input_position_3" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorPosVec8, m_flInputPos4, SO_VEC3, "input_position_4" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorPosVec8, m_flInputPos5, SO_VEC3, "input_position_5" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorPosVec8, m_flInputPos6, SO_VEC3, "input_position_6" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorPosVec8, m_flInputPos7, SO_VEC3, "input_position_7" );
|
||||
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorPosVec8, "util_pos_vec8" )
|
||||
|
||||
void CSosOperatorPosVec8::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorPosVec8_t *pStructMem = (CSosOperatorPosVec8_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutPosition, SO_VEC3, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutMaxIndex, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputEntryCount, SO_SINGLE, 1.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputIndex, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputPos0, SO_VEC3, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputPos1, SO_VEC3, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputPos2, SO_VEC3, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputPos3, SO_VEC3, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputPos4, SO_VEC3, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputPos5, SO_VEC3, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputPos6, SO_VEC3, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputPos7, SO_VEC3, 0.0 )
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorPosVec8::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorPosVec8_t *pStructMem = (CSosOperatorPosVec8_t *)pVoidMem;
|
||||
|
||||
int nIndex = (int)pStructMem->m_flInputIndex[0];
|
||||
int nEntryCount = pStructMem->m_flInputEntryCount[0];
|
||||
nIndex = ( nIndex >= nEntryCount ) ? nEntryCount - 1 : nIndex;
|
||||
nIndex = ( nIndex < 0 ) ? 0 : nIndex;
|
||||
|
||||
float *pIndexedPos = pStructMem->m_flInputPos0;
|
||||
|
||||
switch( nIndex )
|
||||
{
|
||||
case 0:
|
||||
pIndexedPos = pStructMem->m_flInputPos0;
|
||||
break;
|
||||
case 1:
|
||||
pIndexedPos = pStructMem->m_flInputPos1;
|
||||
break;
|
||||
case 2:
|
||||
pIndexedPos = pStructMem->m_flInputPos2;
|
||||
break;
|
||||
case 3:
|
||||
pIndexedPos = pStructMem->m_flInputPos3;
|
||||
break;
|
||||
case 4:
|
||||
pIndexedPos = pStructMem->m_flInputPos4;
|
||||
break;
|
||||
case 5:
|
||||
pIndexedPos = pStructMem->m_flInputPos5;
|
||||
break;
|
||||
case 6:
|
||||
pIndexedPos = pStructMem->m_flInputPos6;
|
||||
break;
|
||||
case 7:
|
||||
pIndexedPos = pStructMem->m_flInputPos7;
|
||||
break;
|
||||
}
|
||||
|
||||
pStructMem->m_flOutPosition[0] = pIndexedPos[0];
|
||||
pStructMem->m_flOutPosition[1] = pIndexedPos[1];
|
||||
pStructMem->m_flOutPosition[2] = pIndexedPos[2];
|
||||
|
||||
pStructMem->m_flOutMaxIndex[0] = pStructMem->m_flInputEntryCount[0] - 1.0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CSosOperatorPosVec8::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorPosVec8_t *pStructMem = (CSosOperatorPosVec8_t *)pVoidMem;
|
||||
NOTE_UNUSED( pStructMem );
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
|
||||
}
|
||||
void CSosOperatorPosVec8::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorPosVec8::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorPosVec8_t *pStructMem = (CSosOperatorPosVec8_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
41
engine/audio/private/snd_op_sys/sos_op_pos_vec8.h
Normal file
41
engine/audio/private/snd_op_sys/sos_op_pos_vec8.h
Normal file
@@ -0,0 +1,41 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_POS_VEC8_H
|
||||
#define SOS_OP_POS_VEC8_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// simple operator for setting a single position
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorPosVec8_t : CSosOperator_t
|
||||
{
|
||||
SOS_OUTPUT_FLOAT( m_flOutPosition, SO_VEC3 )
|
||||
SOS_OUTPUT_FLOAT( m_flOutMaxIndex, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputIndex, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputEntryCount, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputPos0, SO_VEC3 )
|
||||
SOS_INPUT_FLOAT( m_flInputPos1, SO_VEC3 )
|
||||
SOS_INPUT_FLOAT( m_flInputPos2, SO_VEC3 )
|
||||
SOS_INPUT_FLOAT( m_flInputPos3, SO_VEC3 )
|
||||
SOS_INPUT_FLOAT( m_flInputPos4, SO_VEC3 )
|
||||
SOS_INPUT_FLOAT( m_flInputPos5, SO_VEC3 )
|
||||
SOS_INPUT_FLOAT( m_flInputPos6, SO_VEC3 )
|
||||
SOS_INPUT_FLOAT( m_flInputPos7, SO_VEC3 )
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorPosVec8 : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorPosVec8 )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_POS_VEC8_H
|
||||
336
engine/audio/private/snd_op_sys/sos_op_source_info.cpp
Normal file
336
engine/audio/private/snd_op_sys/sos_op_source_info.cpp
Normal file
@@ -0,0 +1,336 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_source_info.h"
|
||||
|
||||
#include "snd_dma.h"
|
||||
#include "soundinfo.h"
|
||||
#include "cdll_engine_int.h"
|
||||
#include "../../debugoverlay.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
ConVar snd_sos_show_source_info("snd_sos_show_source_info", "0" );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorSourceInfo
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorSourceInfo, "get_source_info" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorSourceInfo, m_flOutEntityIndex, SO_SINGLE, "output_entity_index" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorSourceInfo, m_flOutPosition, SO_VEC3, "output_position" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorSourceInfo, m_flOutAngles, SO_VEC3, "output_angles" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorSourceInfo, m_flOutRadius, SO_SINGLE, "output_radius" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorSourceInfo, m_flOutVolume, SO_SINGLE, "output_volume" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorSourceInfo, m_flOutLevel, SO_SINGLE, "output_level" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorSourceInfo, m_flOutPitch, SO_SINGLE, "output_pitch" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorSourceInfo, m_flOutSourceCount, SO_SINGLE, "output_source_count" );
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorSourceInfo, m_flInputSourceIndex, SO_SINGLE, "input_source_index" );
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorSourceInfo, "get_source_info" )
|
||||
|
||||
void CSosOperatorSourceInfo::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorSourceInfo_t *pStructMem = (CSosOperatorSourceInfo_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutEntityIndex, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutPosition, SO_VEC3, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutAngles, SO_VEC3, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutRadius, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutVolume, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutLevel, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutPitch, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutSourceCount, SO_SINGLE, 1.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputSourceIndex, SO_SINGLE, 0.0 )
|
||||
pStructMem->m_nSource = SO_SRC_EMITTER;
|
||||
pStructMem->m_bGameExtraOrigins = true;
|
||||
}
|
||||
|
||||
void CSosOperatorSourceInfo::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorSourceInfo_t *pStructMem = (CSosOperatorSourceInfo_t *)pVoidMem;
|
||||
|
||||
bool bUseEntity = ( pStructMem->m_nSource == SO_SRC_ENTITY );
|
||||
|
||||
int nSourceCount = pScratchPad->m_UtlVecMultiOrigins.Count();
|
||||
|
||||
// have we gotten our sources yet?
|
||||
if( nSourceCount < 1 )
|
||||
{
|
||||
|
||||
// update channel's position in case ent that made the sound is moving.
|
||||
QAngle source_angles;
|
||||
source_angles.Init(0.0, 0.0, 0.0);
|
||||
|
||||
// default entity to emitter in case there is no entity available
|
||||
int nSoundSource = pScratchPad->m_nSoundSource;
|
||||
int nEntChannel = pScratchPad->m_nChannel;
|
||||
const char *pSoundName = pScratchPad->m_emitterInfoSoundName;
|
||||
Vector vOrigin = pScratchPad->m_vEmitterInfoOrigin;
|
||||
Vector vDirection = pScratchPad->m_vEmitterInfoDirection;
|
||||
short nMasterVolume = (short) pScratchPad->m_flEmitterInfoMasterVolume * 255;
|
||||
soundlevel_t nSoundLevel = pScratchPad->m_vEmitterInfoSoundLevel;
|
||||
bool bIsLooping = pScratchPad->m_bIsLooping;
|
||||
float flPitch = pScratchPad->m_bIsLooping;
|
||||
int nSpeakerEntity = pScratchPad->m_nEmitterInfoSpeakerEntity;
|
||||
|
||||
Vector vListenerOrigin = pScratchPad->m_vBlendedListenerOrigin; // HACK FOR SPLITSCREEN, only client\c_func_tracktrain.cpp(100): CalcClosestPointOnLine( info.info.vListenerOrigin, vecStart, vecEnd, *info.pOrigin, &t ); every looked at listener origin in this structure...
|
||||
|
||||
Vector vEntOrigin = vOrigin;
|
||||
float flRadius = 0.0;
|
||||
|
||||
SpatializationInfo_t si;
|
||||
|
||||
si.info.Set(
|
||||
nSoundSource,
|
||||
nEntChannel,
|
||||
pSoundName,
|
||||
vOrigin,
|
||||
vDirection,
|
||||
nMasterVolume,
|
||||
nSoundLevel,
|
||||
bIsLooping,
|
||||
flPitch,
|
||||
vListenerOrigin,
|
||||
nSpeakerEntity,
|
||||
0 ); // FIX SEEDING?
|
||||
|
||||
si.type = SpatializationInfo_t::SI_INSPATIALIZATION;
|
||||
si.pOrigin = &vEntOrigin;
|
||||
si.pAngles = &source_angles;
|
||||
si.pflRadius = &flRadius;
|
||||
|
||||
CUtlVector< Vector > utlVecMultiOrigins;
|
||||
si.m_pUtlVecMultiOrigins = &pScratchPad->m_UtlVecMultiOrigins;
|
||||
|
||||
CUtlVector< Vector > utlVecMultiAngles;
|
||||
// si.m_pUtlVecMultiAngles = &pScratchPad->m_UtlVecMultiAngles;
|
||||
|
||||
// TODO: morasky, verify it's been handled
|
||||
// if ( pChannel->soundsource != 0 && pChannel->radius == 0 )
|
||||
// {
|
||||
// si.pflRadius = &pChannel->radius;
|
||||
// }
|
||||
|
||||
// this returns the position of the entity in vEntOrigin
|
||||
//VPROF_("SoundServices->GetSoundSpatializtion", 2, VPROF_BUDGETGROUP_OTHER_SOUND, false, BUDGETFLAG_OTHER );
|
||||
bUseEntity &= g_pSoundServices->GetSoundSpatialization( nSoundSource, si );
|
||||
|
||||
|
||||
if( !bUseEntity )
|
||||
{
|
||||
si.pOrigin = &si.info.vOrigin;
|
||||
}
|
||||
|
||||
#ifndef DEDICATED
|
||||
// extra, non-entity related, game specific processing (portal2, multi-source, etc.)
|
||||
if( pStructMem->m_bGameExtraOrigins )
|
||||
{
|
||||
g_ClientDLL->GetSoundSpatialization( si );
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: morasky, verify it's been handled
|
||||
// // just about pChannel->direction?!
|
||||
// // if ( pChannel->flags.bUpdatePositions )
|
||||
// {
|
||||
// // angles -> forward vector
|
||||
// AngleVectors( source_angles, &pChannel->direction );
|
||||
// //XXX pChannel->origin = vEntOrigin;
|
||||
// }
|
||||
// // else
|
||||
// {
|
||||
// // vector -> angles
|
||||
// VectorAngles( pChannel->direction, source_angles );
|
||||
// }
|
||||
|
||||
// ???
|
||||
// if ( IsPC() && pChannel->userdata != 0 )
|
||||
// {
|
||||
// g_pSoundServices->GetToolSpatialization( pChannel->userdata, pChannel->guid, si );
|
||||
// if ( pChannel->flags.bUpdatePositions )
|
||||
// {
|
||||
// AngleVectors( source_angles, &pChannel->direction );
|
||||
// //XXX pChannel->origin = vEntOrigin;
|
||||
// }
|
||||
// }
|
||||
|
||||
pScratchPad->m_vEntityInfoAngle = source_angles;
|
||||
pScratchPad->m_vEntityInfoOrigin = vEntOrigin;
|
||||
pScratchPad->m_flEntityInfoRadius = flRadius;
|
||||
|
||||
}
|
||||
|
||||
nSourceCount = pScratchPad->m_UtlVecMultiOrigins.Count();
|
||||
pStructMem->m_flOutSourceCount[0] = (float) nSourceCount;
|
||||
|
||||
|
||||
int nCurIndex = (int) pStructMem->m_flInputSourceIndex[0];
|
||||
// BIG ERROR CHECK HERE!
|
||||
|
||||
|
||||
if ( nCurIndex == 0 )
|
||||
{
|
||||
if ( pStructMem->m_nSource == SO_SRC_ENTITY )
|
||||
{
|
||||
pStructMem->m_flOutPosition[0] = pScratchPad->m_vEntityInfoOrigin[0];
|
||||
pStructMem->m_flOutPosition[1] = pScratchPad->m_vEntityInfoOrigin[1];
|
||||
pStructMem->m_flOutPosition[2] = pScratchPad->m_vEntityInfoOrigin[2];
|
||||
|
||||
pStructMem->m_flOutAngles[0] = pScratchPad->m_vEntityInfoAngle[0];
|
||||
pStructMem->m_flOutAngles[1] = pScratchPad->m_vEntityInfoAngle[1];
|
||||
pStructMem->m_flOutAngles[2] = pScratchPad->m_vEntityInfoAngle[2];
|
||||
|
||||
pStructMem->m_flOutRadius[0] = pScratchPad->m_flEntityInfoRadius;
|
||||
}
|
||||
else if ( pStructMem->m_nSource == SO_SRC_EMITTER )
|
||||
{
|
||||
pStructMem->m_flOutPosition[0] = pScratchPad->m_vEmitterInfoOrigin[0];
|
||||
pStructMem->m_flOutPosition[1] = pScratchPad->m_vEmitterInfoOrigin[1];
|
||||
pStructMem->m_flOutPosition[2] = pScratchPad->m_vEmitterInfoOrigin[2];
|
||||
|
||||
QAngle source_angles;
|
||||
VectorAngles( pScratchPad->m_vEmitterInfoDirection, source_angles );
|
||||
pStructMem->m_flOutAngles[0] = source_angles[0];
|
||||
pStructMem->m_flOutAngles[1] = source_angles[1];
|
||||
pStructMem->m_flOutAngles[2] = source_angles[2];
|
||||
|
||||
pStructMem->m_flOutRadius[0] = pScratchPad->m_nEmitterInfoRadius;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
pStructMem->m_flOutPosition[0] = pScratchPad->m_UtlVecMultiOrigins[nCurIndex - 1][0];
|
||||
pStructMem->m_flOutPosition[1] = pScratchPad->m_UtlVecMultiOrigins[nCurIndex - 1][1];
|
||||
pStructMem->m_flOutPosition[2] = pScratchPad->m_UtlVecMultiOrigins[nCurIndex - 1][2];
|
||||
|
||||
// pStructMem->m_flOutAngles[0] = pScratchPad->m_vEntityInfoAngle[0];
|
||||
// pStructMem->m_flOutAngles[1] = pScratchPad->m_vEntityInfoAngle[1];
|
||||
// pStructMem->m_flOutAngles[2] = pScratchPad->m_vEntityInfoAngle[2];
|
||||
|
||||
// pStructMem->m_flOutRadius[0] = pScratchPad->m_flEntityInfoRadius;
|
||||
|
||||
}
|
||||
pStructMem->m_flOutVolume[0] = pScratchPad->m_flEmitterInfoMasterVolume;
|
||||
pStructMem->m_flOutLevel[0] = pScratchPad->m_vEmitterInfoSoundLevel;
|
||||
pStructMem->m_flOutPitch[0] = pScratchPad->m_flEmitterInfoPitch;
|
||||
pStructMem->m_flOutEntityIndex[0] = (float) pScratchPad->m_nSoundSource;
|
||||
|
||||
|
||||
#ifndef DEDICATED
|
||||
if( snd_sos_show_source_info.GetInt() )
|
||||
{
|
||||
Vector vDebug;
|
||||
vDebug[0] = pStructMem->m_flOutPosition[0];
|
||||
vDebug[1] = pStructMem->m_flOutPosition[1];
|
||||
vDebug[2] = pStructMem->m_flOutPosition[2];
|
||||
CDebugOverlay::AddTextOverlay( vDebug, 2.0f, g_pSoundEmitterSystem->GetSoundNameForHash( pStack->GetScriptHash() ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CSosOperatorSourceInfo::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorSourceInfo_t *pStructMem = (CSosOperatorSourceInfo_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
|
||||
switch( pStructMem->m_nSource )
|
||||
{
|
||||
case SO_SRC_EMITTER:
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sSource: emitter\n", nLevel, " " );
|
||||
break;
|
||||
case SO_SRC_ENTITY:
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sSource: entity\n", nLevel, " " );
|
||||
break;
|
||||
}
|
||||
}
|
||||
void CSosOperatorSourceInfo::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorSourceInfo::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorSourceInfo_t *pStructMem = (CSosOperatorSourceInfo_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "source" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "none" ) )
|
||||
{
|
||||
pStructMem->m_nSource = SO_SRC_NONE;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "emitter" ) )
|
||||
{
|
||||
pStructMem->m_nSource = SO_SRC_EMITTER;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "entity" ) )
|
||||
{
|
||||
pStructMem->m_nSource = SO_SRC_ENTITY;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "game_multi_origin" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bGameExtraOrigins = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bGameExtraOrigins = false;
|
||||
}
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// S_GetFloatFromString( pStructMem->m_vValues, pValueString, SO_POSITION_ARRAY_SIZE );
|
||||
// }
|
||||
// else if ( !V_strcasecmp( pParamString, "xpos" ) )
|
||||
// {
|
||||
// pStructMem->m_vValues[XPOSITION] = RandomInterval( ReadInterval( pValueString ) );
|
||||
// }
|
||||
// else if ( !V_strcasecmp( pParamString, "ypos" ) )
|
||||
// {
|
||||
// pStructMem->m_vValues[YPOSITION] = RandomInterval( ReadInterval( pValueString ) );
|
||||
// }
|
||||
// else if ( !V_strcasecmp( pParamString, "zpos" ) )
|
||||
// {
|
||||
// pStructMem->m_vValues[ZPOSITION] = RandomInterval( ReadInterval( pValueString ) );
|
||||
// }
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
46
engine/audio/private/snd_op_sys/sos_op_source_info.h
Normal file
46
engine/audio/private/snd_op_sys/sos_op_source_info.h
Normal file
@@ -0,0 +1,46 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_SOURCE_INFO_H
|
||||
#define SOS_OP_SOURCE_INFO_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
enum SOValueSource_t
|
||||
{
|
||||
SO_SRC_NONE = 0,
|
||||
SO_SRC_EMITTER,
|
||||
SO_SRC_ENTITY
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// simple operator for setting a single position
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorSourceInfo_t : CSosOperator_t
|
||||
{
|
||||
SOS_OUTPUT_FLOAT( m_flOutEntityIndex, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutPosition, SO_VEC3 )
|
||||
SOS_OUTPUT_FLOAT( m_flOutAngles, SO_VEC3 )
|
||||
SOS_OUTPUT_FLOAT( m_flOutRadius, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutVolume, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutLevel, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutPitch, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutSourceCount, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputSourceIndex, SO_SINGLE )
|
||||
|
||||
SOValueSource_t m_nSource;
|
||||
bool m_bGameExtraOrigins;
|
||||
};
|
||||
|
||||
class CSosOperatorSourceInfo : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorSourceInfo )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_SOURCE_INFO_H
|
||||
194
engine/audio/private/snd_op_sys/sos_op_spatialize.cpp
Normal file
194
engine/audio/private/snd_op_sys/sos_op_spatialize.cpp
Normal file
@@ -0,0 +1,194 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_spatialize.h"
|
||||
|
||||
#include "snd_dma.h"
|
||||
#include "../../cl_splitscreen.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorSpatializeSpeakers
|
||||
// Setting a single, simple scratch pad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorSpatializeSpeakers, "calc_spatialize_speakers" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorSpatializeSpeakers, m_flOutput, SO_SPEAKERS, "output" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorSpatializeSpeakers, m_flInputRadiusMax, SO_SINGLE, "input_radius_max" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorSpatializeSpeakers, m_flInputRadiusMin, SO_SINGLE, "input_radius_min" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorSpatializeSpeakers, m_flInputTimeStartStereoSpread, SO_SINGLE, "input_time_start_stereo_spread")
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorSpatializeSpeakers, m_flInputTimeFinishStereoSpread, SO_SINGLE, "input_time_finish_stereo_spread")
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorSpatializeSpeakers, m_flInputFinalStereoSpread, SO_SINGLE, "input_final_stereo_spread")
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorSpatializeSpeakers, m_flInputRearStereoScale, SO_SINGLE, "input_rear_stereo_scale" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorSpatializeSpeakers, m_flInputDistance, SO_SINGLE, "input_distance" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorSpatializeSpeakers, m_flInputPosition, SO_VEC3, "input_position" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorSpatializeSpeakers, "calc_spatialize_speakers" )
|
||||
|
||||
void CSosOperatorSpatializeSpeakers::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorSpatializeSpeakers_t *pStructMem = (CSosOperatorSpatializeSpeakers_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flInputRadiusMax, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputRadiusMin, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputTimeStartStereoSpread, SO_SINGLE, 0.0)
|
||||
SOS_INIT_INPUT_VAR( m_flInputTimeFinishStereoSpread, SO_SINGLE, 0.0)
|
||||
SOS_INIT_INPUT_VAR( m_flInputFinalStereoSpread, SO_SINGLE, 0.0)
|
||||
SOS_INIT_INPUT_VAR( m_flInputRearStereoScale, SO_SINGLE, 0.75 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputDistance, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputPosition, SO_VEC3, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutput, SO_SPEAKERS, 0.0 )
|
||||
}
|
||||
|
||||
void CSosOperatorSpatializeSpeakers::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorSpatializeSpeakers_t *pStructMem = (CSosOperatorSpatializeSpeakers_t *)pVoidMem;
|
||||
|
||||
float flRadius = pStructMem->m_flInputRadiusMax[0];
|
||||
float flRadiusMin = pStructMem->m_flInputRadiusMin[0];
|
||||
float flDist = pStructMem->m_flInputDistance[0];
|
||||
float flRearStereoScale = pStructMem->m_flInputRearStereoScale[0];
|
||||
|
||||
flRadius = flRadius > 0.0 ? flRadius : 0.0;
|
||||
flRadiusMin = flRadiusMin > 0.0 ? flRadiusMin : 0.0;
|
||||
flRadiusMin = flRadiusMin < flRadius ? flRadiusMin : flRadius;
|
||||
|
||||
float flMono = 0.0;
|
||||
if ( flDist <= flRadiusMin )
|
||||
{
|
||||
flMono = 1.0;
|
||||
}
|
||||
else if ( flDist >= flRadius )
|
||||
{
|
||||
flMono = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
flMono = ((flDist - flRadiusMin) / ( flRadius - flRadiusMin ));
|
||||
}
|
||||
|
||||
if (flDist > flRadiusMin && pStructMem->m_flInputTimeStartStereoSpread[0] != pStructMem->m_flInputTimeFinishStereoSpread[0])
|
||||
{
|
||||
float flElapsedSpatialized = pStructMem->m_flInputTimeStartStereoSpread[0];
|
||||
float flElapsedMono = pStructMem->m_flInputTimeFinishStereoSpread[0];
|
||||
float flMax = flElapsedMono > flElapsedSpatialized ? flElapsedMono : flElapsedSpatialized;
|
||||
float flMin = flElapsedMono < flElapsedSpatialized ? flElapsedMono : flElapsedSpatialized;
|
||||
float flBeginSpatialized = flElapsedSpatialized >= flElapsedMono ? 0.0f : 1.0f;
|
||||
float flEndSpatialized = 1.0f - flBeginSpatialized * pStructMem->m_flInputFinalStereoSpread[0];
|
||||
|
||||
float flSpatialized = 1.0 - flMono;
|
||||
|
||||
float flElapsed = 0.0f;
|
||||
if (pChannel->sfx && pChannel->sfx->pSource && pChannel->pMixer)
|
||||
{
|
||||
const int nSamples = pChannel->sfx->pSource->SampleCount();
|
||||
const int nPos = pChannel->pMixer->GetSamplePosition();
|
||||
|
||||
if (nSamples > 0)
|
||||
{
|
||||
flElapsed = float(nPos) / float(nSamples);
|
||||
}
|
||||
}
|
||||
|
||||
if (flElapsed <= flMin)
|
||||
{
|
||||
flSpatialized *= flBeginSpatialized;
|
||||
}
|
||||
else if (flElapsed >= flMax)
|
||||
{
|
||||
flSpatialized *= flEndSpatialized;
|
||||
}
|
||||
else
|
||||
{
|
||||
float ratio = (flElapsed - flMin) / (flMax - flMin);
|
||||
flSpatialized *= ratio*flEndSpatialized + (1.0 - ratio)*flBeginSpatialized;
|
||||
}
|
||||
|
||||
flMono = 1.0f - flSpatialized;
|
||||
}
|
||||
|
||||
// if ( flRadius > 0.0 && ( flDist < flRadius ) )
|
||||
// {
|
||||
// float interval = flRadius - flRadiusMin;
|
||||
// flMono = flDist - interval;
|
||||
//
|
||||
// if ( flMono < 0.0 )
|
||||
// flMono = 0.0;
|
||||
//
|
||||
// flMono /= interval;
|
||||
//
|
||||
// // flMono is 0.0 -> 1.0 from radius 100% to radius 50%
|
||||
// flMono = 1.0 - flMono;
|
||||
// }
|
||||
|
||||
// fill out channel volumes for single sound source location
|
||||
Vector vSourceVector;
|
||||
Vector vPosition;
|
||||
vPosition[0] = pStructMem->m_flInputPosition[0];
|
||||
vPosition[1] = pStructMem->m_flInputPosition[1];
|
||||
vPosition[2] = pStructMem->m_flInputPosition[2];
|
||||
|
||||
float build_volumes[ MAX_SPLITSCREEN_CLIENTS ][SO_MAX_SPEAKERS] = { 0.0 };
|
||||
|
||||
// collect up all ss players and merge them here
|
||||
FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh )
|
||||
{
|
||||
VectorSubtract( vPosition, pScratchPad->m_vPlayerOrigin[ hh ], vSourceVector );
|
||||
VectorNormalize( vSourceVector );
|
||||
Device_SpatializeChannel( hh, &build_volumes[hh][0], vSourceVector, flMono, flRearStereoScale );
|
||||
}
|
||||
SND_MergeVolumes( build_volumes, pStructMem->m_flOutput );
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorSpatializeSpeakers::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorSpatializeSpeakers_t *pStructMem = (CSosOperatorSpatializeSpeakers_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
|
||||
}
|
||||
void CSosOperatorSpatializeSpeakers::OpHelp( ) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CSosOperatorSpatializeSpeakers::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorSpatializeSpeakers_t *pStructMem = (CSosOperatorSpatializeSpeakers_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
38
engine/audio/private/snd_op_sys/sos_op_spatialize.h
Normal file
38
engine/audio/private/snd_op_sys/sos_op_spatialize.h
Normal file
@@ -0,0 +1,38 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_SPATIALIZE_H
|
||||
#define SOS_OP_SPATIALIZE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// spatialize a sound in the speakers
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorSpatializeSpeakers_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInputPosition, SO_VEC3 )
|
||||
SOS_INPUT_FLOAT( m_flInputDistance, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputRadiusMax, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputRadiusMin, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputTimeStartStereoSpread, SO_SINGLE)
|
||||
SOS_INPUT_FLOAT( m_flInputTimeFinishStereoSpread, SO_SINGLE)
|
||||
SOS_INPUT_FLOAT( m_flInputFinalStereoSpread, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputRearStereoScale, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutput, SO_SPEAKERS )
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorSpatializeSpeakers : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorSpatializeSpeakers )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_SPATIALIZE_H
|
||||
168
engine/audio/private/snd_op_sys/sos_op_start_entry.cpp
Normal file
168
engine/audio/private/snd_op_sys/sos_op_start_entry.cpp
Normal file
@@ -0,0 +1,168 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_start_entry.h"
|
||||
|
||||
#include "snd_dma.h"
|
||||
// #include "cdll_engine_int.h"
|
||||
#include "../../debugoverlay.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorStartEntry
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorStartEntry, "sys_start_entry" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorStartEntry, m_flInputStart, SO_SINGLE, "input_start")
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorStartEntry, m_flInputStartDelay, SO_SINGLE, "input_start_delay")
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorStartEntry, "sys_start_entry" )
|
||||
|
||||
void CSosOperatorStartEntry::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorStartEntry_t *pStructMem = (CSosOperatorStartEntry_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flInputStart, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputStartDelay, SO_SINGLE, 0.0 )
|
||||
|
||||
pStructMem->m_nScriptHash = SOUNDEMITTER_INVALID_HASH;
|
||||
pStructMem->m_nHasStarted = 0;
|
||||
pStructMem->m_bTriggerOnce = false;
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorStartEntry::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorStartEntry_t *pStructMem = (CSosOperatorStartEntry_t *)pVoidMem;
|
||||
|
||||
if( pStructMem->m_flInputStart[0] > 0.0 && !( pStructMem->m_nHasStarted && pStructMem->m_bTriggerOnce ) )
|
||||
{
|
||||
pStructMem->m_nHasStarted = 1;
|
||||
|
||||
|
||||
if ( !g_pSoundEmitterSystem )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, OpColor, "Error: SoundEmitterSystem not initialized in engine!");
|
||||
return;
|
||||
}
|
||||
|
||||
if( !g_pSoundEmitterSystem->GetSoundNameForHash( pStructMem->m_nScriptHash ) )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, OpColor, "Error: Invalid SoundEntry hash %i in operator %s\n", pStructMem->m_nScriptHash , pStack->GetOperatorName( nOpIndex ));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// try to copy all these from the current channel?
|
||||
// this all needs to GET ORGANIZED, some values should come from params some from channel via?? param switch? use copy methods
|
||||
// also, most of this is redundant in that "startsoundentry" calls this same function
|
||||
// still a bit messy !!
|
||||
StartSoundParams_t startParams;
|
||||
CSoundParameters pScriptParams;
|
||||
gender_t gender = GENDER_NONE;
|
||||
if ( !g_pSoundEmitterSystem->GetParametersForSoundEx( "SoundSciptHandle ERROR", pStructMem->m_nScriptHash, pScriptParams, gender, true ) )
|
||||
{
|
||||
//DevWarning("Error: Unable to get parameters for soundentry %s", startParams.m_pSoundEntryName );
|
||||
return;
|
||||
}
|
||||
|
||||
// don't actually need the soundfile yet
|
||||
|
||||
// if ( !pScriptParams.soundname[0] )
|
||||
// return;
|
||||
|
||||
// copy emitter params
|
||||
startParams.staticsound = ( pScriptParams.channel == CHAN_STATIC ) ? true : false;
|
||||
startParams.entchannel = pScriptParams.channel;
|
||||
|
||||
// inherits location and entity
|
||||
VectorCopy( pScratchPad->m_vEmitterInfoOrigin, startParams.origin );
|
||||
startParams.soundsource = pScratchPad->m_nSoundSource;
|
||||
|
||||
startParams.fvol = pScriptParams.volume;
|
||||
startParams.soundlevel = pScriptParams.soundlevel;
|
||||
// startParams.flags = sound.nFlags;
|
||||
startParams.pitch = pScriptParams.pitch;
|
||||
startParams.fromserver = false;
|
||||
startParams.delay = pScriptParams.delay_msec;
|
||||
// startParams.speakerentity = sound.nSpeakerEntity;
|
||||
//startParams.m_bIsScriptHandle = ( pScriptParams.m_nSoundEntryVersion > 1 );
|
||||
startParams.m_bIsScriptHandle = true;
|
||||
|
||||
startParams.m_nSoundScriptHash = pStructMem->m_nScriptHash;
|
||||
g_pSoundOperatorSystem->QueueStartEntry( startParams, pStructMem->m_flInputStartDelay[0], false );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CSosOperatorStartEntry::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorStartEntry_t *pStructMem = (CSosOperatorStartEntry_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sEntry Script Hash: %i\n", nLevel, " ", pStructMem->m_nScriptHash );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sEntry Name: %s\n", nLevel, " ", g_pSoundEmitterSystem->GetSoundNameForHash( pStructMem->m_nScriptHash ) );
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorStartEntry::OpHelp( ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CSosOperatorStartEntry::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorStartEntry_t *pStructMem = (CSosOperatorStartEntry_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ))
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "entry_name" ) )
|
||||
{
|
||||
if ( !g_pSoundEmitterSystem )
|
||||
{
|
||||
DevWarning("Error: SoundEmitterSystem not initialized in engine!");
|
||||
return;
|
||||
}
|
||||
pStructMem->m_nScriptHash = g_pSoundEmitterSystem->HashSoundName( pValueString );
|
||||
|
||||
if( !g_pSoundEmitterSystem->GetSoundNameForHash( pStructMem->m_nScriptHash ))
|
||||
{
|
||||
// DevMsg( "Error: Invalid SoundEntry index %i from entry %s operator %s", pStructMem->m_nScriptHandle, pValueString, pStack->GetOperatorName( nOpIndex ) );
|
||||
DevMsg( "Error: Invalid SoundEntry hash %i from entry %s", pStructMem->m_nScriptHash, pValueString );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
35
engine/audio/private/snd_op_sys/sos_op_start_entry.h
Normal file
35
engine/audio/private/snd_op_sys/sos_op_start_entry.h
Normal file
@@ -0,0 +1,35 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_START_ENTRY_H
|
||||
#define SOS_OP_START_ENTRY_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorStartEntry_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInputStart, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputStartDelay, SO_SINGLE )
|
||||
HSOUNDSCRIPTHASH m_nScriptHash;
|
||||
int m_nHasStarted;
|
||||
bool m_bTriggerOnce;
|
||||
};
|
||||
|
||||
class CSosOperatorStartEntry : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorStartEntry )
|
||||
};
|
||||
|
||||
|
||||
#endif // SOS_OP_START_ENTRY_H
|
||||
363
engine/audio/private/snd_op_sys/sos_op_stop_entry.cpp
Normal file
363
engine/audio/private/snd_op_sys/sos_op_stop_entry.cpp
Normal file
@@ -0,0 +1,363 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "snd_dma.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_entry_match_system.h"
|
||||
#include "sos_op_stop_entry.h"
|
||||
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
ConVar snd_sos_show_operator_stop_entry("snd_sos_show_operator_stop_entry", "0", FCVAR_CHEAT );
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorStopEntry
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorStopEntry, "sys_stop_entries" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorStopEntry, m_flInputMaxVoices, SO_SINGLE, "input_max_entries" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorStopEntry, m_flInputStopDelay, SO_SINGLE, "input_stop_delay" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorStopEntry, m_flOutputVoicesMatching, SO_SINGLE, "output_entries_matching" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorStopEntry, m_flOutputIndexOfThis, SO_SINGLE, "output_this_matches_index" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorStopEntry, "sys_stop_entries" )
|
||||
|
||||
void CSosOperatorStopEntry::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorStopEntry_t *pStructMem = (CSosOperatorStopEntry_t *)pVoidMem;
|
||||
V_strncpy( pStructMem->m_nMatchEntryName, "", sizeof(pStructMem->m_nMatchEntryName) );
|
||||
V_strncpy( pStructMem->m_nMatchSoundName, "", sizeof(pStructMem->m_nMatchSoundName) );
|
||||
pStructMem->m_bMatchEntry = false;
|
||||
pStructMem->m_bMatchSound = false;
|
||||
pStructMem->m_bMatchEntity = false;
|
||||
pStructMem->m_bMatchChannel = false;
|
||||
pStructMem->m_bMatchSubString = false;
|
||||
pStructMem->m_bStopOldest = true;
|
||||
pStructMem->m_bStopThis = false;
|
||||
pStructMem->m_bMatchThisEntry = false;
|
||||
pStructMem->m_bInvertMatch = false;
|
||||
|
||||
SOS_INIT_INPUT_VAR( m_flInputMaxVoices, SO_SINGLE, 1.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputStopDelay, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputVoicesMatching, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputIndexOfThis, SO_SINGLE, 0.0 )
|
||||
|
||||
}
|
||||
|
||||
static int __cdecl ChannelLongestElapsedTimeSortFunc( const int *nChannelIndexA, const int *nChannelIndexB )
|
||||
{
|
||||
return ( S_GetElapsedTimeByGuid( channels[ *nChannelIndexA ].guid ) > S_GetElapsedTimeByGuid( channels[ *nChannelIndexB ].guid ) );
|
||||
}
|
||||
|
||||
// static int __cdecl ChannelLeastVolumeSortFunc( const int *nChannelIndexA, const int *nChannelIndexB )
|
||||
// {
|
||||
// return ( S_GetElapsedTimeByGuid( channels[ *nChannelIndexA ]. ) < S_GetElapsedTimeByGuid( channels[ *nChannelIndexB ].guid ) );
|
||||
// }
|
||||
|
||||
void CSosOperatorStopEntry::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
|
||||
CSosOperatorStopEntry_t *pStructMem = (CSosOperatorStopEntry_t *)pVoidMem;
|
||||
|
||||
|
||||
if( pStructMem->m_bStopThis )
|
||||
{
|
||||
if( !pChannel )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Sound operator %s requires valid channel pointer, being called without one\n", pStack->GetOperatorName( nOpIndex ));
|
||||
return;
|
||||
}
|
||||
if ( snd_sos_show_operator_stop_entry.GetInt() )
|
||||
{
|
||||
Print( pVoidMem, pStack, nOpIndex, 0 );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sStopping: %s : elapsed time: %f.2\n", 1, " ", g_pSoundEmitterSystem->GetSoundNameForHash( pChannel->m_nSoundScriptHash ), S_GetElapsedTime( pChannel ) * .001 );
|
||||
}
|
||||
g_pSoundOperatorSystem->QueueStopChannel( pChannel->guid, pStructMem->m_flInputStopDelay[0] );
|
||||
return;
|
||||
}
|
||||
|
||||
if( pScratchPad->m_nSoundScriptHash == SOUNDEMITTER_INVALID_HASH &&
|
||||
pStructMem->m_bMatchThisEntry )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Sound operator %s scratchpad has invalid script hash, \"match_this_entry\" set to false\n", pStack->GetOperatorName( nOpIndex ));
|
||||
pStructMem->m_bMatchThisEntry = false;
|
||||
}
|
||||
|
||||
|
||||
CSosEntryMatch sosEntryMatch;
|
||||
sosEntryMatch.m_bMatchString1 = pStructMem->m_bMatchEntry;
|
||||
V_strncpy( sosEntryMatch.m_nMatchString1, pStructMem->m_nMatchEntryName, sizeof( sosEntryMatch.m_nMatchString1 ) );
|
||||
|
||||
sosEntryMatch.m_bMatchString2 = pStructMem->m_bMatchSound;
|
||||
V_strncpy( sosEntryMatch.m_nMatchString2, pStructMem->m_nMatchSoundName, sizeof( sosEntryMatch.m_nMatchString2 ) );
|
||||
|
||||
sosEntryMatch.m_bMatchSubString = pStructMem->m_bMatchSubString;
|
||||
|
||||
sosEntryMatch.m_bMatchInt1 = pStructMem->m_bMatchChannel;
|
||||
sosEntryMatch.m_nMatchInt1 = pScratchPad->m_nChannel;
|
||||
|
||||
sosEntryMatch.m_bMatchInt2 = pStructMem->m_bMatchEntity;
|
||||
sosEntryMatch.m_nMatchInt2 = pScratchPad->m_nSoundSource;
|
||||
|
||||
sosEntryMatch.m_bMatchInt3 = pStructMem->m_bMatchThisEntry;
|
||||
sosEntryMatch.m_nMatchInt3 = pScratchPad->m_nSoundScriptHash;
|
||||
|
||||
CUtlVector< int > vMatchingIndices;
|
||||
CChannelList list;
|
||||
g_ActiveChannels.GetActiveChannels( list );
|
||||
int nThisIndex = 0;
|
||||
|
||||
for ( int i = 0; i < list.Count(); i++ )
|
||||
{
|
||||
sosEntryMatch.m_bMatchString1 = pStructMem->m_bMatchEntry;
|
||||
|
||||
int ch_idx = list.GetChannelIndex(i);
|
||||
// skip uninitiated entries (like this one!)
|
||||
if ( ! channels[ch_idx].sfx )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( channels[ch_idx].sfx->pSource && channels[ch_idx].sfx->pSource->GetType() == CAudioSource::AUDIO_SOURCE_VOICE )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( pChannel && &channels[ch_idx] == pChannel )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bIsAMatch = false;
|
||||
bool bInvertMatch = false;
|
||||
// this should probably explicitly check for soundentry_version
|
||||
if( channels[ch_idx].m_nSoundScriptHash == SOUNDEMITTER_INVALID_HASH && pStructMem->m_bMatchEntry )
|
||||
{
|
||||
if( pStructMem->m_bInvertMatch )
|
||||
{
|
||||
bInvertMatch = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if( !bInvertMatch )
|
||||
{
|
||||
CSosEntryMatch sosChanMatch;
|
||||
|
||||
if ( sosEntryMatch.m_bMatchString1 && channels[ch_idx].m_nSoundScriptHash != SOUNDEMITTER_INVALID_HASH )
|
||||
{
|
||||
const char *pEntryName = g_pSoundEmitterSystem->GetSoundNameForHash( channels[ch_idx].m_nSoundScriptHash );
|
||||
if ( !pEntryName )
|
||||
{
|
||||
pEntryName = "";
|
||||
}
|
||||
|
||||
V_strncpy( sosChanMatch.m_nMatchString1, pEntryName, sizeof( sosChanMatch.m_nMatchString1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
sosEntryMatch.m_bMatchString1 = false;
|
||||
}
|
||||
if ( sosEntryMatch.m_bMatchString2 )
|
||||
{
|
||||
channels[ch_idx].sfx->GetFileName( sosChanMatch.m_nMatchString2, sizeof( sosChanMatch.m_nMatchString2 ) );
|
||||
}
|
||||
sosChanMatch.m_nMatchInt1 = channels[ch_idx].entchannel;
|
||||
sosChanMatch.m_nMatchInt2 = channels[ch_idx].soundsource;
|
||||
sosChanMatch.m_nMatchInt3 = channels[ch_idx].m_nSoundScriptHash;
|
||||
|
||||
bIsAMatch = sosEntryMatch.IsAMatch( &sosChanMatch );
|
||||
bIsAMatch = ( bIsAMatch && !pStructMem->m_bInvertMatch ) || ( !bIsAMatch && pStructMem->m_bInvertMatch );
|
||||
}
|
||||
|
||||
|
||||
if ( bIsAMatch || bInvertMatch )
|
||||
{
|
||||
int nNewIndex = vMatchingIndices.AddToTail( ch_idx );
|
||||
if( pChannel && &channels[ ch_idx ] == pChannel )
|
||||
{
|
||||
nThisIndex = nNewIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pStructMem->m_flOutputVoicesMatching[0] = ( float ) vMatchingIndices.Count();
|
||||
pStructMem->m_flOutputIndexOfThis[0] = ( float ) nThisIndex;
|
||||
|
||||
|
||||
if ( vMatchingIndices.Count() > (int) pStructMem->m_flInputMaxVoices[0] )
|
||||
{
|
||||
if( pStructMem->m_bStopOldest )
|
||||
{
|
||||
vMatchingIndices.Sort( &ChannelLongestElapsedTimeSortFunc );
|
||||
}
|
||||
for( int i = (int) pStructMem->m_flInputMaxVoices[0]; i < vMatchingIndices.Count(); i++ )
|
||||
{
|
||||
if ( snd_sos_show_operator_stop_entry.GetInt() )
|
||||
{
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sStopping: %s : elapsed time: %f.2\n", 1, " ", g_pSoundEmitterSystem->GetSoundNameForHash( channels[ vMatchingIndices[ i ] ].m_nSoundScriptHash ), S_GetElapsedTime( &channels[ vMatchingIndices[ i ] ] ) * .001 );
|
||||
}
|
||||
|
||||
g_pSoundOperatorSystem->QueueStopChannel( channels[ vMatchingIndices[ i ] ].guid, pStructMem->m_flInputStopDelay[0] );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSosOperatorStopEntry::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorStopEntry_t *pStructMem = (CSosOperatorStopEntry_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
// Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sNumber Allowed: %i\n", nLevel, " ", pStructMem->m_nNumAllowed );
|
||||
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*smatch_entry: %s\n", nLevel, " ", pStructMem->m_bMatchEntry ? pStructMem->m_nMatchEntryName : "\"\"" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*smatch_sound: %s\n", nLevel, " ", pStructMem->m_bMatchSound ? pStructMem->m_nMatchSoundName : "\"\"" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*smatch_entity: %s\n", nLevel, " ", pStructMem->m_bMatchEntity ? "true" : "false" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*smatch_channel: %s\n", nLevel, " ", pStructMem->m_bMatchEntity ? "true" : "false" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*smatch_substring: %s\n", nLevel, " ", pStructMem->m_bMatchSubString ? "true" : "false" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*smatch_this_entry: %s\n", nLevel, " ", pStructMem->m_bMatchThisEntry ? "true" : "false" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sstop_oldest: %s\n", nLevel, " ", pStructMem->m_bStopOldest ? "true" : "false" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sinvert_match: %s\n", nLevel, " ", pStructMem->m_bInvertMatch ? "true" : "false" );
|
||||
|
||||
}
|
||||
void CSosOperatorStopEntry::OpHelp( ) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorStopEntry::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorStopEntry_t *pStructMem = (CSosOperatorStopEntry_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "match_this_entry" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bMatchThisEntry = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bMatchChannel = false;
|
||||
}
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "match_entry" ) )
|
||||
{
|
||||
pStructMem->m_bMatchEntry = true;
|
||||
V_strncpy( pStructMem->m_nMatchEntryName, pValueString, sizeof(pStructMem->m_nMatchEntryName) );
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "match_sound" ) )
|
||||
{
|
||||
pStructMem->m_bMatchSound = true;
|
||||
V_strncpy( pStructMem->m_nMatchSoundName, pValueString, sizeof(pStructMem->m_nMatchSoundName) );
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "match_entity" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bMatchEntity = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bMatchEntity = false;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "match_channel" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bMatchChannel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bMatchChannel = false;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "match_substring" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bMatchSubString = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bMatchSubString = false;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "stop_oldest" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bStopOldest = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bStopOldest = false;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "stop_this_entry" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bStopThis = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bStopThis = false;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "invert_match" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bInvertMatch = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bInvertMatch = false;
|
||||
}
|
||||
}
|
||||
// else if ( !V_strcasecmp( pParamString, "num_allowed" ) )
|
||||
// {
|
||||
// pStructMem->m_nNumAllowed = V_atoi( pValueString );
|
||||
// }
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
44
engine/audio/private/snd_op_sys/sos_op_stop_entry.h
Normal file
44
engine/audio/private/snd_op_sys/sos_op_stop_entry.h
Normal file
@@ -0,0 +1,44 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_STOP_ENTRY_H
|
||||
#define SOS_OP_STOP_ENTRY_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// stop other sound entries
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorStopEntry_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInputMaxVoices, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputStopDelay, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputVoicesMatching, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputIndexOfThis, SO_SINGLE )
|
||||
|
||||
char m_nMatchEntryName[64];
|
||||
bool m_bMatchEntry;
|
||||
char m_nMatchSoundName[64];
|
||||
bool m_bMatchSound;
|
||||
bool m_bMatchSubString;
|
||||
bool m_bMatchEntity;
|
||||
bool m_bMatchChannel;
|
||||
bool m_bStopOldest;
|
||||
bool m_bStopThis;
|
||||
bool m_bMatchThisEntry;
|
||||
bool m_bInvertMatch;
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorStopEntry : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorStopEntry )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_STOP_ENTRY_H
|
||||
82
engine/audio/private/snd_op_sys/sos_op_sys_time.cpp
Normal file
82
engine/audio/private/snd_op_sys/sos_op_sys_time.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "snd_dma.h"
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_sys_time.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorSysTime
|
||||
// Setting a single, simple scratch pad Expression
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorSysTime, "get_sys_time" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorSysTime, m_flOutputClientElapsed, SO_SINGLE, "output_client_time" );
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorSysTime, m_flOutputHostElapsed, SO_SINGLE, "output_host_time" );
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorSysTime, "get_sys_time" )
|
||||
|
||||
void CSosOperatorSysTime::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorSysTime_t *pStructMem = (CSosOperatorSysTime_t *)pVoidMem;
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputClientElapsed, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputHostElapsed, SO_SINGLE, 0.0 )
|
||||
}
|
||||
|
||||
void CSosOperatorSysTime::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorSysTime_t *pStructMem = (CSosOperatorSysTime_t *)pVoidMem;
|
||||
|
||||
pStructMem->m_flOutputHostElapsed[0] = g_pSoundServices->GetHostTime();
|
||||
pStructMem->m_flOutputClientElapsed[0] = g_pSoundServices->GetClientTime();
|
||||
|
||||
}
|
||||
void CSosOperatorSysTime::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorSysTime_t *pStructMem = (CSosOperatorSysTime_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
|
||||
}
|
||||
void CSosOperatorSysTime::OpHelp( ) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorSysTime::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorSysTime_t *pStructMem = (CSosOperatorSysTime_t *)pVoidMem;
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
33
engine/audio/private/snd_op_sys/sos_op_sys_time.h
Normal file
33
engine/audio/private/snd_op_sys/sos_op_sys_time.h
Normal file
@@ -0,0 +1,33 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_SYS_TIME_H
|
||||
#define SOS_OP_SYS_TIME_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// get elapsed time
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorSysTime_t : CSosOperator_t
|
||||
{
|
||||
SOS_OUTPUT_FLOAT( m_flOutputClientElapsed, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputHostElapsed, SO_SINGLE )
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorSysTime : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorSysTime )
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // SOS_OP_SYS_TIME_H
|
||||
745
engine/audio/private/snd_op_sys/sos_op_tracks.cpp
Normal file
745
engine/audio/private/snd_op_sys/sos_op_tracks.cpp
Normal file
@@ -0,0 +1,745 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "snd_dma.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_tracks.h"
|
||||
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorGetTrackSyncPoint_t
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorGetTrackSyncPoint, "get_track_syncpoint" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorGetTrackSyncPoint, m_flInputMinTimeToNextSync, SO_SINGLE, "input_min_time_to_next_sync" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorGetTrackSyncPoint, m_flInputMaxTimeToNextSync, SO_SINGLE, "input_max_time_to_next_sync" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorGetTrackSyncPoint, m_flOutputFirstSyncPoint, SO_SINGLE, "output_first_syncpoint" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorGetTrackSyncPoint, m_flOutputLastSyncPoint, SO_SINGLE, "output_last_syncpoint" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorGetTrackSyncPoint, m_flOutputTimeToNextSync, SO_SINGLE, "output_time_to_next_syncpoint" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorGetTrackSyncPoint, "get_track_syncpoint" )
|
||||
|
||||
void CSosOperatorGetTrackSyncPoint::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorGetTrackSyncPoint_t *pStructMem = (CSosOperatorGetTrackSyncPoint_t *)pVoidMem;
|
||||
V_strncpy( pStructMem->m_nMatchEntryName, "", sizeof(pStructMem->m_nMatchEntryName) );
|
||||
V_strncpy( pStructMem->m_nSyncPointListName, "", sizeof(pStructMem->m_nSyncPointListName ) );
|
||||
/// V_strncpy( pStructMem->m_nMatchSoundName, "", sizeof(pStructMem->m_nMatchSoundName) );
|
||||
// pStructMem->m_bMatchEntry = false;
|
||||
// pStructMem->m_bMatchSound = false;
|
||||
// pStructMem->m_bMatchEntity = false;
|
||||
// pStructMem->m_bMatchChannel = false;
|
||||
// pStructMem->m_bMatchSubString = false;
|
||||
// pStructMem->m_bStopOldest = true;
|
||||
// pStructMem->m_bStopThis = false;
|
||||
SOS_INIT_INPUT_VAR( m_flInputMinTimeToNextSync, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_INPUT_VAR( m_flInputMaxTimeToNextSync, SO_SINGLE, 1000.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputTimeToNextSync, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputFirstSyncPoint, SO_SINGLE, 0.0 )
|
||||
|
||||
pStructMem->m_bDataFromThis = false;
|
||||
pStructMem->m_bMatchEntry = false;
|
||||
pStructMem->m_bSubtractMinTimeToSync = true;
|
||||
pStructMem->m_bSubtractMinTimeToSyncFromLastSync = false;
|
||||
pStructMem->m_bSubtractFirstSyncFromLastSync = true;
|
||||
}
|
||||
|
||||
static int __cdecl ChannelLongestElapsedTimeSortFunc( const int *nChannelIndexA, const int *nChannelIndexB )
|
||||
{
|
||||
return ( S_GetElapsedTimeByGuid( channels[ *nChannelIndexA ].guid ) > S_GetElapsedTimeByGuid( channels[ *nChannelIndexB ].guid ) );
|
||||
}
|
||||
|
||||
// static int __cdecl ChannelLeastVolumeSortFunc( const int *nChannelIndexA, const int *nChannelIndexB )
|
||||
// {
|
||||
// return ( S_GetElapsedTimeByGuid( channels[ *nChannelIndexA ]. ) < S_GetElapsedTimeByGuid( channels[ *nChannelIndexB ].guid ) );
|
||||
// }
|
||||
|
||||
void CSosOperatorGetTrackSyncPoint::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
|
||||
CSosOperatorGetTrackSyncPoint_t *pStructMem = (CSosOperatorGetTrackSyncPoint_t *)pVoidMem;
|
||||
|
||||
track_data_t trackData;
|
||||
pStack->GetTrackData( trackData );
|
||||
|
||||
// HSOUNDSCRIPTHASH nSoundScriptHashHandle = SOUNDEMITTER_INVALID_HASH;
|
||||
float fElapsedTime = 0.0;
|
||||
float fDuration = 0.0;
|
||||
KeyValues *pSyncPointList = NULL;
|
||||
|
||||
|
||||
if( ! pStructMem->m_bDataFromThis )
|
||||
{
|
||||
CChannelList list;
|
||||
g_ActiveChannels.GetActiveChannels( list );
|
||||
|
||||
for ( int i = 0; i < list.Count(); i++ )
|
||||
{
|
||||
|
||||
int ch_idx = list.GetChannelIndex(i);
|
||||
// skip uninitiated entries (like this one!)
|
||||
if ( ! channels[ch_idx].sfx )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( pChannel && &channels[ch_idx] == pChannel )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// this should probably explicitly check for soundentry_version
|
||||
if( channels[ch_idx].m_nSoundScriptHash == SOUNDEMITTER_INVALID_HASH )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
KeyValues *pOperatorKV = g_pSoundEmitterSystem->GetOperatorKVByHandle( channels[ch_idx].m_nSoundScriptHash );
|
||||
if ( !pOperatorKV )
|
||||
{
|
||||
// Log_Warning( LOG_SND_OPERATORS, "Error: Sound operator %s cannot find operator KV data\n", pStack->GetOperatorName( nOpIndex ));
|
||||
continue;
|
||||
}
|
||||
|
||||
track_data_t chanTrackData;
|
||||
S_GetTrackData( pOperatorKV, chanTrackData );
|
||||
|
||||
if( chanTrackData.m_nTrackNumber != trackData.m_nSyncTrackNumber )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// getting elapsed time from entry time due to mp3 weirdness
|
||||
fElapsedTime = S_GetElapsedTimeByGuid( channels[ ch_idx ].guid ) * 0.01;
|
||||
// if ( channels[ch_idx].m_pStackList )
|
||||
// {
|
||||
// CSosOperatorStack *pTheStack = NULL;
|
||||
// pTheStack = channels[ch_idx].m_pStackList->GetStack( CSosOperatorStack::SOS_UPDATE );
|
||||
//
|
||||
// if ( pTheStack )
|
||||
// {
|
||||
// fElapsedTime = pTheStack->GetElapsedTime();
|
||||
// }
|
||||
// }
|
||||
fDuration = chanTrackData.m_flEndPoint - chanTrackData.m_flStartPoint;
|
||||
// fDuration = S_SoundDuration( &channels[ ch_idx ] );
|
||||
fElapsedTime = fmod( fElapsedTime, fDuration );
|
||||
|
||||
|
||||
pSyncPointList = pStack->GetSyncPointsKV( pOperatorKV, pStructMem->m_nSyncPointListName );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// nSoundScriptHashHandle = pStack->GetScriptHash();
|
||||
pSyncPointList = pStack->GetSyncPointsKV( pStructMem->m_nSyncPointListName );
|
||||
}
|
||||
|
||||
|
||||
CUtlVector< float > vSyncPoints;
|
||||
if( pSyncPointList )
|
||||
{
|
||||
for ( KeyValues *pValue = pSyncPointList->GetFirstValue(); pValue; pValue = pValue->GetNextValue() )
|
||||
{
|
||||
vSyncPoints.AddToTail( pValue->GetFloat() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log_Warning( LOG_SND_OPERATORS, "Error: Sound operator %s cannot find track syncpoint KV data\n", pStack->GetOperatorName( nOpIndex ));
|
||||
return;
|
||||
}
|
||||
|
||||
float fMinTimeToSyncPoint = pStructMem->m_flInputMaxTimeToNextSync[0];
|
||||
for( int i = 0; i < vSyncPoints.Count(); i++ )
|
||||
{
|
||||
float fDiff = vSyncPoints[i] - fElapsedTime;
|
||||
if( fDiff > 0 && fDiff < fMinTimeToSyncPoint && fDiff > pStructMem->m_flInputMinTimeToNextSync[0] )
|
||||
{
|
||||
fMinTimeToSyncPoint = fDiff;
|
||||
}
|
||||
|
||||
}
|
||||
fMinTimeToSyncPoint = fMinTimeToSyncPoint - ( pStructMem->m_bSubtractMinTimeToSync ? pStructMem->m_flInputMinTimeToNextSync[0] : 0.0 );
|
||||
pStructMem->m_flOutputTimeToNextSync[0] = fMinTimeToSyncPoint;
|
||||
|
||||
float fLastSyncPoint = 0.0;
|
||||
int nIndexToLastSyncPoint = vSyncPoints.Count() > 0 ? vSyncPoints.Count() - 1 : -1;
|
||||
if( nIndexToLastSyncPoint >= 0 )
|
||||
{
|
||||
fLastSyncPoint = vSyncPoints[ nIndexToLastSyncPoint ] - ( pStructMem->m_bSubtractMinTimeToSyncFromLastSync ? pStructMem->m_flInputMinTimeToNextSync[0] : 0.0 );
|
||||
fLastSyncPoint = fLastSyncPoint - ( pStructMem->m_bSubtractFirstSyncFromLastSync ? vSyncPoints[0] : 0.0 );
|
||||
}
|
||||
|
||||
pStructMem->m_flOutputLastSyncPoint[0] = fLastSyncPoint;
|
||||
|
||||
|
||||
if( vSyncPoints.Count() > 0 )
|
||||
{
|
||||
pStructMem->m_flOutputFirstSyncPoint[0] = vSyncPoints[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_flOutputFirstSyncPoint[0] = 0.0;
|
||||
}
|
||||
|
||||
// pStructMem->m_flOutputVoicesMatching[0] = ( float ) vMatchingIndices.Count();
|
||||
// pStructMem->m_flOutputIndexOfThis[0] = ( float ) nThisIndex;
|
||||
//
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorGetTrackSyncPoint::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorGetTrackSyncPoint_t *pStructMem = (CSosOperatorGetTrackSyncPoint_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
// Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sNumber Allowed: %i\n", nLevel, " ", pStructMem->m_nNumAllowed );
|
||||
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*smatch_entry: %s\n", nLevel, " ", pStructMem->m_bMatchEntry ? pStructMem->m_nMatchEntryName : "\"\"" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*ssyncpoint_list: %s\n", nLevel, " ", pStructMem->m_nSyncPointListName );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*sthis_entry_syncpoints: %s\n", nLevel, " ", pStructMem->m_bDataFromThis ? "true" : "false" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*ssubtract_min_time_from_next: %s\n", nLevel, " ", pStructMem->m_bSubtractMinTimeToSync ? "true" : "false" );
|
||||
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*ssubtract_min_time_from_last: %s\n", nLevel, " ", pStructMem->m_bSubtractMinTimeToSyncFromLastSync ? "true" : "false" );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*ssubtract_first_from_last: %s\n", nLevel, " ", pStructMem->m_bSubtractFirstSyncFromLastSync ? "true" : "false" );
|
||||
|
||||
|
||||
}
|
||||
void CSosOperatorGetTrackSyncPoint::OpHelp( ) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorGetTrackSyncPoint::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorGetTrackSyncPoint_t *pStructMem = (CSosOperatorGetTrackSyncPoint_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "match_entry" ) )
|
||||
{
|
||||
pStructMem->m_bMatchEntry = true;
|
||||
V_strncpy( pStructMem->m_nMatchEntryName, pValueString, sizeof(pStructMem->m_nMatchEntryName) );
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "syncpoint_list" ) )
|
||||
{
|
||||
V_strncpy( pStructMem->m_nSyncPointListName, pValueString, sizeof( pStructMem->m_nSyncPointListName ) );
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "this_entry_syncpoints" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bDataFromThis = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bDataFromThis = false;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "subtract_min_time_from_next" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bSubtractMinTimeToSync = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bSubtractMinTimeToSync = false;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "subtract_min_time_from_last" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bSubtractMinTimeToSyncFromLastSync = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bSubtractMinTimeToSyncFromLastSync = false;
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "subtract_first_from_last" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bSubtractFirstSyncFromLastSync = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_bSubtractFirstSyncFromLastSync = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorQueueToTrack_t
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConVar snd_sos_show_queuetotrack("snd_sos_show_queuetotrack", "0", FCVAR_CHEAT );
|
||||
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorQueueToTrack, "track_queue" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorQueueToTrack, m_flOutputTimeToNextSync, SO_SINGLE, "output_time_to_next_syncpoint" )
|
||||
SOS_REGISTER_OUTPUT_FLOAT( CSosOperatorQueueToTrack, m_flOutputTimeToStart, SO_SINGLE, "output_time_to_start" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorQueueToTrack, "track_queue" )
|
||||
|
||||
void CSosOperatorQueueToTrack::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorQueueToTrack_t *pStructMem = (CSosOperatorQueueToTrack_t *)pVoidMem;
|
||||
V_strncpy( pStructMem->m_nSyncPointListName, "", sizeof(pStructMem->m_nSyncPointListName ) );
|
||||
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputTimeToNextSync, SO_SINGLE, 0.0 )
|
||||
SOS_INIT_OUTPUT_VAR( m_flOutputTimeToStart, SO_SINGLE, 0.0 )
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorQueueToTrack::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
|
||||
CSosOperatorQueueToTrack_t *pStructMem = (CSosOperatorQueueToTrack_t *)pVoidMem;
|
||||
|
||||
track_data_t trackData;
|
||||
pStack->GetTrackData( trackData );
|
||||
|
||||
float fElapsedTime = 0.0;
|
||||
float fDuration = 0.0;
|
||||
float flMinTimeToSyncPoint = 0.0;
|
||||
KeyValues *pSyncPointList = NULL;
|
||||
|
||||
|
||||
channel_t *pCurrentChannelOnThisTrack = NULL;
|
||||
int nThisTrackIndex = g_pSoundOperatorSystem->m_vTrackDict.Find( trackData.m_pTrackName );
|
||||
if( g_pSoundOperatorSystem->m_vTrackDict.IsValidIndex( nThisTrackIndex ) )
|
||||
{
|
||||
pCurrentChannelOnThisTrack = g_pSoundOperatorSystem->m_vTrackDict[nThisTrackIndex];
|
||||
|
||||
if( pCurrentChannelOnThisTrack && pCurrentChannelOnThisTrack->m_nSoundScriptHash != SOUNDEMITTER_INVALID_HASH )
|
||||
{
|
||||
|
||||
KeyValues *pOperatorKV = g_pSoundEmitterSystem->GetOperatorKVByHandle( pCurrentChannelOnThisTrack->m_nSoundScriptHash );
|
||||
if ( pOperatorKV )
|
||||
{
|
||||
track_data_t thatTrackData;
|
||||
S_GetTrackData( pOperatorKV, thatTrackData );
|
||||
|
||||
if( !S_TrackHasPriority( trackData, thatTrackData ) )
|
||||
{
|
||||
if( snd_sos_show_queuetotrack.GetInt() )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "QUEUETOTRACK: %s priority blocked by %s\n", g_pSoundEmitterSystem->GetSoundNameForHash( pStack->GetScriptHash() ), g_pSoundEmitterSystem->GetSoundNameForHash( pCurrentChannelOnThisTrack->m_nSoundScriptHash ));
|
||||
}
|
||||
pScratchPad->m_flDelayToQueue = 0.0;
|
||||
pScratchPad->m_bBlockStart = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if there's nothing playing on the sync track do we just play?
|
||||
// currently YES
|
||||
channel_t *pCurrentChannelOnSyncTrack = NULL;
|
||||
int nTrackIndex = g_pSoundOperatorSystem->m_vTrackDict.Find( trackData.m_pSyncTrackName );
|
||||
if( g_pSoundOperatorSystem->m_vTrackDict.IsValidIndex( nTrackIndex ) )
|
||||
{
|
||||
pCurrentChannelOnSyncTrack = g_pSoundOperatorSystem->m_vTrackDict[nTrackIndex];
|
||||
|
||||
if( pCurrentChannelOnSyncTrack && pCurrentChannelOnSyncTrack->m_nSoundScriptHash != SOUNDEMITTER_INVALID_HASH )
|
||||
{
|
||||
|
||||
KeyValues *pOperatorKV = g_pSoundEmitterSystem->GetOperatorKVByHandle( pCurrentChannelOnSyncTrack->m_nSoundScriptHash );
|
||||
if ( pOperatorKV )
|
||||
{
|
||||
|
||||
track_data_t syncTrackData;
|
||||
S_GetTrackData( pOperatorKV, syncTrackData );
|
||||
|
||||
fElapsedTime = S_GetElapsedTimeByGuid( pCurrentChannelOnSyncTrack->guid ) * 0.01;
|
||||
// fDuration = S_SoundDuration( pCurrentChannelOnSyncTrack );
|
||||
fDuration = syncTrackData.m_flEndPoint - syncTrackData.m_flStartPoint;
|
||||
fElapsedTime = fmod( fElapsedTime, fDuration );
|
||||
|
||||
|
||||
pSyncPointList = pStack->GetSyncPointsKV( pOperatorKV, pStructMem->m_nSyncPointListName );
|
||||
|
||||
// collect up sync points
|
||||
CUtlVector< float > vSyncPoints;
|
||||
if( pSyncPointList )
|
||||
{
|
||||
for ( KeyValues *pValue = pSyncPointList->GetFirstValue(); pValue; pValue = pValue->GetNextValue() )
|
||||
{
|
||||
vSyncPoints.AddToTail( pValue->GetFloat() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log_Warning( LOG_SND_OPERATORS, "Error: Sound operator %s cannot find track syncpoint KV data\n", pStack->GetOperatorName( nOpIndex ));
|
||||
return;
|
||||
}
|
||||
|
||||
flMinTimeToSyncPoint = fDuration;
|
||||
bool bFoundSyncPoint = false;
|
||||
for( int i = 0; i < vSyncPoints.Count(); i++ )
|
||||
{
|
||||
float fDiff = vSyncPoints[i] - fElapsedTime;
|
||||
if( fDiff > 0 && fDiff < flMinTimeToSyncPoint && fDiff > trackData.m_flStartPoint )
|
||||
{
|
||||
bFoundSyncPoint = true;
|
||||
flMinTimeToSyncPoint = fDiff;
|
||||
}
|
||||
|
||||
}
|
||||
if( bFoundSyncPoint )
|
||||
{
|
||||
pStructMem->m_flOutputTimeToNextSync[0] = flMinTimeToSyncPoint;
|
||||
|
||||
// subtract start point
|
||||
flMinTimeToSyncPoint = flMinTimeToSyncPoint - trackData.m_flStartPoint;
|
||||
pStructMem->m_flOutputTimeToStart[0] = flMinTimeToSyncPoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
pStructMem->m_flOutputTimeToNextSync[0] = 0.0;
|
||||
pStructMem->m_flOutputTimeToStart[0] = 0.0;
|
||||
flMinTimeToSyncPoint = 0.0;
|
||||
}
|
||||
|
||||
if( snd_sos_show_queuetotrack.GetInt() )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "QUEUETOTRACK: %s queued with a delay of %f\n", g_pSoundEmitterSystem->GetSoundNameForHash( pStack->GetScriptHash() ), flMinTimeToSyncPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pScratchPad->m_flDelayToQueue = flMinTimeToSyncPoint;
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorQueueToTrack::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorQueueToTrack_t *pStructMem = (CSosOperatorQueueToTrack_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*ssyncpoint_list: %s\n", nLevel, " ", pStructMem->m_nSyncPointListName );
|
||||
}
|
||||
void CSosOperatorQueueToTrack::OpHelp( ) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorQueueToTrack::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorQueueToTrack_t *pStructMem = (CSosOperatorQueueToTrack_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "syncpoint_list" ) )
|
||||
{
|
||||
V_strncpy( pStructMem->m_nSyncPointListName, pValueString, sizeof( pStructMem->m_nSyncPointListName ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorPlayOnTrack_t
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorPlayOnTrack, "track_update" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorPlayOnTrack, "track_update" )
|
||||
|
||||
void CSosOperatorPlayOnTrack::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorPlayOnTrack_t *pStructMem = (CSosOperatorPlayOnTrack_t *)pVoidMem;
|
||||
pStructMem->m_nAutoQueueEndPointScriptHash = SOUNDEMITTER_INVALID_HASH;
|
||||
pStructMem->m_trackData.SetDefaults();
|
||||
pStructMem->m_bHasTriggeredAutoQue = false;
|
||||
pStructMem->m_bStopChannelOnTrack = true;
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorPlayOnTrack::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
|
||||
if( !pChannel )
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Sound operator %s requires valid channel pointer, being called without one\n", pStack->GetOperatorName( nOpIndex ));
|
||||
return;
|
||||
}
|
||||
|
||||
CSosOperatorPlayOnTrack_t *pStructMem = (CSosOperatorPlayOnTrack_t *)pVoidMem;
|
||||
|
||||
// first time
|
||||
if( !pStructMem->m_bHasExecuted )
|
||||
{
|
||||
if( pStructMem->m_bStopChannelOnTrack )
|
||||
{
|
||||
g_pSoundOperatorSystem->StopChannelOnTrack( pStructMem->m_trackData.m_pTrackName, false, pStructMem->m_trackData.m_flStartPoint );
|
||||
}
|
||||
g_pSoundOperatorSystem->SetChannelOnTrack( pStructMem->m_trackData.m_pTrackName, pChannel );
|
||||
}
|
||||
|
||||
|
||||
// in the case that the incoming cue has a starttime longer than the time left on the track, there will be silence.
|
||||
// punt for now
|
||||
// ( pStack->GetStopType() == SOS_STOP_NONE || ( pStack->GetStopType() == SOS_STOP_QUEUE ) ) ) //&& ( pStack->GetStopTime() > pStructMem->m_trackData.m_flStartPoint )
|
||||
|
||||
if ( pStructMem->m_nAutoQueueEndPointScriptHash != SOUNDEMITTER_INVALID_HASH &&
|
||||
pStack->GetStopType() == SOS_STOP_NONE )
|
||||
{
|
||||
float fThisChannelsElapsedTime = S_GetElapsedTime( pChannel ) * 0.01;
|
||||
float fTimeToTrigger = pStructMem->m_trackData.m_flEndPoint - pStructMem->m_fAutoQueueStartPoint;
|
||||
if( ( fThisChannelsElapsedTime >= fTimeToTrigger ) &&
|
||||
!pStructMem->m_bHasTriggeredAutoQue )
|
||||
{
|
||||
// copied from start_entry.... UGH, PROPAGATING UGLINESS!!
|
||||
|
||||
StartSoundParams_t startParams;
|
||||
CSoundParameters pScriptParams;
|
||||
gender_t gender = GENDER_NONE;
|
||||
if ( !g_pSoundEmitterSystem->GetParametersForSoundEx( "SoundSciptHandle ERROR", pStructMem->m_nAutoQueueEndPointScriptHash, pScriptParams, gender, true ) )
|
||||
{
|
||||
//DevWarning("Error: Unable to get parameters for soundentry %s", startParams.m_pSoundEntryName );
|
||||
return;
|
||||
}
|
||||
|
||||
// don't actually need the soundfile yet
|
||||
|
||||
// if ( !pScriptParams.soundname[0] )
|
||||
// return;
|
||||
|
||||
// copy emitter params
|
||||
startParams.staticsound = ( pScriptParams.channel == CHAN_STATIC ) ? true : false;
|
||||
startParams.entchannel = pScriptParams.channel;
|
||||
|
||||
// inherits location and entity
|
||||
VectorCopy( pScratchPad->m_vEmitterInfoOrigin, startParams.origin );
|
||||
startParams.soundsource = pScratchPad->m_nSoundSource;
|
||||
|
||||
startParams.fvol = pScriptParams.volume;
|
||||
startParams.soundlevel = pScriptParams.soundlevel;
|
||||
// startParams.flags = sound.nFlags;
|
||||
startParams.pitch = pScriptParams.pitch;
|
||||
startParams.fromserver = false;
|
||||
startParams.delay = pScriptParams.delay_msec;
|
||||
// startParams.speakerentity = sound.nSpeakerEntity;
|
||||
//startParams.m_bIsScriptHandle = ( pScriptParams.m_nSoundEntryVersion > 1 );
|
||||
startParams.m_bIsScriptHandle = true;
|
||||
|
||||
startParams.m_nSoundScriptHash = pStructMem->m_nAutoQueueEndPointScriptHash;
|
||||
g_pSoundOperatorSystem->QueueStartEntry( startParams, 0.0, false );
|
||||
|
||||
pStructMem->m_bHasTriggeredAutoQue = true;
|
||||
g_pSoundOperatorSystem->RemoveChannelFromTrack( pStructMem->m_trackData.m_pTrackName, pStack->GetChannelGuid() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSosOperatorPlayOnTrack::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
// CSosOperatorPlayOnTrack_t *pStructMem = (CSosOperatorPlayOnTrack_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
}
|
||||
void CSosOperatorPlayOnTrack::OpHelp( ) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorPlayOnTrack::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorPlayOnTrack_t *pStructMem = (CSosOperatorPlayOnTrack_t *)pVoidMem;
|
||||
|
||||
|
||||
pStack->GetTrackData( pStructMem->m_trackData );
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "autoqueue_entry_at_end_point" ) )
|
||||
{
|
||||
if ( !g_pSoundEmitterSystem )
|
||||
{
|
||||
DevWarning("Error: SoundEmitterSystem not initialized in engine!");
|
||||
return;
|
||||
}
|
||||
pStructMem->m_nAutoQueueEndPointScriptHash = g_pSoundEmitterSystem->HashSoundName( pValueString );
|
||||
|
||||
if( !g_pSoundEmitterSystem->GetSoundNameForHash( pStructMem->m_nAutoQueueEndPointScriptHash ))
|
||||
{
|
||||
// DevMsg( "Error: Invalid SoundEntry index %i from entry %s operator %s", pStructMem->m_nScriptHandle, pValueString, pStack->GetOperatorName( nOpIndex ) );
|
||||
DevMsg( "Error: Invalid SoundEntry hash %i from entry %s", pStructMem->m_nAutoQueueEndPointScriptHash, pValueString );
|
||||
pStructMem->m_nAutoQueueEndPointScriptHash = SOUNDEMITTER_INVALID_HASH;
|
||||
}
|
||||
else
|
||||
{
|
||||
KeyValues *pOperatorKV = g_pSoundEmitterSystem->GetOperatorKVByHandle( pStructMem->m_nAutoQueueEndPointScriptHash );
|
||||
if ( !pOperatorKV )
|
||||
{
|
||||
// Log_Warning( LOG_SND_OPERATORS, "Error: Sound operator %s cannot find operator KV data\n", pStack->GetOperatorName( nOpIndex ));
|
||||
pStructMem->m_fAutoQueueStartPoint = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
track_data_t trackData;
|
||||
S_GetTrackData( pOperatorKV, trackData );
|
||||
pStructMem->m_fAutoQueueStartPoint = trackData.m_flStartPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "stop_channel_on_track" ) )
|
||||
{
|
||||
if ( !V_strcasecmp( pValueString, "true" ) )
|
||||
{
|
||||
pStructMem->m_bStopChannelOnTrack = true;
|
||||
}
|
||||
else if ( !V_strcasecmp( pValueString, "false" ) )
|
||||
{
|
||||
pStructMem->m_bStopChannelOnTrack = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s Unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorStopTrack_t
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorStopTrack, "track_stop" )
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorStopTrack, "track_stop" )
|
||||
|
||||
void CSosOperatorStopTrack::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorStopTrack_t *pStructMem = (CSosOperatorStopTrack_t *)pVoidMem;
|
||||
pStructMem->m_nTrackName[0] = 0;
|
||||
}
|
||||
|
||||
void CSosOperatorStopTrack::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorStopTrack_t *pStructMem = (CSosOperatorStopTrack_t *)pVoidMem;
|
||||
g_pSoundOperatorSystem->StopChannelOnTrack( pStructMem->m_nTrackName );
|
||||
|
||||
// add stopall and delay as "features"
|
||||
// g_pSoundOperatorSystem->StopChannelOnTrack( pStructMem->m_nTrackName, bStopAllQueued, flDelay );
|
||||
}
|
||||
|
||||
void CSosOperatorStopTrack::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
CSosOperatorStopTrack_t *pStructMem = (CSosOperatorStopTrack_t *)pVoidMem;
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "%*strack: %s\n", nLevel, " ", pStructMem->m_nTrackName );
|
||||
}
|
||||
void CSosOperatorStopTrack::OpHelp( ) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorStopTrack::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorStopTrack_t *pStructMem = (CSosOperatorStopTrack_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
}
|
||||
else if ( !V_strcasecmp( pParamString, "track_name" ) )
|
||||
{
|
||||
V_strncpy( pStructMem->m_nTrackName, pValueString, sizeof(pStructMem->m_nTrackName ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s Unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
104
engine/audio/private/snd_op_sys/sos_op_tracks.h
Normal file
104
engine/audio/private/snd_op_sys/sos_op_tracks.h
Normal file
@@ -0,0 +1,104 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_TRACKS_H
|
||||
#define SOS_OP_TRACKS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// get sync data
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorGetTrackSyncPoint_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInputMinTimeToNextSync, SO_SINGLE )
|
||||
SOS_INPUT_FLOAT( m_flInputMaxTimeToNextSync, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputFirstSyncPoint, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputLastSyncPoint, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputTimeToNextSync, SO_SINGLE )
|
||||
//
|
||||
char m_nSyncPointListName[64];
|
||||
|
||||
char m_nMatchEntryName[64];
|
||||
bool m_bMatchEntry;
|
||||
|
||||
// bool m_bMatchEntry;
|
||||
// char m_nMatchSoundName[64];
|
||||
// bool m_bMatchSound;
|
||||
// bool m_bMatchSubString;
|
||||
// bool m_bMatchEntity;
|
||||
// bool m_bMatchChannel;
|
||||
// bool m_bStopOldest;
|
||||
// bool m_bStopThis;
|
||||
bool m_bDataFromThis;
|
||||
bool m_bSubtractMinTimeToSync;
|
||||
bool m_bSubtractMinTimeToSyncFromLastSync;
|
||||
bool m_bSubtractFirstSyncFromLastSync;
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorGetTrackSyncPoint : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorGetTrackSyncPoint )
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// queue to a track
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorQueueToTrack_t : CSosOperator_t
|
||||
{
|
||||
SOS_OUTPUT_FLOAT( m_flOutputTimeToStart, SO_SINGLE )
|
||||
SOS_OUTPUT_FLOAT( m_flOutputTimeToNextSync, SO_SINGLE )
|
||||
char m_nSyncPointListName[64];
|
||||
};
|
||||
|
||||
class CSosOperatorQueueToTrack : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorQueueToTrack )
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// play on a track
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorPlayOnTrack_t : CSosOperator_t
|
||||
{
|
||||
// SOS_OUTPUT_FLOAT( m_flOutputTimeToStart, SO_SINGLE )
|
||||
// SOS_OUTPUT_FLOAT( m_flOutputTimeToNextSync, SO_SINGLE )
|
||||
// char m_nSyncPointListName[64];
|
||||
HSOUNDSCRIPTHASH m_nAutoQueueEndPointScriptHash;
|
||||
|
||||
track_data_t m_trackData;
|
||||
float m_fAutoQueueStartPoint;
|
||||
bool m_bHasTriggeredAutoQue;
|
||||
bool m_bStopChannelOnTrack;
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorPlayOnTrack : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorPlayOnTrack )
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// stop channel(s) a track
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorStopTrack_t : CSosOperator_t
|
||||
{
|
||||
char m_nTrackName[64];
|
||||
};
|
||||
|
||||
class CSosOperatorStopTrack : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorStopTrack )
|
||||
|
||||
};
|
||||
#endif // SOS_OP_TRACKS_H
|
||||
79
engine/audio/private/snd_op_sys/sos_op_util.cpp
Normal file
79
engine/audio/private/snd_op_sys/sos_op_util.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "audio_pch.h"
|
||||
#include "tier2/interval.h"
|
||||
|
||||
#include "sos_op.h"
|
||||
#include "sos_op_util.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
|
||||
extern Color OpColor;
|
||||
extern Color ConnectColor;
|
||||
extern Color ResultColor;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CSosOperatorPrintFloat
|
||||
// Catchall operator
|
||||
//-----------------------------------------------------------------------------
|
||||
SOS_BEGIN_OPERATOR_CONSTRUCTOR( CSosOperatorPrintFloat, "util_print_float" )
|
||||
SOS_REGISTER_INPUT_FLOAT( CSosOperatorPrintFloat, m_flInput, SO_SINGLE, "input" );
|
||||
SOS_END_OPERATOR_CONSTRUCTOR( CSosOperatorPrintFloat, "util_print_float" )
|
||||
|
||||
void CSosOperatorPrintFloat::SetDefaults( void *pVoidMem ) const
|
||||
{
|
||||
CSosOperatorPrintFloat_t *pStructMem = (CSosOperatorPrintFloat_t *)pVoidMem;
|
||||
SOS_INIT_INPUT_VAR( m_flInput, SO_SINGLE, 0.0 )
|
||||
|
||||
}
|
||||
void CSosOperatorPrintFloat::Execute( void *pVoidMem, channel_t *pChannel, CScratchPad *pScratchPad, CSosOperatorStack *pStack, int nOpIndex ) const
|
||||
{
|
||||
CSosOperatorPrintFloat_t *pStructMem = (CSosOperatorPrintFloat_t *)pVoidMem;
|
||||
|
||||
Log_Msg( LOG_SND_OPERATORS, OpColor, "SOS PRINT FLOAT: %s: %f\n", pStack->GetOperatorName( nOpIndex ), pStructMem->m_flInput[0] );
|
||||
|
||||
}
|
||||
|
||||
void CSosOperatorPrintFloat::Print( void *pVoidMem, CSosOperatorStack *pStack, int nOpIndex, int nLevel ) const
|
||||
{
|
||||
PrintBaseParams( pVoidMem, pStack, nOpIndex, nLevel );
|
||||
// CSosOperatorPrintFloat_t *pStructMem = (CSosOperatorPrintFloat_t *)pVoidMem;
|
||||
|
||||
}
|
||||
void CSosOperatorPrintFloat::OpHelp( ) const
|
||||
{
|
||||
|
||||
}
|
||||
void CSosOperatorPrintFloat::ParseKV( CSosOperatorStack *pStack, void *pVoidMem, KeyValues *pOpKeys ) const
|
||||
{
|
||||
CSosOperatorPrintFloat_t *pStructMem = (CSosOperatorPrintFloat_t *)pVoidMem;
|
||||
|
||||
KeyValues *pParams = pOpKeys->GetFirstSubKey();
|
||||
while ( pParams )
|
||||
{
|
||||
const char *pParamString = pParams->GetName();
|
||||
const char *pValueString = pParams->GetString();
|
||||
if ( pParamString && *pParamString )
|
||||
{
|
||||
if ( pValueString && *pValueString )
|
||||
{
|
||||
if ( BaseParseKV( pStack, (CSosOperator_t *)pStructMem, pParamString, pValueString ) )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_Warning( LOG_SND_OPERATORS, "Error: Operator %s, unknown sound operator attribute %s\n", pStack->m_pCurrentOperatorName, pParamString );
|
||||
}
|
||||
}
|
||||
}
|
||||
pParams = pParams->GetNextKey();
|
||||
}
|
||||
}
|
||||
30
engine/audio/private/snd_op_sys/sos_op_util.h
Normal file
30
engine/audio/private/snd_op_sys/sos_op_util.h
Normal file
@@ -0,0 +1,30 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_OP_UTIL_H
|
||||
#define SOS_OP_UTIL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sos_op.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// basic mixgroup operator
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CSosOperatorPrintFloat_t : CSosOperator_t
|
||||
{
|
||||
SOS_INPUT_FLOAT( m_flInput, SO_SINGLE )
|
||||
|
||||
};
|
||||
|
||||
class CSosOperatorPrintFloat : public CSosOperator
|
||||
{
|
||||
SOS_HEADER_DESC( CSosOperatorPrintFloat )
|
||||
};
|
||||
|
||||
#endif // SOS_OP_UTIL
|
||||
1857
engine/audio/private/snd_op_sys/sos_system.cpp
Normal file
1857
engine/audio/private/snd_op_sys/sos_system.cpp
Normal file
File diff suppressed because it is too large
Load Diff
540
engine/audio/private/snd_op_sys/sos_system.h
Normal file
540
engine/audio/private/snd_op_sys/sos_system.h
Normal file
@@ -0,0 +1,540 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
//
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef SOS_SYSTEM_H
|
||||
#define SOS_SYSTEM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier1/UtlStringMap.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/utlsymbol.h"
|
||||
#include "toolframework/itoolframework.h"
|
||||
#include "snd_dma.h"
|
||||
#include "snd_channels.h"
|
||||
#include "sos_entry_match_system.h"
|
||||
|
||||
|
||||
|
||||
class CSosOperator;
|
||||
class CSosOperatorStack;
|
||||
// Externs the logging channel
|
||||
DECLARE_LOGGING_CHANNEL( LOG_SND_OPERATORS );
|
||||
|
||||
extern bool IsSoundSourceViewEntity( int soundsource );
|
||||
|
||||
|
||||
extern ConVar snd_sos_show_operator_updates;
|
||||
extern ConVar snd_sos_show_operator_start;
|
||||
extern ConVar snd_sos_show_operator_prestart;
|
||||
extern ConVar snd_sos_show_operator_entry_filter;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SOS_INVALID_TRACK_NUMBER -1
|
||||
|
||||
|
||||
struct track_data_t
|
||||
{
|
||||
void SetDefaults( )
|
||||
{
|
||||
m_pTrackName = NULL;
|
||||
m_pSyncTrackName = NULL;
|
||||
m_nTrackNumber = SOS_INVALID_TRACK_NUMBER;
|
||||
m_nTrackPriority = 0;
|
||||
m_bPriorityOverride = false;
|
||||
m_bBlockEqualPriority = false;
|
||||
m_nSyncTrackNumber = SOS_INVALID_TRACK_NUMBER;
|
||||
m_flStartPoint = 0.0;
|
||||
m_flEndPoint = 0.0;
|
||||
};
|
||||
|
||||
const char *m_pTrackName;
|
||||
const char *m_pSyncTrackName;
|
||||
int m_nTrackNumber;
|
||||
int m_nTrackPriority;
|
||||
bool m_bPriorityOverride;
|
||||
bool m_bBlockEqualPriority;
|
||||
int m_nSyncTrackNumber;
|
||||
float m_flStartPoint;
|
||||
float m_flEndPoint;
|
||||
|
||||
};
|
||||
bool S_TrackHasPriority( track_data_t &newTrackData, track_data_t &existingTrackData );
|
||||
|
||||
struct stack_data_t
|
||||
{
|
||||
stack_data_t( )
|
||||
{
|
||||
m_nGuid = -1;
|
||||
m_flStartTime = -1.0;
|
||||
m_pOperatorsKV = NULL;
|
||||
m_nSoundScriptHash = SOUNDEMITTER_INVALID_HASH;
|
||||
};
|
||||
|
||||
int m_nGuid;
|
||||
float m_flStartTime;
|
||||
KeyValues *m_pOperatorsKV;
|
||||
HSOUNDSCRIPTHASH m_nSoundScriptHash;
|
||||
|
||||
};
|
||||
bool S_GetTrackData( KeyValues *pOperatorsKV, track_data_t &trackData );
|
||||
|
||||
extern CSosOperatorStackList *S_InitChannelOperators( stack_data_t &stackData );
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SO_MAX_DATA_SIZE SO_MAX_SPEAKERS
|
||||
#define SO_MAX_SPEAKERS ( CCHANVOLUMES / 2 )
|
||||
#define SO_POSITION_ARRAY_SIZE 3
|
||||
#define XPOSITION 0
|
||||
#define YPOSITION 1
|
||||
#define ZPOSITION 2
|
||||
#define SO_ANGLE_ARRAY_SIZE 3
|
||||
#define XANGLE 0
|
||||
#define YANGLE 1
|
||||
#define ZANGLE 2
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
class CScratchPad
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
void Clear()
|
||||
{
|
||||
m_bIsPlayerSound = false;
|
||||
m_bIsLooping = false;
|
||||
|
||||
// cleared before update loop, needs to go away anyway
|
||||
// m_vBlendedListenerOrigin.Init( 0, 0, 0 );
|
||||
m_UtlVecMultiOrigins.RemoveAll( );
|
||||
m_nChannel = 6;
|
||||
m_nSoundSource = 0;
|
||||
m_flDelay = 0.0;
|
||||
m_bBlockStart = false;
|
||||
m_nSoundScriptHash = SOUNDEMITTER_INVALID_HASH;
|
||||
m_flDelayToQueue = 0.0;
|
||||
}
|
||||
|
||||
// void SetPerUpdate();
|
||||
void SetPerExecution( channel_t *pChannel, StartSoundParams_t *pStartParams )
|
||||
{
|
||||
Clear();
|
||||
|
||||
if( pChannel )
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// channel params
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VectorCopy( pChannel->origin, m_vEmitterInfoOrigin );
|
||||
VectorCopy( pChannel->direction, m_vEmitterInfoDirection );
|
||||
m_nSoundSource = pChannel->soundsource;
|
||||
m_nChannel = pChannel->entchannel;
|
||||
pChannel->sfx ? pChannel->sfx->getname( m_emitterInfoSoundName, sizeof( m_emitterInfoSoundName ) ) : "";
|
||||
m_flEmitterInfoMasterVolume = ( (float) pChannel->master_vol ) / 255.0f;
|
||||
m_vEmitterInfoSoundLevel = DIST_MULT_TO_SNDLVL( pChannel->dist_mult );
|
||||
m_flEmitterInfoPitch = pChannel->basePitch * 0.01f;
|
||||
m_nEmitterInfoSpeakerEntity = pChannel->speakerentity;
|
||||
m_nEmitterInfoRadius = pChannel->radius;
|
||||
|
||||
CAudioSource *pSource = pChannel->sfx ? pChannel->sfx->pSource : NULL;
|
||||
if ( pSource )
|
||||
{
|
||||
m_bIsLooping = pSource->IsLooped();
|
||||
}
|
||||
|
||||
m_nSoundScriptHash = pChannel->m_nSoundScriptHash;
|
||||
}
|
||||
else if ( pStartParams )
|
||||
{
|
||||
char m_emitterInfoSoundName[MAX_PATH];
|
||||
pStartParams->pSfx ? pStartParams->pSfx->getname( m_emitterInfoSoundName, sizeof( m_emitterInfoSoundName ) ) : "";
|
||||
// MORASKY: handle emitter angles throughout scratchpad
|
||||
//VectorCopy( pStartParams.direction, g_scratchpad.m_vEmitterInfoAngle );
|
||||
VectorCopy( pStartParams->origin, m_vEmitterInfoOrigin );
|
||||
VectorCopy( pStartParams->direction, m_vEmitterInfoDirection );
|
||||
m_nSoundSource = pStartParams->soundsource;
|
||||
m_nChannel = pStartParams->entchannel;
|
||||
m_vEmitterInfoSoundLevel = pStartParams->soundlevel;
|
||||
m_flEmitterInfoPitch = pStartParams->pitch * 0.01f;
|
||||
m_nEmitterInfoSpeakerEntity = pStartParams->speakerentity;
|
||||
m_flEmitterInfoMasterVolume = pStartParams->fvol;
|
||||
m_nEmitterInfoRadius = dB_To_Radius( m_vEmitterInfoSoundLevel );
|
||||
|
||||
CAudioSource *pSource = pStartParams->pSfx ? pStartParams->pSfx->pSource : NULL;
|
||||
if ( pSource )
|
||||
{
|
||||
m_bIsLooping = pSource->IsLooped();
|
||||
}
|
||||
|
||||
if( pStartParams->m_bIsScriptHandle )
|
||||
{
|
||||
m_nSoundScriptHash = pStartParams->m_nSoundScriptHash;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// is this a player originated sound and not a tool sound?
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
if ( IsSoundSourceViewEntity( m_nSoundSource ) && !toolframework->InToolMode() )
|
||||
{
|
||||
// sounds coming from listener actually come from a short distance directly in front of listener
|
||||
// in tool mode however, the view entity is meaningless, since we're viewing from arbitrary locations in space
|
||||
m_bIsPlayerSound = true;
|
||||
}
|
||||
}
|
||||
|
||||
HSOUNDSCRIPTHASH m_nSoundScriptHash;
|
||||
|
||||
// listener(s)
|
||||
// NOTE: should be made 1 listener per updated and use iterators
|
||||
Vector m_vPlayerOrigin[ MAX_SPLITSCREEN_CLIENTS ];
|
||||
Vector m_vPlayerForward[ MAX_SPLITSCREEN_CLIENTS ];
|
||||
Vector m_vPlayerRight[ MAX_SPLITSCREEN_CLIENTS ];
|
||||
Vector m_vPlayerUp[ MAX_SPLITSCREEN_CLIENTS ];
|
||||
Vector m_vClientSourceVectors[ MAX_SPLITSCREEN_CLIENTS ];
|
||||
Vector m_vBlendedListenerOrigin;
|
||||
|
||||
// source info
|
||||
bool m_bIsLooping;
|
||||
bool m_bIsPlayerSound;
|
||||
|
||||
// emitter info
|
||||
int m_nChannel;
|
||||
int m_nSoundSource;
|
||||
char m_emitterInfoSoundName[MAX_PATH];
|
||||
Vector m_vEmitterInfoOrigin;
|
||||
Vector m_vEmitterInfoDirection;
|
||||
soundlevel_t m_vEmitterInfoSoundLevel;
|
||||
float m_flEmitterInfoPitch;
|
||||
int m_nEmitterInfoSpeakerEntity;
|
||||
float m_flEmitterInfoMasterVolume; // channel actually? ie: it's been altered by operators?
|
||||
float m_nEmitterInfoRadius;
|
||||
|
||||
// not passed to scratchpad from StartSoundParams_t
|
||||
// CSfxTable *pSfx;
|
||||
// int flags;
|
||||
// float delay;
|
||||
// int initialStreamPosition;
|
||||
// HSOUNDSCRIPTHANDLE m_nSoundScriptHandle;
|
||||
// const char *m_pSoundEntryName;
|
||||
//
|
||||
// bool staticsound : 1;
|
||||
// bool bUpdatePositions : 1;
|
||||
// bool fromserver : 1;
|
||||
// bool bToolSound : 1;
|
||||
// bool m_bIsScriptHandle : 1;
|
||||
|
||||
// entity info
|
||||
QAngle m_vEntityInfoAngle;
|
||||
Vector m_vEntityInfoOrigin;
|
||||
float m_flEntityInfoRadius;
|
||||
CUtlVector< Vector > m_UtlVecMultiOrigins;
|
||||
|
||||
|
||||
// outputs
|
||||
float m_flDelay;
|
||||
bool m_bBlockStart;
|
||||
float m_flDelayToQueue;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
enum SODataType_t
|
||||
{
|
||||
SO_FLOAT = 0,
|
||||
};
|
||||
|
||||
#define SO_SINGLE 1
|
||||
#define SO_VEC3 3
|
||||
#define SO_SPEAKERS SO_MAX_SPEAKERS
|
||||
#define SO_VEC3_X_8 3 * 8
|
||||
|
||||
|
||||
// enum SODataCount_t
|
||||
// {
|
||||
// SO_FLOAT_1 = 1,
|
||||
// SO_VEC3 = 3,
|
||||
// SO_SPEAKERS = SO_MAX_SPEAKERS,
|
||||
// SO_VEC3_X_8 = 3 * 8,
|
||||
//
|
||||
// };
|
||||
|
||||
|
||||
// SIZES MUST MATCH ABOVE INDICES
|
||||
// short SODataSizes[] = { sizeof( float ), sizeof( float ) * 3, sizeof( float ) * SO_MAX_SPEAKERS, sizeof( float ) * 3 * 8 };
|
||||
//
|
||||
// short SODataIndices[] = { 1, 3, SO_MAX_SPEAKERS, 3 * 8 };
|
||||
|
||||
enum SOSStopType_t
|
||||
{
|
||||
SOS_STOP_NONE = 0,
|
||||
SOS_STOP_NORM,
|
||||
SOS_STOP_FORCE,
|
||||
SOS_STOP_HOLD,
|
||||
SOS_STOP_QUEUE
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The CSosOperatorStack class:
|
||||
//
|
||||
// Manages a "stack" of operators.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSosOperatorStack
|
||||
{
|
||||
public:
|
||||
|
||||
enum SosStackType_t
|
||||
{
|
||||
SOS_NONE = 0,
|
||||
SOS_UPDATE,
|
||||
SOS_CUE,
|
||||
SOS_START,
|
||||
SOS_STOP,
|
||||
|
||||
};
|
||||
|
||||
CSosOperatorStack( SosStackType_t SosType, stack_data_t &stackData );
|
||||
~CSosOperatorStack();
|
||||
|
||||
SosStackType_t GetType() { return m_SOSType; }
|
||||
|
||||
void SetName( const char *pName ) { V_strcpy_safe( m_nName, pName ); }
|
||||
const char *GetName() { return m_nName; }
|
||||
void SetChannelGuid( int nGuid ) { m_nChannelGuid = nGuid; }
|
||||
int GetChannelGuid( ) const { return m_nChannelGuid; }
|
||||
void SetStartTime( float flStartTime ) { m_flStartTime = flStartTime; }
|
||||
float GetStartTime( ) const { return m_flStartTime; }
|
||||
float GetElapsedTime( ) const { return g_pSoundServices->GetHostTime() - m_flStartTime; }
|
||||
void SetStopTime( float flStopTime ) { m_flStopTime = flStopTime; }
|
||||
float GetStopTime( ) const { return m_flStopTime; }
|
||||
float GetElapsedStopTime( ) const { return m_flStopTime < 0.0 ? -1.0 : g_pSoundServices->GetHostTime() - m_flStopTime; }
|
||||
void SetScriptHash( HSOUNDSCRIPTHASH nHash );
|
||||
HSOUNDSCRIPTHASH GetScriptHash( ) const { return m_nScriptHash; }
|
||||
void SetOperatorsKV( KeyValues *pOpKV ) { m_pOperatorsKV = pOpKV; }
|
||||
KeyValues *GetOperatorsKV( ) const { return m_pOperatorsKV; }
|
||||
void SetStopType( SOSStopType_t stopType );
|
||||
SOSStopType_t GetStopType( ) const { return m_stopType; }
|
||||
|
||||
KeyValues *GetSyncPointsKV( KeyValues *pOperatorsKV, const char *pListName );
|
||||
KeyValues *GetSyncPointsKV( const char *pListName );
|
||||
|
||||
void GetTrackData( track_data_t &trackData ) const;
|
||||
|
||||
void AddToTail( CSosOperator *pOperator, const char *pName );
|
||||
|
||||
int FindOperatorViaOffset( size_t nOffset );
|
||||
CSosOperator *FindOperator( const char *pName, void **pStructHandle );
|
||||
int FindOperator( const char *pName );
|
||||
const char* GetOperatorName( int nOpIndex ) { return m_vOperatorMap.GetElementName( nOpIndex ); }
|
||||
int GetOperatorOffset( int nIndex );
|
||||
int GetOperatorOutputOffset( const char *pOperatorName, const char *pOutputName );
|
||||
void *GetMemPtr() { return m_pMemPool; }
|
||||
size_t GetSize() { return m_nMemSize; }
|
||||
void Execute( channel_t *pChannel, CScratchPad *pScratchPad );
|
||||
void ExecuteIterator( channel_t *pChannel, CScratchPad *pScratchPad, const void *pVoidMem, const char *pOperatorName, int * pnOperatorIndex );
|
||||
void Init( );
|
||||
void Shutdown( );
|
||||
|
||||
inline bool IsType( SosStackType_t SosType ) { return ( SosType == m_SOSType ); }
|
||||
|
||||
void Print( int nLevel );
|
||||
void Copy( CSosOperatorStack *pDstStack, size_t nMemOffset );
|
||||
void ParseKV( KeyValues *pParamKV );
|
||||
bool ShouldPrintOperators( ) const;
|
||||
bool ShouldPrintOperatorUpdates( ) const;
|
||||
// void OverParseKV( KeyValues *pOperatorsKV );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
char m_nName[64];
|
||||
SosStackType_t m_SOSType;
|
||||
void *m_pMemPool;
|
||||
size_t m_nMemSize;
|
||||
CUtlVector< CSosOperator * > m_vStack;
|
||||
CUtlDict < int, int > m_vOperatorMap;
|
||||
|
||||
int m_nChannelGuid;
|
||||
float m_flStartTime;
|
||||
HSOUNDSCRIPTHASH m_nScriptHash;
|
||||
KeyValues *m_pOperatorsKV;
|
||||
SOSStopType_t m_stopType;
|
||||
float m_flStopTime;
|
||||
|
||||
public:
|
||||
const char *m_pCurrentOperatorName;
|
||||
|
||||
};
|
||||
|
||||
extern CSosOperatorStack *S_GetStack( CSosOperatorStack::SosStackType_t stackType, stack_data_t &stackData );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The CSosOperatorStackList class:
|
||||
//
|
||||
// Manages a "stack" of operators.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSosOperatorStackList
|
||||
{
|
||||
|
||||
public:
|
||||
CSosOperatorStackList();
|
||||
~CSosOperatorStackList();
|
||||
|
||||
void SetStopType( SOSStopType_t stopType );
|
||||
SOSStopType_t GetStopType( ) const { return m_stopType; }
|
||||
void SetStopTime( float flStopTime );
|
||||
float GetStartTime( ) const { return m_flStopTime; }
|
||||
float GetElapsedStopTime( ) const { return m_flStopTime < 0.0 ? 0.0 : g_pSoundServices->GetHostTime() - m_flStopTime; }
|
||||
|
||||
bool HasStack( CSosOperatorStack::SosStackType_t SosType );
|
||||
|
||||
void Execute( CSosOperatorStack::SosStackType_t SosType, channel_t *pChannel, CScratchPad *pScratchPad );
|
||||
|
||||
void SetChannelGuid( int nGuid );
|
||||
void SetStartTime( float flStartTime );
|
||||
void SetScriptHash( HSOUNDSCRIPTHASH nHash );
|
||||
void SetStack( CSosOperatorStack *pStack );
|
||||
CSosOperatorStack *GetStack( CSosOperatorStack::SosStackType_t SosType );
|
||||
void StopStacks( SOSStopType_t stopType );
|
||||
bool IsStopped( ) const { return ( m_stopType != SOS_STOP_NONE && m_stopType!= SOS_STOP_HOLD && m_stopType!= SOS_STOP_QUEUE ); }
|
||||
bool IsStopping( ) const { return ( m_stopType != SOS_STOP_NONE ); }
|
||||
void ParseKV( stack_data_t &stackData );
|
||||
void Print( );
|
||||
|
||||
private:
|
||||
|
||||
CSosOperatorStack *m_vUpdateStack;
|
||||
CSosOperatorStack *m_vStartStack;
|
||||
CSosOperatorStack *m_vStopStack;
|
||||
CSosOperatorStack *m_vCueStack;
|
||||
SOSStopType_t m_stopType;
|
||||
float m_flStopTime;
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The CSosOperatorStackCollection class:
|
||||
//
|
||||
// Manages a "stack" of operators.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSosOperatorStackCollection
|
||||
{
|
||||
|
||||
public:
|
||||
~CSosOperatorStackCollection();
|
||||
void Clear();
|
||||
|
||||
CSosOperatorStack *GetStack( const char *pStackName );
|
||||
CSosOperatorStack *GetStack( CSosOperatorStack::SosStackType_t SosType, const char *pStackName );
|
||||
|
||||
void Print();
|
||||
void ParseKV( CSosOperatorStack::SosStackType_t SosType, KeyValues *pParamKV );
|
||||
|
||||
private:
|
||||
|
||||
CUtlDict <CSosOperatorStack *, int> m_vAllStacks;
|
||||
CUtlDict <CSosOperatorStack *, int> m_vUpdateStacks;
|
||||
CUtlDict <CSosOperatorStack *, int> m_vStartStacks;
|
||||
CUtlDict <CSosOperatorStack *, int> m_vStopStacks;
|
||||
CUtlDict <CSosOperatorStack *, int> m_vCueStacks;
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
class SosStopQueueData_t
|
||||
{
|
||||
public:
|
||||
int m_nChannelGuid;
|
||||
float m_nStopTime;
|
||||
};
|
||||
class SosStartQueueData_t
|
||||
{
|
||||
public:
|
||||
StartSoundParams_t m_startSoundParams;
|
||||
float m_nStartTime;
|
||||
bool m_bFromPrestart;
|
||||
};
|
||||
|
||||
class CSosOperatorSystem
|
||||
{
|
||||
public:
|
||||
CSosOperatorSystem();
|
||||
~CSosOperatorSystem();
|
||||
|
||||
void Init();
|
||||
void Update();
|
||||
void Shutdown();
|
||||
void Flush();
|
||||
void PrintOperatorList();
|
||||
|
||||
void ClearSubSystems();
|
||||
|
||||
void QueueStartEntry( StartSoundParams_t &startParams, float flDelay = 0.0, bool bFromPrestart = false );
|
||||
void StartQueuedEntries();
|
||||
|
||||
void QueueStopChannel( int nChannelGuid, float flDelay = 0.0 );
|
||||
void StopQueuedChannels();
|
||||
bool IsInStopQueue( int nChannelGuid );
|
||||
|
||||
void StopChannelOnTrack( const char *pTrackName, bool bStopAll = false, float flStopDelay = 0.0 );
|
||||
void SetChannelOnTrack( const char *pTrackName, channel_t *pChannel );
|
||||
void RemoveChannelFromTracks( int nGuid );
|
||||
void RemoveChannelFromTrack( const char *pTrackName, int nGuid );
|
||||
void DEBUG_ShowTrackList( void );
|
||||
|
||||
channel_t *GetChannelOnTrack( const char *pTrackName );
|
||||
HSOUNDSCRIPTHASH GetSoundEntryOnTrack( const char *pTrackName );
|
||||
bool GetTrackDataOnTrack( const char *pTrackName, track_data_t &trackData );
|
||||
|
||||
bool SetOpVarFloat( const char *pString, float flVariable );
|
||||
bool GetOpVarFloat( const char *pString, float &flVariable );
|
||||
void DEBUG_ShowOpvarList( void );
|
||||
|
||||
|
||||
public:
|
||||
CSosOperatorStackCollection m_MasterStackCollection;
|
||||
CUtlDict <CSosOperator*, int> m_vOperatorCollection;
|
||||
|
||||
CSosEntryMatchList m_sosEntryBlockList;
|
||||
|
||||
CUtlDict <channel_t *, int> m_vTrackDict;
|
||||
|
||||
|
||||
// NOT THREAD PROTECTED!
|
||||
CUtlVector < SosStopQueueData_t * > m_sosStopChannelQueue;
|
||||
CUtlVector< SosStartQueueData_t * > m_sosStartEntryQueue;
|
||||
|
||||
// CTSQueue< StartSoundParams_t > m_sosStartEntryQueue;
|
||||
// CTSQueue< sos_stop_queue_t > m_sosStopChannelQueue;
|
||||
|
||||
static CSosOperatorSystem *GetSoundOperatorSystem();
|
||||
|
||||
// Used to generate random numbers
|
||||
CUniformRandomStream m_operatorRandomStream;
|
||||
|
||||
private:
|
||||
bool m_bHasInitialized;
|
||||
// CUtlStringMap < float > m_sosFloatOpvarMap;
|
||||
CUtlDict < float, int > m_sosOpVarFloatMap;
|
||||
};
|
||||
|
||||
#define g_pSoundOperatorSystem CSosOperatorSystem::GetSoundOperatorSystem()
|
||||
|
||||
#endif // SOS_SYSTEM_H
|
||||
Reference in New Issue
Block a user