VSoundEffectTrack.cpp
Engine/source/Verve/Extension/SoundEffect/VSoundEffectTrack.cpp
Public Functions
Detailed Description
Public Functions
IMPLEMENT_CONOBJECT(VSoundEffectTrack )
1 2//----------------------------------------------------------------------------- 3// Verve 4// Copyright (C) 2014 - Violent Tulip 5// 6// Permission is hereby granted, free of charge, to any person obtaining a copy 7// of this software and associated documentation files (the "Software"), to 8// deal in the Software without restriction, including without limitation the 9// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10// sell copies of the Software, and to permit persons to whom the Software is 11// furnished to do so, subject to the following conditions: 12// 13// The above copyright notice and this permission notice shall be included in 14// all copies or substantial portions of the Software. 15// 16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22// IN THE SOFTWARE. 23//----------------------------------------------------------------------------- 24#include "Verve/Extension/SoundEffect/VSoundEffectTrack.h" 25#include "Verve/Extension/SoundEffect/VSoundEffectEvent.h" 26 27#include "console/consoleTypes.h" 28 29//----------------------------------------------------------------------------- 30IMPLEMENT_CONOBJECT( VSoundEffectTrack ); 31//----------------------------------------------------------------------------- 32 33VSoundEffectTrack::VSoundEffectTrack( void ) : 34 mSource( NULL ) 35{ 36 setLabel( "SoundTrack" ); 37} 38 39//----------------------------------------------------------------------------- 40// 41// Controller Methods. 42// 43//----------------------------------------------------------------------------- 44 45//----------------------------------------------------------------------------- 46// 47// VSoundEffectTrack::onControllerEvent( pEvent ); 48// 49// If the controller ceases playback and the track has a valid reference to a 50// source provider, then the sound is stopped. 51// 52//----------------------------------------------------------------------------- 53bool VSoundEffectTrack::onControllerEvent( VController::eControllerEventType pEvent ) 54{ 55 if ( !Parent::onControllerEvent( pEvent ) ) 56 { 57 // Skip. 58 return false; 59 } 60 61 // Enabled? 62 if ( !isEnabled() ) 63 { 64 // Continue Processing Events. 65 return true; 66 } 67 68 switch ( pEvent ) 69 { 70 case VController::k_EventPause : 71 case VController::k_EventStop : 72 { 73#ifdef VT_EDITOR 74 75 if ( mSource ) 76 { 77 // Stop Sound. 78 VTorque::stopSound( mSource ); 79 80 // Clear Source. 81 mSource = NULL; 82 } 83 84#endif 85 } break; 86 } 87 88 return true; 89} 90 91//----------------------------------------------------------------------------- 92// 93// VSoundEffectTrack::onControllerReset( pTime, pForward ); 94// 95// If the track is reset and it has a valid reference to a source provider, 96// then the sound is stopped. 97// 98//----------------------------------------------------------------------------- 99void VSoundEffectTrack::onControllerReset( const S32 &pTime, const bool &pForward ) 100{ 101 // Default Reset. 102 Parent::onControllerReset( pTime, pForward ); 103 104 if ( mSource ) 105 { 106 // Stop Sound. 107 VTorque::stopSound( mSource ); 108 } 109 110 // Clear Source. 111 mSource = NULL; 112} 113